Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(530)

Side by Side Diff: chrome/browser/ui/webui/extensions/extension_settings_handler.cc

Issue 10407105: Improve error messaging of webRequest API in case of conflicts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/webui/extensions/extension_settings_handler.h" 5 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // static 99 // static
100 void ExtensionSettingsHandler::RegisterUserPrefs(PrefService* prefs) { 100 void ExtensionSettingsHandler::RegisterUserPrefs(PrefService* prefs) {
101 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, 101 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode,
102 false, 102 false,
103 PrefService::SYNCABLE_PREF); 103 PrefService::SYNCABLE_PREF);
104 } 104 }
105 105
106 DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue( 106 DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue(
107 const Extension* extension, 107 const Extension* extension,
108 const std::vector<ExtensionPage>& pages, 108 const std::vector<ExtensionPage>& pages,
109 const ExtensionWarningSet* warnings_set) { 109 const ExtensionWarningService* warnings_set) {
110 DictionaryValue* extension_data = new DictionaryValue(); 110 DictionaryValue* extension_data = new DictionaryValue();
111 bool enabled = extension_service_->IsExtensionEnabled(extension->id()); 111 bool enabled = extension_service_->IsExtensionEnabled(extension->id());
112 extension->GetBasicInfo(enabled, extension_data); 112 extension->GetBasicInfo(enabled, extension_data);
113 113
114 extension_data->SetBoolean("userModifiable", 114 extension_data->SetBoolean("userModifiable",
115 management_policy_->UserMayModifySettings(extension, NULL)); 115 management_policy_->UserMayModifySettings(extension, NULL));
116 116
117 GURL icon = 117 GURL icon =
118 ExtensionIconSource::GetIconURL(extension, 118 ExtensionIconSource::GetIconURL(extension,
119 extension_misc::EXTENSION_ICON_MEDIUM, 119 extension_misc::EXTENSION_ICON_MEDIUM,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 view_value->SetInteger("renderProcessId", iter->render_process_id); 168 view_value->SetInteger("renderProcessId", iter->render_process_id);
169 view_value->SetBoolean("incognito", iter->incognito); 169 view_value->SetBoolean("incognito", iter->incognito);
170 views->Append(view_value); 170 views->Append(view_value);
171 } 171 }
172 extension_data->Set("views", views); 172 extension_data->Set("views", views);
173 extension_data->SetBoolean("hasPopupAction", 173 extension_data->SetBoolean("hasPopupAction",
174 extension->browser_action() || extension->page_action()); 174 extension->browser_action() || extension->page_action());
175 175
176 // Add warnings. 176 // Add warnings.
177 if (warnings_set) { 177 if (warnings_set) {
178 std::set<ExtensionWarningSet::WarningType> warnings; 178 std::set<linked_ptr<ExtensionWarning> > warnings;
179 warnings_set->GetWarningsAffectingExtension(extension->id(), &warnings); 179 warnings_set->GetWarningsAffectingExtension(extension->id(), &warnings);
180 180
181 if (!warnings.empty()) { 181 if (!warnings.empty()) {
182 ListValue* warnings_list = new ListValue; 182 ListValue* warnings_list = new ListValue;
183 for (std::set<ExtensionWarningSet::WarningType>::const_iterator iter = 183 for (std::set<linked_ptr<ExtensionWarning> >::const_iterator iter =
184 warnings.begin(); 184 warnings.begin();
185 iter != warnings.end(); 185 iter != warnings.end();
186 ++iter) { 186 ++iter) {
187 string16 warning_string( 187 warnings_list->Append(
188 ExtensionWarningSet::GetLocalizedWarning(*iter)); 188 Value::CreateStringValue((*iter)->GetMessage(extension_service_)));
189 warnings_list->Append(Value::CreateStringValue(warning_string));
190 } 189 }
191 extension_data->Set("warnings", warnings_list); 190 extension_data->Set("warnings", warnings_list);
192 } 191 }
193 } 192 }
194 193
195 // Add install warnings (these are not the same as warnings!). 194 // Add install warnings (these are not the same as warnings!).
196 if (extension->location() == Extension::LOAD) { 195 if (extension->location() == Extension::LOAD) {
197 const Extension::InstallWarningVector& install_warnings = 196 const Extension::InstallWarningVector& install_warnings =
198 extension->install_warnings(); 197 extension->install_warnings();
199 if (!install_warnings.empty()) { 198 if (!install_warnings.empty()) {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } 466 }
468 } 467 }
469 468
470 void ExtensionSettingsHandler::HandleRequestExtensionsData( 469 void ExtensionSettingsHandler::HandleRequestExtensionsData(
471 const ListValue* args) { 470 const ListValue* args) {
472 DictionaryValue results; 471 DictionaryValue results;
473 472
474 // Add the extensions to the results structure. 473 // Add the extensions to the results structure.
475 ListValue *extensions_list = new ListValue(); 474 ListValue *extensions_list = new ListValue();
476 475
477 ExtensionWarningSet* warnings = extension_service_->extension_warnings(); 476 ExtensionWarningService* warnings = extension_service_->extension_warnings();
478 477
479 const ExtensionSet* extensions = extension_service_->extensions(); 478 const ExtensionSet* extensions = extension_service_->extensions();
480 for (ExtensionSet::const_iterator extension = extensions->begin(); 479 for (ExtensionSet::const_iterator extension = extensions->begin();
481 extension != extensions->end(); ++extension) { 480 extension != extensions->end(); ++extension) {
482 if ((*extension)->ShouldDisplayInExtensionSettings()) { 481 if ((*extension)->ShouldDisplayInExtensionSettings()) {
483 extensions_list->Append(CreateExtensionDetailValue( 482 extensions_list->Append(CreateExtensionDetailValue(
484 *extension, 483 *extension,
485 GetInspectablePagesForExtension(*extension, true), 484 GetInspectablePagesForExtension(*extension, true),
486 warnings)); 485 warnings));
487 } 486 }
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 #else 879 #else
881 return NULL; 880 return NULL;
882 #endif // !defined(OS_ANDROID) 881 #endif // !defined(OS_ANDROID)
883 } 882 }
884 883
885 void ExtensionSettingsHandler::InspectExtensionHost( 884 void ExtensionSettingsHandler::InspectExtensionHost(
886 extensions::ExtensionHost* host) { 885 extensions::ExtensionHost* host) {
887 if (host) 886 if (host)
888 DevToolsWindow::OpenDevToolsWindow(host->render_view_host()); 887 DevToolsWindow::OpenDevToolsWindow(host->render_view_host());
889 } 888 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698