diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-27 22:09:40 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-27 22:09:40 +0000 |
commit | 9cddd470b53f54df561ac630c182dfd393cce7fd (patch) | |
tree | 5d7f48c12c151f6a3badd5dc8a517a69175d1bec | |
parent | 120095f6071469461c10b5fa4ef26ffcd42a41d6 (diff) | |
download | chromium_src-9cddd470b53f54df561ac630c182dfd393cce7fd.zip chromium_src-9cddd470b53f54df561ac630c182dfd393cce7fd.tar.gz chromium_src-9cddd470b53f54df561ac630c182dfd393cce7fd.tar.bz2 |
Make possible reloading extensions from the chrome://extensions/ page.
http://crbug.com/16459
Review URL: http://codereview.chromium.org/159323
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21719 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/extensions_service.cc | 8 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service.h | 3 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_ui.cc | 11 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_ui.h | 5 | ||||
-rw-r--r-- | chrome/browser/resources/extensions_ui.html | 18 |
5 files changed, 41 insertions, 4 deletions
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index 970ddc0..2acc256 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -354,6 +354,14 @@ void ExtensionsService::UpdateExtension(const std::string& id, alert_on_error, scoped_refptr<ExtensionsService>(this))); } +void ExtensionsService::ReloadExtension(const std::string& extension_id) { + Extension* extension = GetExtensionById(extension_id); + FilePath extension_path = extension->path(); + + UnloadExtension(extension_id); + LoadExtension(extension_path); +} + void ExtensionsService::UninstallExtension(const std::string& extension_id, bool external_uninstall) { Extension* extension = GetExtensionById(extension_id); diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h index 4a57e41..b664b22 100644 --- a/chrome/browser/extensions/extensions_service.h +++ b/chrome/browser/extensions/extensions_service.h @@ -153,6 +153,9 @@ class ExtensionsService bool alert_on_error, ExtensionInstallCallback* callback); + // Reloads the specified extension. + void ReloadExtension(const std::string& extension_id); + // Uninstalls the specified extension. Callers should only call this method // with extensions that exist. |external_uninstall| is a magical parameter // that is only used to send information to ExtensionPrefs, which external diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index ffd2d04..73714f5 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -75,6 +75,8 @@ void ExtensionsDOMHandler::RegisterMessages() { NewCallback(this, &ExtensionsDOMHandler::HandleRequestExtensionsData)); dom_ui_->RegisterMessageCallback("inspect", NewCallback(this, &ExtensionsDOMHandler::HandleInspectMessage)); + dom_ui_->RegisterMessageCallback("reload", + NewCallback(this, &ExtensionsDOMHandler::HandleReloadMessage)); dom_ui_->RegisterMessageCallback("uninstall", NewCallback(this, &ExtensionsDOMHandler::HandleUninstallMessage)); } @@ -127,6 +129,15 @@ void ExtensionsDOMHandler::HandleInspectMessage(const Value* value) { DevToolsManager::GetInstance()->OpenDevToolsWindow(host); } +void ExtensionsDOMHandler::HandleReloadMessage(const Value* value) { + CHECK(value->IsType(Value::TYPE_LIST)); + const ListValue* list = static_cast<const ListValue*>(value); + CHECK(list->GetSize() == 1); + std::string extension_id; + CHECK(list->GetString(0, &extension_id)); + extensions_service_->ReloadExtension(extension_id); +} + void ExtensionsDOMHandler::HandleUninstallMessage(const Value* value) { CHECK(value->IsType(Value::TYPE_LIST)); const ListValue* list = static_cast<const ListValue*>(value); diff --git a/chrome/browser/extensions/extensions_ui.h b/chrome/browser/extensions/extensions_ui.h index 38b302b..c92c2ca 100644 --- a/chrome/browser/extensions/extensions_ui.h +++ b/chrome/browser/extensions/extensions_ui.h @@ -50,7 +50,7 @@ class ExtensionsDOMHandler : public DOMMessageHandler { public: explicit ExtensionsDOMHandler(ExtensionsService* extension_service); virtual ~ExtensionsDOMHandler(); - + // DOMMessageHandler implementation. virtual void RegisterMessages(); @@ -71,6 +71,9 @@ class ExtensionsDOMHandler : public DOMMessageHandler { // Callback for "inspect" message. void HandleInspectMessage(const Value* value); + // Callback for "reload" message. + void HandleReloadMessage(const Value* value); + // Callback for "uninstall" message. void HandleUninstallMessage(const Value* value); diff --git a/chrome/browser/resources/extensions_ui.html b/chrome/browser/resources/extensions_ui.html index f956f1e..eba9e72 100644 --- a/chrome/browser/resources/extensions_ui.html +++ b/chrome/browser/resources/extensions_ui.html @@ -125,6 +125,14 @@ function sendInspectMessage(viewData) { } /** + * Handles a 'reload' button getting clicked. + */ +function handleReloadExtension(node) { + // Tell the C++ ExtensionDOMHandler to reload the extension. + chrome.send('reload', [node.extensionId]); +} + +/** * Handles an 'uninstall' button getting clicked. */ function handleUninstallExtension(node) { @@ -170,8 +178,8 @@ div.extension-name { text-align: left; } -div.extension-uninstall { - margin-bottom: 1em; +div.extension-actions { + margin: 1em; } dl { @@ -250,7 +258,11 @@ th.desc { <div jsdisplay="extensions.length > 0"> <div class="extension" jsselect="extensions"> <div class="extension-name" jscontent="name">Extension Name</div> - <div class="extension-uninstall"> + <div class="extension-actions"> + <button + jsvalues=".extensionId:id" + onclick="handleReloadExtension(this)" + >Reload</button> <button jsvalues=".extensionId:id" onclick="handleUninstallExtension(this)" |