Commit 2910a1b6 authored by csilv@chromium.org's avatar csilv@chromium.org

[uber page] Remove extensions sub-page from options2.

BUG=107469
TEST=Verify that chrome://settings-frame still functions sans extensions.
Review URL: http://codereview.chromium.org/8949006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114663 0039d316-1c4b-4281-b951-d872f2087c98
parent 25fba3fd
This diff is collapsed.
/*
Copyright (c) 2011 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
*/
.details-view {
-webkit-padding-end: 10px;
}
.extension-list-item {
padding-bottom: 7px;
padding-top: 7px;
width: 100%;
-webkit-user-select: auto;
}
/* Get rid of display: table, which causes width issues. */
#extension-settings .displaytable {
display: block;
}
/* Get rid of display: table row, which causes width issues. */
#extension-settings .displaytable > section {
display: block;
}
/* Get rid of display: table cell, which causes width issues. */
#extension-settings .displaytable > section > * {
display: block;
}
.extension-settings-content {
border-bottom : 0px solid #eee;
margin-top: 3px;
}
#extension-settings-list {
min-height: 0;
overflow-y: hidden;
}
/* Get rid of the light-blue background on list item hover. */
#extension-settings-list:not([disabled]) > :hover {
background-color: white;
border-color: #CDCDCD;
}
.butter-bar {
background: #FFF299;
padding: 2px 5px;
border-radius: 3px;
white-space: normal;
}
.search-suppress {
display: none;
height: 0;
}
.extension-list-item-collaped {
height: auto;
margin-bottom: 16px;
-webkit-transition: padding 300ms, overflow 300ms, opacity 700ms;
}
.extension-list-item-expanded {
height: auto;
margin-bottom: 16px;
overflow: visible;
-webkit-transition: padding 300ms, overflow 300ms, opacity 700ms;
}
.extension-settings {
overflow-x: hidden;
}
.extension-icon {
height: 48px;
vertical-align: text-top;
width: 48px;
-webkit-padding-start: 15px;
-webkit-padding-end: 15px;
-webkit-user-select: none;
}
.extension-title {
font-size: 16px;
font-weight: 500;
-webkit-padding-end: 20px;
}
.extension-version {
font-size: 13px;
font-weight: 400;
-webkit-padding-end: 7px;
}
.extension-description {
font-size: 13px;
white-space: normal;
-webkit-padding-end: 5px;
}
.extension-checkbox-span {
-webkit-margin-start: 7px;
}
.extension-checkbox-label {
-webkit-margin-end: 10px;
}
.extension-delete {
-webkit-margin-start: 5px;
}
.extension-details-hidden {
opacity: 0;
max-height: 0;
-webkit-transition: max-height 400ms, opacity 200ms;
}
.extension-details-visible {
opacity: 1;
max-height: 1000px;
-webkit-transition: max-height 200ms, opacity 300ms;
}
.extension-links-view {
-webkit-padding-start: 15px;
}
.extension-links-trailing {
-webkit-padding-end: 7px;
}
.extension-zippy-container {
cursor: pointer;
width: 20px;
-webkit-user-select: none;
}
.extension-warnings-title {
color: red;
}
.extension-warnings {
margin-top: 6px;
}
.extension-warnings ul {
margin: 0;
}
.extension-warnings > * {
white-space: normal;
}
.informative-text {
color: gray;
}
.extension-zippy-default {
background-image: url('zippy.png');
background-repeat: no-repeat;
background-position: center top;
position: absolute;
left: 12px;
top: 25px;
width: 6px;
height: 16px;
opacity: .25;
}
.extension-zippy-collapsed {
-webkit-transition: -webkit-transform 100ms;
-webkit-transform: rotate(0deg);
}
.extension-zippy-collapsed:hover {
opacity: .5;
-webkit-transform: rotate(5deg);
-webkit-transition: -webkit-transform 100ms, opacity 100ms;
}
.extension-zippy-expanded {
-webkit-transition: -webkit-transform 100ms;
-webkit-transform: rotate(90deg);
}
.extension-zippy-expanded:hover {
-webkit-transition: -webkit-transform 100ms;
-webkit-transform: rotate(85deg);
}
.extension-enabling {
position: relative;
top: 3px;
}
.extension-enabling-label {
color: black;
-webkit-padding-start: 3px;
-webkit-padding-end: 9px;
}
.extension-enabling-label-bold {
font-weight: bold;
}
.extension-inspect-table {
padding: 0;
border-spacing: 0;
}
.extension-inspect-left-column {
vertical-align: text-top;
}
/* Dev */
.dev-open {
border-bottom: 1px solid rgb(205, 205, 205);
height: 32px;
padding-bottom: 7px;
padding-top: 13px;
-webkit-padding-start: 4px;
-webkit-padding-end: 3px;
-webkit-transition: padding 300ms, height 300ms, opacity 700ms;
}
.dev-closed {
height: 0;
opacity: 0;
padding-top: 9px;
-webkit-padding-start: 4px;
-webkit-padding-end: 3px;
-webkit-transition: padding 300ms, height 700ms, opacity 200ms;
}
.dev-button-visible {
display: inherit;
opacity: 1;
-webkit-transition: opacity 200ms;
}
.dev-button-hidden {
display: none;
}
#suggest-gallery {
-webkit-padding-start: 10px;
}
#dev-toggle {
display: block;
text-align: end;
margin-top: -28px;
-webkit-margin-end: 8px;
}
#get-more-extensions-container {
display: -webkit-box;
}
#get-more-extensions {
padding-top: 5px;
font-size: 15px;
-webkit-padding-start: 10px;
}
/* Support full keyboard accessibility without making things ugly
for users who click, by hiding some focus outlines when the user
clicks anywhere, but showing them when the user presses any key. */
body.hide-some-focus-outlines .extension-zippy-container {
outline: none;
}
<div id="extension-settings" class="page" hidden>
<h1 i18n-content="extensionSettings"></h1>
<div id="dev-toggle">
<input id="toggle-dev-on" type="checkbox" value="off"></input>
<label for="toggle-dev-on" i18n-content="extensionSettingsDeveloperMode" />
</div>
<div class="displaytable">
<div id="dev" class="dev-closed">
<table id="dev-table" width="100%">
<tr>
<td>
<button id="load-unpacked"
i18n-content="extensionSettingsLoadUnpackedButton"></button>
<button id="pack-extension"
i18n-content="extensionSettingsPackButton"></button>
</td>
<td align="right">
<button id="update-extensions-now"
i18n-content="extensionSettingsUpdateButton"></button>
</td>
</tr>
</table>
</div>
<section class="extension-settings-content">
<div class="extension-settings">
<list id="extension-settings-list"></list>
</div>
</section>
</div>
<section>
<div><strong id="no-extensions"
i18n-content="extensionSettingsNoExtensions"
hidden="true"></strong></div>
<div id="suggest-gallery" hidden="true"></div>
<div id="get-more-extensions-container" hidden="true">
<img src="chrome://theme/IDR_WEBSTORE_ICON_32">
<div id="get-more-extensions"></div>
</div>
</section>
</div>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Used for observing function of the backend datasource for this page by
// tests.
var webui_responded_ = false;
cr.define('options', function() {
var OptionsPage = options.OptionsPage;
var ExtensionsList = options.ExtensionsList;
/**
* ExtensionSettings class
* Encapsulated handling of the 'Manage Extensions' page.
* @class
*/
function ExtensionSettings() {
OptionsPage.call(this, 'extensions',
templateData.extensionSettingsTabTitle,
'extension-settings');
}
cr.addSingletonGetter(ExtensionSettings);
ExtensionSettings.prototype = {
__proto__: OptionsPage.prototype,
/**
* Initialize the page.
*/
initializePage: function() {
OptionsPage.prototype.initializePage.call(this);
// This will request the data to show on the page and will get a response
// back in returnExtensionsData.
chrome.send('extensionSettingsRequestExtensionsData');
// Set up the developer mode button.
var toggleDevMode = $('toggle-dev-on');
toggleDevMode.addEventListener('click',
this.handleToggleDevMode_.bind(this));
// Setup the gallery related links and text.
$('suggest-gallery').innerHTML =
localStrings.getString('extensionSettingsSuggestGallery');
$('get-more-extensions').innerHTML =
localStrings.getString('extensionSettingsGetMoreExtensions');
// Set up the three dev mode buttons (load unpacked, pack and update).
$('load-unpacked').addEventListener('click',
this.handleLoadUnpackedExtension_.bind(this));
$('pack-extension').addEventListener('click',
this.handlePackExtension_.bind(this));
$('update-extensions-now').addEventListener('click',
this.handleUpdateExtensionNow_.bind(this));
},
/**
* Utility function which asks the C++ to show a platform-specific file
* select dialog, and fire |callback| with the |filePath| that resulted.
* |selectType| can be either 'file' or 'folder'. |operation| can be 'load',
* 'packRoot', or 'pem' which are signals to the C++ to do some
* operation-specific configuration.
* @private
*/
showFileDialog_: function(selectType, operation, callback) {
handleFilePathSelected = function(filePath) {
callback(filePath);
handleFilePathSelected = function() {};
};
chrome.send('extensionSettingsSelectFilePath', [selectType, operation]);
},
/**
* Handles the Load Unpacked Extension button.
* @param {Event} e Change event.
* @private
*/
handleLoadUnpackedExtension_: function(e) {
this.showFileDialog_('folder', 'load', function(filePath) {
chrome.send('extensionSettingsLoad', [String(filePath)]);
});
chrome.send('coreOptionsUserMetricsAction',
['Options_LoadUnpackedExtension']);
},
/**
* Handles the Pack Extension button.
* @param {Event} e Change event.
* @private
*/
handlePackExtension_: function(e) {
OptionsPage.navigateToPage('packExtensionOverlay');
chrome.send('coreOptionsUserMetricsAction', ['Options_PackExtension']);
},
/**
* Handles the Update Extension Now button.
* @param {Event} e Change event.
* @private
*/
handleUpdateExtensionNow_: function(e) {
chrome.send('extensionSettingsAutoupdate', []);
},
/**
* Handles the Toggle Dev Mode button.
* @param {Event} e Change event.
* @private
*/
handleToggleDevMode_: function(e) {
var dev = $('dev');
if (!dev.classList.contains('dev-open')) {
// Make the Dev section visible.
dev.classList.add('dev-open');
dev.classList.remove('dev-closed');
$('load-unpacked').classList.add('dev-button-visible');
$('load-unpacked').classList.remove('dev-button-hidden');
$('pack-extension').classList.add('dev-button-visible');
$('pack-extension').classList.remove('dev-button-hidden');
$('update-extensions-now').classList.add('dev-button-visible');
$('update-extensions-now').classList.remove('dev-button-hidden');
} else {
// Hide the Dev section.
dev.classList.add('dev-closed');
dev.classList.remove('dev-open');
$('load-unpacked').classList.add('dev-button-hidden');
$('load-unpacked').classList.remove('dev-button-visible');
$('pack-extension').classList.add('dev-button-hidden');
$('pack-extension').classList.remove('dev-button-visible');
$('update-extensions-now').classList.add('dev-button-hidden');
$('update-extensions-now').classList.remove('dev-button-visible');
}
chrome.send('extensionSettingsToggleDeveloperMode', []);
},
};
/**
* Called by the dom_ui_ to re-populate the page with data representing
* the current state of installed extensions.
*/
ExtensionSettings.returnExtensionsData = function(extensionsData) {
webui_responded_ = true;
$('no-extensions').hidden = true;
$('suggest-gallery').hidden = true;
$('get-more-extensions-container').hidden = true;
if (extensionsData.extensions.length > 0) {
// Enforce order specified in the data or (if equal) then sort by
// extension name (case-insensitive).
extensionsData.extensions.sort(function(a, b) {
if (a.order == b.order) {
a = a.name.toLowerCase();
b = b.name.toLowerCase();
return a < b ? -1 : (a > b ? 1 : 0);
} else {
return a.order < b.order ? -1 : 1;
}
});
$('get-more-extensions-container').hidden = false;
} else {
$('no-extensions').hidden = false;
$('suggest-gallery').hidden = false;
}
ExtensionsList.prototype.data_ = extensionsData;
var extensionList = $('extension-settings-list');
ExtensionsList.decorate(extensionList);
}
// Export
return {
ExtensionSettings: ExtensionSettings
};
});
......@@ -24,7 +24,6 @@
<link rel="stylesheet" href="clear_browser_data_overlay.css">
<link rel="stylesheet" href="content_settings.css">
<link rel="stylesheet" href="cookies_view.css">
<link rel="stylesheet" href="extension_settings.css">
<link rel="stylesheet" href="font_settings.css">
<if expr="pp_ifdef('enable_register_protocol_handler')">
<link rel="stylesheet" href="handler_options.css">
......@@ -35,7 +34,6 @@
</if>
<link rel="stylesheet" href="language_options.css">
<link rel="stylesheet" href="manage_profile_overlay.css">
<link rel="stylesheet" href="pack_extension_overlay.css">
<link rel="stylesheet" href="password_manager.css">
<link rel="stylesheet" href="password_manager_list.css">
<link rel="stylesheet" href="personal_options.css">
......@@ -90,7 +88,6 @@
<include src="instant_confirm_overlay.html">
<include src="language_add_language_overlay.html">
<include src="manage_profile_overlay.html">
<include src="pack_extension_overlay.html">
<include src="../sync_setup_overlay.html">
<if expr="pp_ifdef('chromeos')">
<include
......@@ -129,7 +126,6 @@
<include src="chromeos/accounts_options.html">
</if>
<include src="advanced_options.html">
<include src="extension_settings.html">
</div>
<div id="subpage-sheet-container-1"
class="subpage-sheet-container transparent" hidden>
......
......@@ -14,7 +14,6 @@ var ContentSettings = options.ContentSettings;
var ContentSettingsExceptionsArea =
options.contentSettings.ContentSettingsExceptionsArea;
var CookiesView = options.CookiesView;
var ExtensionSettings = options.ExtensionSettings;
var FontSettings = options.FontSettings;
var HandlerOptions = options.HandlerOptions;
var ImportDataOverlay = options.ImportDataOverlay;
......@@ -22,7 +21,6 @@ var IntentsView = options.IntentsView;
var InstantConfirmOverlay = options.InstantConfirmOverlay;
var LanguageOptions = options.LanguageOptions;
var OptionsPage = options.OptionsPage;
var PackExtensionOverlay = options.PackExtensionOverlay;
var PasswordManager = options.PasswordManager;
var PersonalOptions = options.PersonalOptions;
var Preferences = options.Preferences;
......@@ -173,10 +171,6 @@ function load() {
OptionsPage.registerOverlay(ManageProfileOverlay.getInstance(),
PersonalOptions.getInstance());
OptionsPage.register(ExtensionSettings.getInstance());
OptionsPage.registerOverlay(PackExtensionOverlay.getInstance(),
ExtensionSettings.getInstance());
if (cr.isChromeOS) {
OptionsPage.register(AccountsOptions.getInstance());
OptionsPage.registerSubPage(ProxyOptions.getInstance(),
......
......@@ -64,8 +64,6 @@
<include src="content_settings_ui.js"></include>
<include src="cookies_list.js"></include>
<include src="cookies_view.js"></include>
<include src="extension_list.js"></include>
<include src="extension_settings.js"></include>
<include src="font_settings.js"></include>
<if expr="pp_ifdef('enable_register_protocol_handler')">
<include src="handler_options.js"></script>
......@@ -81,7 +79,6 @@
<include src="language_list.js"></include>
<include src="language_options.js"></include>
<include src="manage_profile_overlay.js"></include>
<include src="pack_extension_overlay.js"></include>
<include src="password_manager.js"></include>
<include src="password_manager_list.js"></include>
<include src="personal_options.js"></include>
......
/*
Copyright (c) 2011 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
*/
.packExtensionHeading {
width: 520px;
padding-bottom: 5px;
}
.packExtensionTextBoxes {
text-align: right;
}
.packExtensionTextArea {
width: 260px;
}
<div id="packExtensionOverlay" class="page" hidden>
<h1 i18n-content="packExtensionOverlay"></h1>
<div id="cbdContentArea" class="content-area">
<div class="packExtensionHeading" i18n-content="packExtensionHeading"></div>
<div class="packExtensionTextBoxes">
<label i18n-content="packExtensionRootDir"></label>
<input class="packExtensionTextArea" id="extensionRootDir" type="text" />
<button id="browseExtensionDir"
i18n-content="packExtensionBrowseButton"></button>
</div>
<div class="packExtensionTextBoxes">
<label i18n-content="packExtensionPrivateKey"></label>
<input class="packExtensionTextArea"
id="extensionPrivateKey" type="text" />
<button id="browsePrivateKey"
i18n-content="packExtensionBrowseButton"></button>
</div>
</div>
<div class="action-area">
<div class="action-area-right">
<div class="button-strip">
<button id="packExtensionDismiss" i18n-content="cancel"></button>
<button id="packExtensionCommit"
i18n-content="packExtensionCommit"></button>
</div>
</div>
</div>
</div>
\ No newline at end of file
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
cr.define('options', function() {
const OptionsPage = options.OptionsPage;
/**
* PackExtensionOverlay class
* Encapsulated handling of the 'Pack Extension' overlay page.
* @constructor
*/
function PackExtensionOverlay() {
OptionsPage.call(this, 'packExtensionOverlay',
templateData.packExtensionOverlayTabTitle,
'packExtensionOverlay');
}
cr.addSingletonGetter(PackExtensionOverlay);
PackExtensionOverlay.prototype = {
// Inherit PackExtensionOverlay from OptionsPage.
__proto__: OptionsPage.prototype,
/**
* Initialize the page.
*/
initializePage: function() {
// Call base class implementation to starts preference initialization.
OptionsPage.prototype.initializePage.call(this);
$('packExtensionDismiss').onclick = function(event) {
OptionsPage.closeOverlay();
};
$('packExtensionCommit').onclick = function(event) {
var extensionPath = $('extensionRootDir').value;
var privateKeyPath = $('extensionPrivateKey').value;
chrome.send('pack', [extensionPath, privateKeyPath]);
};
$('browseExtensionDir').addEventListener('click',
this.handleBrowseExtensionDir_.bind(this));
$('browsePrivateKey').addEventListener('click',
this.handleBrowsePrivateKey_.bind(this));
},
/**
* Utility function which asks the C++ to show a platform-specific file
* select dialog, and fire |callback| with the |filePath| that resulted.
* |selectType| can be either 'file' or 'folder'. |operation| can be 'load',
* 'packRoot', or 'pem' which are signals to the C++ to do some
* operation-specific configuration.
* @private
*/
showFileDialog_: function(selectType, operation, callback) {
handleFilePathSelected = function(filePath) {
callback(filePath);
handleFilePathSelected = function() {};
};
chrome.send('extensionSettingsSelectFilePath', [selectType, operation]);
},
/**
* Handles the showing of the extension directory browser.
* @param {Event} e Change event.
* @private
*/
handleBrowseExtensionDir_: function(e) {
this.showFileDialog_('folder', 'load', function(filePath) {
$('extensionRootDir').value = filePath;
});
},
/**
* Handles the showing of the extension private key file.
* @param {Event} e Change event.
* @private
*/
handleBrowsePrivateKey_: function(e) {
this.showFileDialog_('file', 'load', function(filePath) {
$('extensionPrivateKey').value = filePath;
});
},
};
// Export
return {
PackExtensionOverlay: PackExtensionOverlay
};
});
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_EXTENSION_SETTINGS_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_OPTIONS2_EXTENSION_SETTINGS_HANDLER_H_
#pragma once
#include <set>
#include <string>
#include <vector>
#include "chrome/browser/extensions/extension_install_ui.h"
#include "chrome/browser/extensions/extension_uninstall_dialog.h"
#include "chrome/browser/extensions/extension_warning_set.h"
#include "chrome/browser/ui/select_file_dialog.h"
#include "chrome/browser/ui/webui/options2/options_ui2.h"
#include "chrome/browser/ui/webui/chrome_web_ui.h"
#include "chrome/common/extensions/extension_resource.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "googleurl/src/gurl.h"
class Extension;
class ExtensionService;
class FilePath;
class PrefService;
class UserScript;
namespace base {
class DictionaryValue;
class ListValue;
}
// Information about a page running in an extension, for example a popup bubble,
// a background page, or a tab contents.
struct ExtensionPage {
ExtensionPage(const GURL& url, int render_process_id, int render_view_id,
bool incognito)
: url(url),
render_process_id(render_process_id),
render_view_id(render_view_id),
incognito(incognito) {}
GURL url;
int render_process_id;
int render_view_id;
bool incognito;
};
// Extension Settings UI handler.
class ExtensionSettingsHandler : public OptionsPage2UIHandler,
public SelectFileDialog::Listener,
public ExtensionUninstallDialog::Delegate {
public:
ExtensionSettingsHandler();
virtual ~ExtensionSettingsHandler();
static void RegisterUserPrefs(PrefService* prefs);
// Extension Detail JSON Struct for page. (static for ease of testing).
// Note: |service| and |warnings| can be NULL in unit tests.
static base::DictionaryValue* CreateExtensionDetailValue(
ExtensionService* service,
const Extension* extension,
const std::vector<ExtensionPage>& pages,
const ExtensionWarningSet* warnings,
bool enabled,
bool terminated);
// ContentScript JSON Struct for page. (static for ease of testing).
static base::DictionaryValue* CreateContentScriptDetailValue(
const UserScript& script,
const FilePath& extension_path);
// Callback for "requestExtensionsData" message.
void HandleRequestExtensionsData(const base::ListValue* args);
// Callback for "toggleDeveloperMode" message.
void HandleToggleDeveloperMode(const base::ListValue* args);
// Callback for "inspect" message.
void HandleInspectMessage(const base::ListValue* args);
// Callback for "reload" message.
void HandleReloadMessage(const base::ListValue* args);
// Callback for "enable" message.
void HandleEnableMessage(const base::ListValue* args);
// Callback for "enableIncognito" message.
void HandleEnableIncognitoMessage(const base::ListValue* args);
// Callback for "allowFileAcces" message.
void HandleAllowFileAccessMessage(const base::ListValue* args);
// Callback for "uninstall" message.
void HandleUninstallMessage(const base::ListValue* args);
// Callback for "options" message.
void HandleOptionsMessage(const base::ListValue* args);
// Callback for "showButton" message.
void HandleShowButtonMessage(const base::ListValue* args);
// Callback for "load" message.
void HandleLoadMessage(const base::ListValue* args);
// Callback for "pack" message.
void HandlePackMessage(const base::ListValue* args);
// Callback for "autoupdate" message.
void HandleAutoUpdateMessage(const base::ListValue* args);
// Utility for calling javascript window.alert in the page.
void ShowAlert(const std::string& message);
// Callback for "selectFilePath" message.
void HandleSelectFilePathMessage(const base::ListValue* args);
// Utility for callbacks that get an extension ID as the sole argument.
const Extension* GetExtension(const base::ListValue* args);
// Forces a UI update if appropriate after a notification is received.
void MaybeUpdateAfterNotification();
// Register for notifications that we need to reload the page.
void MaybeRegisterForNotifications();
// SelectFileDialog::Listener
virtual void FileSelected(const FilePath& path,
int index, void* params) OVERRIDE;
virtual void MultiFilesSelected(
const std::vector<FilePath>& files, void* params) OVERRIDE;
virtual void FileSelectionCanceled(void* params) OVERRIDE {}
// WebUIMessageHandler implementation.
virtual void RegisterMessages() OVERRIDE;
virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE;
// OptionsUIHandler implementation.
virtual void GetLocalizedValues(
base::DictionaryValue* localized_strings) OVERRIDE;
virtual void Initialize() OVERRIDE;
// content::NotificationObserver implementation.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
// ExtensionUninstallDialog::Delegate implementation, used for receiving
// notification about uninstall confirmation dialog selections.
virtual void ExtensionUninstallAccepted() OVERRIDE;
virtual void ExtensionUninstallCanceled() OVERRIDE;
private:
// Helper that lists the current active html pages for an extension.
std::vector<ExtensionPage> GetActivePagesForExtension(
const Extension* extension);
void GetActivePagesForExtensionProcess(
const std::set<RenderViewHost*>& views,
std::vector<ExtensionPage> *result);
// Returns the ExtensionUninstallDialog object for this class, creating it if
// needed.
ExtensionUninstallDialog* GetExtensionUninstallDialog();
// Our model. Outlives us since it's owned by our containing profile.
ExtensionService* extension_service_;
// Used to pick the directory when loading an extension.
scoped_refptr<SelectFileDialog> load_extension_dialog_;
// Used to show confirmation UI for uninstalling extensions in incognito mode.
scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_;
// The id of the extension we are prompting the user about.
std::string extension_id_prompting_;
// If true, we will ignore notifications in ::Observe(). This is needed
// to prevent reloading the page when we were the cause of the
// notification.
bool ignore_notifications_;
// The page may be refreshed in response to a RENDER_VIEW_HOST_DELETED,
// but the iteration over RenderViewHosts will include the host because the
// notification is sent when it is in the process of being deleted (and before
// it is removed from the process). Keep a pointer to it so we can exclude
// it from the active views.
RenderViewHost* deleting_rvh_;
// We want to register for notifications only after we've responded at least
// once to the page, otherwise we'd be calling javacsript functions on objects
// that don't exist yet when notifications come in. This variable makes sure
// we do so only once.
bool registered_for_notifications_;
DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler);
};
#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_EXTENSION_SETTINGS_HANDLER_H_
......@@ -26,14 +26,12 @@
#include "chrome/browser/ui/webui/options2/content_settings_handler.h"
#include "chrome/browser/ui/webui/options2/cookies_view_handler.h"
#include "chrome/browser/ui/webui/options2/core_options_handler.h"
#include "chrome/browser/ui/webui/options2/extension_settings_handler.h"
#include "chrome/browser/ui/webui/options2/font_settings_handler.h"
#include "chrome/browser/ui/webui/options2/handler_options_handler.h"
#include "chrome/browser/ui/webui/options2/import_data_handler.h"
#include "chrome/browser/ui/webui/options2/language_options_handler.h"
#include "chrome/browser/ui/webui/options2/manage_profile_handler.h"
#include "chrome/browser/ui/webui/options2/options_sync_setup_handler.h"
#include "chrome/browser/ui/webui/options2/pack_extension_handler.h"
#include "chrome/browser/ui/webui/options2/password_manager_handler.h"
#include "chrome/browser/ui/webui/options2/personal_options_handler.h"
#include "chrome/browser/ui/webui/options2/search_engine_manager_handler.h"
......@@ -213,7 +211,6 @@ Options2UI::Options2UI(TabContents* contents)
AddOptionsPageUIHandler(localized_strings, new ClearBrowserDataHandler());
AddOptionsPageUIHandler(localized_strings, new ContentSettingsHandler());
AddOptionsPageUIHandler(localized_strings, new CookiesViewHandler());
AddOptionsPageUIHandler(localized_strings, new ExtensionSettingsHandler());
AddOptionsPageUIHandler(localized_strings, new FontSettingsHandler());
AddOptionsPageUIHandler(localized_strings, new WebIntentsSettingsHandler());
#if defined(OS_CHROMEOS)
......@@ -223,7 +220,6 @@ Options2UI::Options2UI(TabContents* contents)
AddOptionsPageUIHandler(localized_strings, new LanguageOptionsHandler());
#endif
AddOptionsPageUIHandler(localized_strings, new ManageProfileHandler());
AddOptionsPageUIHandler(localized_strings, new PackExtensionHandler());
AddOptionsPageUIHandler(localized_strings, new PasswordManagerHandler());
AddOptionsPageUIHandler(localized_strings, new PersonalOptionsHandler());
AddOptionsPageUIHandler(localized_strings, new SearchEngineManagerHandler());
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/options2/pack_extension_handler.h"
#include "base/bind.h"
#include "base/utf_string_conversions.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
PackExtensionHandler::PackExtensionHandler() {
}
PackExtensionHandler::~PackExtensionHandler() {
if (pack_job_.get())
pack_job_->ClearClient();
}
void PackExtensionHandler::Initialize() {
}
void PackExtensionHandler::GetLocalizedValues(
DictionaryValue* localized_strings) {
DCHECK(localized_strings);
RegisterTitle(localized_strings, "clearBrowserDataOverlay",
IDS_CLEAR_BROWSING_DATA_TITLE);
localized_strings->SetString("packExtensionOverlay",
l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_DIALOG_TITLE));
localized_strings->SetString("packExtensionHeading",
l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_DIALOG_HEADING));
localized_strings->SetString("packExtensionCommit",
l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_BUTTON));
localized_strings->SetString("packExtensionRootDir",
l10n_util::GetStringUTF16(
IDS_EXTENSION_PACK_DIALOG_ROOT_DIRECTORY_LABEL));
localized_strings->SetString("packExtensionPrivateKey",
l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_DIALOG_PRIVATE_KEY_LABEL));
localized_strings->SetString("packExtensionBrowseButton",
l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_DIALOG_BROWSE));
}
void PackExtensionHandler::RegisterMessages() {
// Setup handlers specific to this panel.
web_ui_->RegisterMessageCallback("pack",
base::Bind(&PackExtensionHandler::HandlePackMessage,
base::Unretained(this)));
}
void PackExtensionHandler::OnPackSuccess(const FilePath& crx_file,
const FilePath& pem_file) {
ListValue results;
web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay", results);
ShowAlert(UTF16ToUTF8(PackExtensionJob::StandardSuccessMessage(crx_file,
pem_file)));
}
void PackExtensionHandler::OnPackFailure(const std::string& error) {
ShowAlert(error);
}
void PackExtensionHandler::HandlePackMessage(const ListValue* args) {
std::string extension_path;
std::string private_key_path;
CHECK_EQ(2U, args->GetSize());
CHECK(args->GetString(0, &extension_path));
CHECK(args->GetString(1, &private_key_path));
FilePath root_directory =
FilePath::FromWStringHack(UTF8ToWide(extension_path));
FilePath key_file = FilePath::FromWStringHack(UTF8ToWide(private_key_path));
if (root_directory.empty()) {
if (extension_path.empty()) {
ShowAlert(l10n_util::GetStringUTF8(
IDS_EXTENSION_PACK_DIALOG_ERROR_ROOT_REQUIRED));
} else {
ShowAlert(l10n_util::GetStringUTF8(
IDS_EXTENSION_PACK_DIALOG_ERROR_ROOT_INVALID));
}
return;
}
if (!private_key_path.empty() && key_file.empty()) {
ShowAlert(l10n_util::GetStringUTF8(
IDS_EXTENSION_PACK_DIALOG_ERROR_KEY_INVALID));
return;
}
pack_job_ = new PackExtensionJob(this, root_directory, key_file);
pack_job_->Start();
}
void PackExtensionHandler::ShowAlert(const std::string& message) {
ListValue arguments;
arguments.Append(Value::CreateStringValue(message));
web_ui_->CallJavascriptFunction("alert", arguments);
}
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_PACK_EXTENSION_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_OPTIONS2_PACK_EXTENSION_HANDLER_H_
#pragma once
#include <string>
#include "chrome/browser/browsing_data_remover.h"
#include "chrome/browser/extensions/pack_extension_job.h"
#include "chrome/browser/plugin_data_remover_helper.h"
#include "chrome/browser/ui/webui/options2/options_ui2.h"
// Clear browser data handler page UI handler.
class PackExtensionHandler : public OptionsPage2UIHandler,
public PackExtensionJob::Client {
public:
PackExtensionHandler();
virtual ~PackExtensionHandler();
// OptionsPage2UIHandler implementation.
virtual void Initialize() OVERRIDE;
virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE;
// WebUIMessageHandler implementation.
virtual void RegisterMessages() OVERRIDE;
// ExtensionPackJob::Client
virtual void OnPackSuccess(const FilePath& crx_file,
const FilePath& key_file) OVERRIDE;
virtual void OnPackFailure(const std::string& error) OVERRIDE;
private:
// Javascript callback to start packing an extension.
void HandlePackMessage(const ListValue* args);
// A function to ask the webpage to show an alert.
void ShowAlert(const std::string& message);
// Used to package the extension.
scoped_refptr<PackExtensionJob> pack_job_;
DISALLOW_COPY_AND_ASSIGN(PackExtensionHandler);
};
#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_PACK_EXTENSION_HANDLER_H_
......@@ -3981,8 +3981,6 @@
'browser/ui/webui/options2/cookies_view_handler.h',
'browser/ui/webui/options2/core_options_handler.cc',
'browser/ui/webui/options2/core_options_handler.h',
'browser/ui/webui/options2/extension_settings_handler.h',
'browser/ui/webui/options2/extension_settings_handler.cc',
'browser/ui/webui/options2/font_settings_handler.cc',
'browser/ui/webui/options2/font_settings_handler.h',
'browser/ui/webui/options2/font_settings_utils.h',
......@@ -4005,8 +4003,6 @@
'browser/ui/webui/options2/options_ui2.h',
'browser/ui/webui/options2/password_manager_handler.cc',
'browser/ui/webui/options2/password_manager_handler.h',
'browser/ui/webui/options2/pack_extension_handler.h',
'browser/ui/webui/options2/pack_extension_handler.cc',
'browser/ui/webui/options2/personal_options_handler.cc',
'browser/ui/webui/options2/personal_options_handler.h',
'browser/ui/webui/options2/search_engine_manager_handler.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment