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

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

Issue 9694038: OBSOLETE REVIEW. See http://codereview.chromium.org/10382149/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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/options/extension_settings_handler.h" 5 #include "chrome/browser/ui/webui/options/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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "base/version.h" 16 #include "base/version.h"
17 #include "chrome/browser/debugger/devtools_window.h" 17 #include "chrome/browser/debugger/devtools_window.h"
18 #include "chrome/browser/extensions/crx_installer.h" 18 #include "chrome/browser/extensions/crx_installer.h"
19 #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h" 19 #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h"
20 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/extensions/extension_updater.h" 21 #include "chrome/browser/extensions/extension_updater.h"
22 #include "chrome/browser/extensions/extension_warning_set.h" 22 #include "chrome/browser/extensions/extension_warning_set.h"
23 #include "chrome/browser/extensions/unpacked_installer.h" 23 #include "chrome/browser/extensions/unpacked_installer.h"
24 #include "chrome/browser/google/google_util.h" 24 #include "chrome/browser/google/google_util.h"
25 #include "chrome/browser/managed_mode.h"
25 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/tab_contents/background_contents.h" 27 #include "chrome/browser/tab_contents/background_contents.h"
27 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 28 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
28 #include "chrome/common/chrome_notification_types.h" 29 #include "chrome/common/chrome_notification_types.h"
29 #include "chrome/common/chrome_switches.h" 30 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/chrome_view_type.h" 31 #include "chrome/common/chrome_view_type.h"
31 #include "chrome/common/extensions/extension.h" 32 #include "chrome/common/extensions/extension.h"
32 #include "chrome/common/extensions/extension_icon_set.h" 33 #include "chrome/common/extensions/extension_icon_set.h"
33 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
34 #include "chrome/common/url_constants.h" 35 #include "chrome/common/url_constants.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 extensions_list->Append(CreateExtensionDetailValue( 192 extensions_list->Append(CreateExtensionDetailValue(
192 extension_service_, 193 extension_service_,
193 *extension, 194 *extension,
194 empty_pages, // Terminated process has no active pages. 195 empty_pages, // Terminated process has no active pages.
195 warnings, 196 warnings,
196 false, true)); // enabled, terminated 197 false, true)); // enabled, terminated
197 } 198 }
198 } 199 }
199 results.Set("extensions", extensions_list); 200 results.Set("extensions", extensions_list);
200 201
201 Profile* profile = Profile::FromWebUI(web_ui()); 202 if (ManagedMode::IsInManagedMode()) {
202 bool developer_mode = 203 results.SetBoolean("managedMode", true);
203 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode); 204 results.SetBoolean("developerMode", false);
204 results.SetBoolean("developerMode", developer_mode); 205 } else {
206 results.SetBoolean("managedMode", false);
207 Profile* profile = Profile::FromWebUI(web_ui());
208 bool developer_mode =
209 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode);
210 results.SetBoolean("developerMode", developer_mode);
211 }
205 212
206 web_ui()->CallJavascriptFunction("ExtensionSettings.returnExtensionsData", 213 web_ui()->CallJavascriptFunction("ExtensionSettings.returnExtensionsData",
207 results); 214 results);
208 215
209 MaybeRegisterForNotifications(); 216 MaybeRegisterForNotifications();
210 } 217 }
211 218
212 void ExtensionSettingsHandler::MaybeRegisterForNotifications() { 219 void ExtensionSettingsHandler::MaybeRegisterForNotifications() {
213 if (registered_for_notifications_) 220 if (registered_for_notifications_)
214 return; 221 return;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 ExtensionSettingsHandler::GetExtensionUninstallDialog() { 257 ExtensionSettingsHandler::GetExtensionUninstallDialog() {
251 if (!extension_uninstall_dialog_.get()) { 258 if (!extension_uninstall_dialog_.get()) {
252 extension_uninstall_dialog_.reset( 259 extension_uninstall_dialog_.reset(
253 ExtensionUninstallDialog::Create(Profile::FromWebUI(web_ui()), this)); 260 ExtensionUninstallDialog::Create(Profile::FromWebUI(web_ui()), this));
254 } 261 }
255 return extension_uninstall_dialog_.get(); 262 return extension_uninstall_dialog_.get();
256 } 263 }
257 264
258 void ExtensionSettingsHandler::HandleToggleDeveloperMode( 265 void ExtensionSettingsHandler::HandleToggleDeveloperMode(
259 const ListValue* args) { 266 const ListValue* args) {
267 if (ManagedMode::IsInManagedMode())
268 return;
Evan Stade 2012/03/13 21:02:07 nit: \n
260 Profile* profile = Profile::FromWebUI(web_ui()); 269 Profile* profile = Profile::FromWebUI(web_ui());
261 bool developer_mode = 270 bool developer_mode =
262 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode); 271 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode);
263 profile->GetPrefs()->SetBoolean( 272 profile->GetPrefs()->SetBoolean(
264 prefs::kExtensionsUIDeveloperMode, !developer_mode); 273 prefs::kExtensionsUIDeveloperMode, !developer_mode);
265 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableUberPage)) 274 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableUberPage))
266 HandleRequestExtensionsData(NULL); 275 HandleRequestExtensionsData(NULL);
267 } 276 }
268 277
269 void ExtensionSettingsHandler::HandleInspectMessage(const ListValue* args) { 278 void ExtensionSettingsHandler::HandleInspectMessage(const ListValue* args) {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 localized_strings->SetString("extensionSettingsIncognitoWarning", 564 localized_strings->SetString("extensionSettingsIncognitoWarning",
556 l10n_util::GetStringUTF16(IDS_EXTENSIONS_INCOGNITO_WARNING)); 565 l10n_util::GetStringUTF16(IDS_EXTENSIONS_INCOGNITO_WARNING));
557 localized_strings->SetString("extensionSettingsReload", 566 localized_strings->SetString("extensionSettingsReload",
558 l10n_util::GetStringUTF16(IDS_EXTENSIONS_RELOAD)); 567 l10n_util::GetStringUTF16(IDS_EXTENSIONS_RELOAD));
559 localized_strings->SetString("extensionSettingsOptions", 568 localized_strings->SetString("extensionSettingsOptions",
560 l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS_LINK)); 569 l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS_LINK));
561 localized_strings->SetString("extensionSettingsActivity", 570 localized_strings->SetString("extensionSettingsActivity",
562 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ACTIVITY_LINK)); 571 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ACTIVITY_LINK));
563 localized_strings->SetString("extensionSettingsPolicyControlled", 572 localized_strings->SetString("extensionSettingsPolicyControlled",
564 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_CONTROLLED)); 573 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_CONTROLLED));
574 localized_strings->SetString("extensionSettingsManagedMode",
575 l10n_util::GetStringUTF16(IDS_EXTENSIONS_MANAGED_MODE));
565 localized_strings->SetString("extensionSettingsShowButton", 576 localized_strings->SetString("extensionSettingsShowButton",
566 l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_BUTTON)); 577 l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_BUTTON));
567 localized_strings->SetString("extensionSettingsLoadUnpackedButton", 578 localized_strings->SetString("extensionSettingsLoadUnpackedButton",
568 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_UNPACKED_BUTTON)); 579 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_UNPACKED_BUTTON));
569 localized_strings->SetString("extensionSettingsPackButton", 580 localized_strings->SetString("extensionSettingsPackButton",
570 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PACK_BUTTON)); 581 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PACK_BUTTON));
571 localized_strings->SetString("extensionSettingsUpdateButton", 582 localized_strings->SetString("extensionSettingsUpdateButton",
572 l10n_util::GetStringUTF16(IDS_EXTENSIONS_UPDATE_BUTTON)); 583 l10n_util::GetStringUTF16(IDS_EXTENSIONS_UPDATE_BUTTON));
573 localized_strings->SetString("extensionSettingsCrashMessage", 584 localized_strings->SetString("extensionSettingsCrashMessage",
574 l10n_util::GetStringUTF16(IDS_EXTENSIONS_CRASHED_EXTENSION)); 585 l10n_util::GetStringUTF16(IDS_EXTENSIONS_CRASHED_EXTENSION));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 extension_data->SetString("id", extension->id()); 679 extension_data->SetString("id", extension->id());
669 extension_data->SetString("name", extension->name()); 680 extension_data->SetString("name", extension->name());
670 extension_data->SetString("description", extension->description()); 681 extension_data->SetString("description", extension->description());
671 if (extension->location() == Extension::LOAD) 682 if (extension->location() == Extension::LOAD)
672 extension_data->SetString("path", extension->path().value()); 683 extension_data->SetString("path", extension->path().value());
673 extension_data->SetString("version", extension->version()->GetString()); 684 extension_data->SetString("version", extension->version()->GetString());
674 extension_data->SetString("icon", icon.spec()); 685 extension_data->SetString("icon", icon.spec());
675 extension_data->SetBoolean("isUnpacked", 686 extension_data->SetBoolean("isUnpacked",
676 extension->location() == Extension::LOAD); 687 extension->location() == Extension::LOAD);
677 extension_data->SetBoolean("mayDisable", 688 extension_data->SetBoolean("mayDisable",
689 !ManagedMode::IsInManagedMode() &&
678 Extension::UserMayDisable(extension->location())); 690 Extension::UserMayDisable(extension->location()));
679 extension_data->SetBoolean("enabled", enabled); 691 extension_data->SetBoolean("enabled", enabled);
680 extension_data->SetBoolean("terminated", terminated); 692 extension_data->SetBoolean("terminated", terminated);
681 extension_data->SetBoolean("enabledIncognito", 693 extension_data->SetBoolean("enabledIncognito",
682 service ? service->IsIncognitoEnabled(extension->id()) : false); 694 service ? service->IsIncognitoEnabled(extension->id()) : false);
683 extension_data->SetBoolean("wantsFileAccess", extension->wants_file_access()); 695 extension_data->SetBoolean("wantsFileAccess", extension->wants_file_access());
684 extension_data->SetBoolean("allowFileAccess", 696 extension_data->SetBoolean("allowFileAccess",
685 service ? service->AllowFileAccess(extension) : false); 697 service ? service->AllowFileAccess(extension) : false);
686 extension_data->SetBoolean("allow_activity", 698 extension_data->SetBoolean("allow_activity",
687 enabled && CommandLine::ForCurrentProcess()->HasSwitch( 699 enabled && CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 chrome::VIEW_TYPE_EXTENSION_DIALOG == host_type) 793 chrome::VIEW_TYPE_EXTENSION_DIALOG == host_type)
782 continue; 794 continue;
783 795
784 GURL url = host->GetDelegate()->GetURL(); 796 GURL url = host->GetDelegate()->GetURL();
785 content::RenderProcessHost* process = host->GetProcess(); 797 content::RenderProcessHost* process = host->GetProcess();
786 result->push_back( 798 result->push_back(
787 ExtensionPage(url, process->GetID(), host->GetRoutingID(), 799 ExtensionPage(url, process->GetID(), host->GetRoutingID(),
788 process->GetBrowserContext()->IsOffTheRecord())); 800 process->GetBrowserContext()->IsOffTheRecord()));
789 } 801 }
790 } 802 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698