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 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/renderer_host/render_view_host.h" | 21 #include "chrome/browser/renderer_host/render_view_host.h" |
22 #include "chrome/browser/tab_contents/tab_contents.h" | 22 #include "chrome/browser/tab_contents/tab_contents.h" |
23 #include "chrome/browser/tab_contents/tab_contents_view.h" | 23 #include "chrome/browser/tab_contents/tab_contents_view.h" |
24 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
25 #include "chrome/common/extensions/extension_error_reporter.h" | 25 #include "chrome/common/extensions/extension_error_reporter.h" |
26 #include "chrome/common/extensions/user_script.h" | 26 #include "chrome/common/extensions/user_script.h" |
27 #include "chrome/common/extensions/url_pattern.h" | 27 #include "chrome/common/extensions/url_pattern.h" |
28 #include "chrome/common/jstemplate_builder.h" | 28 #include "chrome/common/jstemplate_builder.h" |
29 #include "chrome/common/notification_service.h" | 29 #include "chrome/common/notification_service.h" |
30 #include "chrome/common/notification_type.h" | 30 #include "chrome/common/notification_type.h" |
| 31 #include "chrome/common/pref_names.h" |
| 32 #include "chrome/common/pref_service.h" |
31 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
32 #include "net/base/net_util.h" | 34 #include "net/base/net_util.h" |
33 | 35 |
34 #include "grit/browser_resources.h" | 36 #include "grit/browser_resources.h" |
35 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
36 #include "grit/theme_resources.h" | 38 #include "grit/theme_resources.h" |
37 | 39 |
38 //////////////////////////////////////////////////////////////////////////////// | 40 //////////////////////////////////////////////////////////////////////////////// |
39 // | 41 // |
40 // ExtensionsHTMLSource | 42 // ExtensionsHTMLSource |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // | 83 // |
82 /////////////////////////////////////////////////////////////////////////////// | 84 /////////////////////////////////////////////////////////////////////////////// |
83 | 85 |
84 ExtensionsDOMHandler::ExtensionsDOMHandler(ExtensionsService* extension_service) | 86 ExtensionsDOMHandler::ExtensionsDOMHandler(ExtensionsService* extension_service) |
85 : extensions_service_(extension_service) { | 87 : extensions_service_(extension_service) { |
86 } | 88 } |
87 | 89 |
88 void ExtensionsDOMHandler::RegisterMessages() { | 90 void ExtensionsDOMHandler::RegisterMessages() { |
89 dom_ui_->RegisterMessageCallback("requestExtensionsData", | 91 dom_ui_->RegisterMessageCallback("requestExtensionsData", |
90 NewCallback(this, &ExtensionsDOMHandler::HandleRequestExtensionsData)); | 92 NewCallback(this, &ExtensionsDOMHandler::HandleRequestExtensionsData)); |
| 93 dom_ui_->RegisterMessageCallback("toggleDeveloperMode", |
| 94 NewCallback(this, &ExtensionsDOMHandler::HandleToggleDeveloperMode)); |
91 dom_ui_->RegisterMessageCallback("inspect", | 95 dom_ui_->RegisterMessageCallback("inspect", |
92 NewCallback(this, &ExtensionsDOMHandler::HandleInspectMessage)); | 96 NewCallback(this, &ExtensionsDOMHandler::HandleInspectMessage)); |
93 dom_ui_->RegisterMessageCallback("reload", | 97 dom_ui_->RegisterMessageCallback("reload", |
94 NewCallback(this, &ExtensionsDOMHandler::HandleReloadMessage)); | 98 NewCallback(this, &ExtensionsDOMHandler::HandleReloadMessage)); |
95 dom_ui_->RegisterMessageCallback("enable", | 99 dom_ui_->RegisterMessageCallback("enable", |
96 NewCallback(this, &ExtensionsDOMHandler::HandleEnableMessage)); | 100 NewCallback(this, &ExtensionsDOMHandler::HandleEnableMessage)); |
97 dom_ui_->RegisterMessageCallback("uninstall", | 101 dom_ui_->RegisterMessageCallback("uninstall", |
98 NewCallback(this, &ExtensionsDOMHandler::HandleUninstallMessage)); | 102 NewCallback(this, &ExtensionsDOMHandler::HandleUninstallMessage)); |
99 dom_ui_->RegisterMessageCallback("options", | 103 dom_ui_->RegisterMessageCallback("options", |
100 NewCallback(this, &ExtensionsDOMHandler::HandleOptionsMessage)); | 104 NewCallback(this, &ExtensionsDOMHandler::HandleOptionsMessage)); |
(...skipping 25 matching lines...) Expand all Loading... |
126 extensions = extensions_service_->disabled_extensions(); | 130 extensions = extensions_service_->disabled_extensions(); |
127 for (ExtensionList::const_iterator extension = extensions->begin(); | 131 for (ExtensionList::const_iterator extension = extensions->begin(); |
128 extension != extensions->end(); ++extension) { | 132 extension != extensions->end(); ++extension) { |
129 if (!(*extension)->IsTheme()) { | 133 if (!(*extension)->IsTheme()) { |
130 extensions_list->Append(CreateExtensionDetailValue( | 134 extensions_list->Append(CreateExtensionDetailValue( |
131 *extension, GetActivePagesForExtension((*extension)->id()), false)); | 135 *extension, GetActivePagesForExtension((*extension)->id()), false)); |
132 } | 136 } |
133 } | 137 } |
134 results.Set(L"extensions", extensions_list); | 138 results.Set(L"extensions", extensions_list); |
135 | 139 |
| 140 bool developer_mode = dom_ui_->GetProfile()->GetPrefs() |
| 141 ->GetBoolean(prefs::kExtensionsUIDeveloperMode); |
| 142 results.SetBoolean(L"developerMode", developer_mode); |
| 143 |
136 dom_ui_->CallJavascriptFunction(L"returnExtensionsData", results); | 144 dom_ui_->CallJavascriptFunction(L"returnExtensionsData", results); |
137 | 145 |
138 // Register for notifications that we need to reload the page. | 146 // Register for notifications that we need to reload the page. |
139 registrar_.RemoveAll(); | 147 registrar_.RemoveAll(); |
140 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 148 registrar_.Add(this, NotificationType::EXTENSION_LOADED, |
141 NotificationService::AllSources()); | 149 NotificationService::AllSources()); |
142 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, | 150 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, |
143 NotificationService::AllSources()); | 151 NotificationService::AllSources()); |
144 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, | 152 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, |
145 NotificationService::AllSources()); | 153 NotificationService::AllSources()); |
146 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED_DISABLED, | 154 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED_DISABLED, |
147 NotificationService::AllSources()); | 155 NotificationService::AllSources()); |
148 } | 156 } |
149 | 157 |
| 158 void ExtensionsDOMHandler::HandleToggleDeveloperMode(const Value* value) { |
| 159 bool developer_mode = dom_ui_->GetProfile()->GetPrefs() |
| 160 ->GetBoolean(prefs::kExtensionsUIDeveloperMode); |
| 161 dom_ui_->GetProfile()->GetPrefs()->SetBoolean( |
| 162 prefs::kExtensionsUIDeveloperMode, !developer_mode); |
| 163 } |
| 164 |
150 void ExtensionsDOMHandler::HandleInspectMessage(const Value* value) { | 165 void ExtensionsDOMHandler::HandleInspectMessage(const Value* value) { |
151 std::string render_process_id_str; | 166 std::string render_process_id_str; |
152 std::string render_view_id_str; | 167 std::string render_view_id_str; |
153 int render_process_id; | 168 int render_process_id; |
154 int render_view_id; | 169 int render_view_id; |
155 CHECK(value->IsType(Value::TYPE_LIST)); | 170 CHECK(value->IsType(Value::TYPE_LIST)); |
156 const ListValue* list = static_cast<const ListValue*>(value); | 171 const ListValue* list = static_cast<const ListValue*>(value); |
157 CHECK(list->GetSize() == 2); | 172 CHECK(list->GetSize() == 2); |
158 CHECK(list->GetString(0, &render_process_id_str)); | 173 CHECK(list->GetString(0, &render_process_id_str)); |
159 CHECK(list->GetString(1, &render_view_id_str)); | 174 CHECK(list->GetString(1, &render_view_id_str)); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 522 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
508 NewRunnableMethod(&chrome_url_data_manager, | 523 NewRunnableMethod(&chrome_url_data_manager, |
509 &ChromeURLDataManager::AddDataSource, html_source)); | 524 &ChromeURLDataManager::AddDataSource, html_source)); |
510 } | 525 } |
511 | 526 |
512 // static | 527 // static |
513 RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes() { | 528 RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes() { |
514 return ResourceBundle::GetSharedInstance(). | 529 return ResourceBundle::GetSharedInstance(). |
515 LoadImageResourceBytes(IDR_PLUGIN); | 530 LoadImageResourceBytes(IDR_PLUGIN); |
516 } | 531 } |
| 532 |
| 533 // static |
| 534 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { |
| 535 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, false); |
| 536 } |
OLD | NEW |