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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 if (!(*extension)->IsTheme()) { | 114 if (!(*extension)->IsTheme()) { |
115 extensions_list->Append(CreateExtensionDetailValue( | 115 extensions_list->Append(CreateExtensionDetailValue( |
116 *extension, GetActivePagesForExtension((*extension)->id()), false)); | 116 *extension, GetActivePagesForExtension((*extension)->id()), false)); |
117 } | 117 } |
118 } | 118 } |
119 results.Set(L"extensions", extensions_list); | 119 results.Set(L"extensions", extensions_list); |
120 | 120 |
121 dom_ui_->CallJavascriptFunction(L"returnExtensionsData", results); | 121 dom_ui_->CallJavascriptFunction(L"returnExtensionsData", results); |
122 | 122 |
123 // Register for notifications that we need to reload the page. | 123 // Register for notifications that we need to reload the page. |
| 124 registrar_.RemoveAll(); |
124 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 125 registrar_.Add(this, NotificationType::EXTENSION_LOADED, |
125 NotificationService::AllSources()); | 126 NotificationService::AllSources()); |
126 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, | 127 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, |
127 NotificationService::AllSources()); | 128 NotificationService::AllSources()); |
128 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, | 129 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, |
129 NotificationService::AllSources()); | 130 NotificationService::AllSources()); |
130 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED_DISABLED, | 131 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED_DISABLED, |
131 NotificationService::AllSources()); | 132 NotificationService::AllSources()); |
132 } | 133 } |
133 | 134 |
(...skipping 24 matching lines...) Expand all Loading... |
158 const ListValue* list = static_cast<const ListValue*>(value); | 159 const ListValue* list = static_cast<const ListValue*>(value); |
159 CHECK(list->GetSize() == 1); | 160 CHECK(list->GetSize() == 1); |
160 std::string extension_id; | 161 std::string extension_id; |
161 CHECK(list->GetString(0, &extension_id)); | 162 CHECK(list->GetString(0, &extension_id)); |
162 extensions_service_->ReloadExtension(extension_id); | 163 extensions_service_->ReloadExtension(extension_id); |
163 } | 164 } |
164 | 165 |
165 void ExtensionsDOMHandler::HandleEnableMessage(const Value* value) { | 166 void ExtensionsDOMHandler::HandleEnableMessage(const Value* value) { |
166 CHECK(value->IsType(Value::TYPE_LIST)); | 167 CHECK(value->IsType(Value::TYPE_LIST)); |
167 const ListValue* list = static_cast<const ListValue*>(value); | 168 const ListValue* list = static_cast<const ListValue*>(value); |
168 CHECK(list->GetSize() == 1); | 169 CHECK(list->GetSize() == 2); |
169 std::string extension_id; | 170 std::string extension_id, enable_str; |
170 CHECK(list->GetString(0, &extension_id)); | 171 CHECK(list->GetString(0, &extension_id)); |
171 extensions_service_->EnableExtension(extension_id); | 172 CHECK(list->GetString(1, &enable_str)); |
| 173 if (enable_str == "true") { |
| 174 extensions_service_->EnableExtension(extension_id); |
| 175 } else { |
| 176 extensions_service_->DisableExtension(extension_id); |
| 177 } |
172 } | 178 } |
173 | 179 |
174 void ExtensionsDOMHandler::HandleUninstallMessage(const Value* value) { | 180 void ExtensionsDOMHandler::HandleUninstallMessage(const Value* value) { |
175 CHECK(value->IsType(Value::TYPE_LIST)); | 181 CHECK(value->IsType(Value::TYPE_LIST)); |
176 const ListValue* list = static_cast<const ListValue*>(value); | 182 const ListValue* list = static_cast<const ListValue*>(value); |
177 CHECK(list->GetSize() == 1); | 183 CHECK(list->GetSize() == 1); |
178 std::string extension_id; | 184 std::string extension_id; |
179 CHECK(list->GetString(0, &extension_id)); | 185 CHECK(list->GetString(0, &extension_id)); |
180 extensions_service_->UninstallExtension(extension_id, false); | 186 extensions_service_->UninstallExtension(extension_id, false); |
181 } | 187 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 AddMessageHandler(handler); | 355 AddMessageHandler(handler); |
350 handler->Attach(this); | 356 handler->Attach(this); |
351 | 357 |
352 ExtensionsUIHTMLSource* html_source = new ExtensionsUIHTMLSource(); | 358 ExtensionsUIHTMLSource* html_source = new ExtensionsUIHTMLSource(); |
353 | 359 |
354 // Set up the chrome://extensions/ source. | 360 // Set up the chrome://extensions/ source. |
355 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 361 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
356 NewRunnableMethod(&chrome_url_data_manager, | 362 NewRunnableMethod(&chrome_url_data_manager, |
357 &ChromeURLDataManager::AddDataSource, html_source)); | 363 &ChromeURLDataManager::AddDataSource, html_source)); |
358 } | 364 } |
OLD | NEW |