| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extensions_ui.h" | 5 #include "chrome/browser/extensions/extensions_ui.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/thread.h" | 10 #include "base/thread.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 ExtensionsDOMHandler::ExtensionsDOMHandler( | 68 ExtensionsDOMHandler::ExtensionsDOMHandler( |
| 69 ExtensionsService* extension_service) | 69 ExtensionsService* extension_service) |
| 70 : extensions_service_(extension_service) { | 70 : extensions_service_(extension_service) { |
| 71 } | 71 } |
| 72 | 72 |
| 73 void ExtensionsDOMHandler::RegisterMessages() { | 73 void ExtensionsDOMHandler::RegisterMessages() { |
| 74 dom_ui_->RegisterMessageCallback("requestExtensionsData", | 74 dom_ui_->RegisterMessageCallback("requestExtensionsData", |
| 75 NewCallback(this, &ExtensionsDOMHandler::HandleRequestExtensionsData)); | 75 NewCallback(this, &ExtensionsDOMHandler::HandleRequestExtensionsData)); |
| 76 dom_ui_->RegisterMessageCallback("inspect", | 76 dom_ui_->RegisterMessageCallback("inspect", |
| 77 NewCallback(this, &ExtensionsDOMHandler::HandleInspectMessage)); | 77 NewCallback(this, &ExtensionsDOMHandler::HandleInspectMessage)); |
| 78 dom_ui_->RegisterMessageCallback("reload", |
| 79 NewCallback(this, &ExtensionsDOMHandler::HandleReloadMessage)); |
| 78 dom_ui_->RegisterMessageCallback("uninstall", | 80 dom_ui_->RegisterMessageCallback("uninstall", |
| 79 NewCallback(this, &ExtensionsDOMHandler::HandleUninstallMessage)); | 81 NewCallback(this, &ExtensionsDOMHandler::HandleUninstallMessage)); |
| 80 } | 82 } |
| 81 | 83 |
| 82 void ExtensionsDOMHandler::HandleRequestExtensionsData(const Value* value) { | 84 void ExtensionsDOMHandler::HandleRequestExtensionsData(const Value* value) { |
| 83 DictionaryValue results; | 85 DictionaryValue results; |
| 84 | 86 |
| 85 // Add the extensions to the results structure. | 87 // Add the extensions to the results structure. |
| 86 ListValue *extensions_list = new ListValue(); | 88 ListValue *extensions_list = new ListValue(); |
| 87 const ExtensionList* extensions = extensions_service_->extensions(); | 89 const ExtensionList* extensions = extensions_service_->extensions(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 RenderViewHost* host = RenderViewHost::FromID(render_process_id, | 122 RenderViewHost* host = RenderViewHost::FromID(render_process_id, |
| 121 render_view_id); | 123 render_view_id); |
| 122 if (!host) { | 124 if (!host) { |
| 123 // This can happen if the host has gone away since the page was displayed. | 125 // This can happen if the host has gone away since the page was displayed. |
| 124 return; | 126 return; |
| 125 } | 127 } |
| 126 | 128 |
| 127 DevToolsManager::GetInstance()->OpenDevToolsWindow(host); | 129 DevToolsManager::GetInstance()->OpenDevToolsWindow(host); |
| 128 } | 130 } |
| 129 | 131 |
| 132 void ExtensionsDOMHandler::HandleReloadMessage(const Value* value) { |
| 133 CHECK(value->IsType(Value::TYPE_LIST)); |
| 134 const ListValue* list = static_cast<const ListValue*>(value); |
| 135 CHECK(list->GetSize() == 1); |
| 136 std::string extension_id; |
| 137 CHECK(list->GetString(0, &extension_id)); |
| 138 extensions_service_->ReloadExtension(extension_id); |
| 139 } |
| 140 |
| 130 void ExtensionsDOMHandler::HandleUninstallMessage(const Value* value) { | 141 void ExtensionsDOMHandler::HandleUninstallMessage(const Value* value) { |
| 131 CHECK(value->IsType(Value::TYPE_LIST)); | 142 CHECK(value->IsType(Value::TYPE_LIST)); |
| 132 const ListValue* list = static_cast<const ListValue*>(value); | 143 const ListValue* list = static_cast<const ListValue*>(value); |
| 133 CHECK(list->GetSize() == 1); | 144 CHECK(list->GetSize() == 1); |
| 134 std::string extension_id; | 145 std::string extension_id; |
| 135 CHECK(list->GetString(0, &extension_id)); | 146 CHECK(list->GetString(0, &extension_id)); |
| 136 extensions_service_->UninstallExtension(extension_id, false); | 147 extensions_service_->UninstallExtension(extension_id, false); |
| 137 } | 148 } |
| 138 | 149 |
| 139 static void CreateScriptFileDetailValue( | 150 static void CreateScriptFileDetailValue( |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 AddMessageHandler(handler); | 269 AddMessageHandler(handler); |
| 259 handler->Attach(this); | 270 handler->Attach(this); |
| 260 | 271 |
| 261 ExtensionsUIHTMLSource* html_source = new ExtensionsUIHTMLSource(); | 272 ExtensionsUIHTMLSource* html_source = new ExtensionsUIHTMLSource(); |
| 262 | 273 |
| 263 // Set up the chrome://extensions/ source. | 274 // Set up the chrome://extensions/ source. |
| 264 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 275 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
| 265 NewRunnableMethod(&chrome_url_data_manager, | 276 NewRunnableMethod(&chrome_url_data_manager, |
| 266 &ChromeURLDataManager::AddDataSource, html_source)); | 277 &ChromeURLDataManager::AddDataSource, html_source)); |
| 267 } | 278 } |
| OLD | NEW |