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

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

Issue 11189094: Implement sideload wipeout for Extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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 27 matching lines...) Expand all
38 #include "chrome/browser/ui/chrome_select_file_policy.h" 38 #include "chrome/browser/ui/chrome_select_file_policy.h"
39 #include "chrome/browser/ui/extensions/shell_window.h" 39 #include "chrome/browser/ui/extensions/shell_window.h"
40 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 40 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
41 #include "chrome/browser/view_type_utils.h" 41 #include "chrome/browser/view_type_utils.h"
42 #include "chrome/common/chrome_notification_types.h" 42 #include "chrome/common/chrome_notification_types.h"
43 #include "chrome/common/chrome_switches.h" 43 #include "chrome/common/chrome_switches.h"
44 #include "chrome/common/extensions/extension.h" 44 #include "chrome/common/extensions/extension.h"
45 #include "chrome/common/extensions/extension_constants.h" 45 #include "chrome/common/extensions/extension_constants.h"
46 #include "chrome/common/extensions/extension_icon_set.h" 46 #include "chrome/common/extensions/extension_icon_set.h"
47 #include "chrome/common/extensions/extension_set.h" 47 #include "chrome/common/extensions/extension_set.h"
48 #include "chrome/common/extensions/feature_switch.h"
48 #include "chrome/common/pref_names.h" 49 #include "chrome/common/pref_names.h"
49 #include "chrome/common/url_constants.h" 50 #include "chrome/common/url_constants.h"
50 #include "content/public/browser/notification_service.h" 51 #include "content/public/browser/notification_service.h"
51 #include "content/public/browser/notification_source.h" 52 #include "content/public/browser/notification_source.h"
52 #include "content/public/browser/notification_types.h" 53 #include "content/public/browser/notification_types.h"
53 #include "content/public/browser/render_process_host.h" 54 #include "content/public/browser/render_process_host.h"
54 #include "content/public/browser/render_view_host.h" 55 #include "content/public/browser/render_view_host.h"
55 #include "content/public/browser/site_instance.h" 56 #include "content/public/browser/site_instance.h"
56 #include "content/public/browser/web_contents.h" 57 #include "content/public/browser/web_contents.h"
57 #include "content/public/browser/web_contents_view.h" 58 #include "content/public/browser/web_contents_view.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 extension_data->SetBoolean("allowFileAccess", 138 extension_data->SetBoolean("allowFileAccess",
138 extension_service_->AllowFileAccess(extension)); 139 extension_service_->AllowFileAccess(extension));
139 extension_data->SetBoolean("allow_activity", 140 extension_data->SetBoolean("allow_activity",
140 enabled && CommandLine::ForCurrentProcess()->HasSwitch( 141 enabled && CommandLine::ForCurrentProcess()->HasSwitch(
141 switches::kEnableExtensionActivityUI)); 142 switches::kEnableExtensionActivityUI));
142 extension_data->SetBoolean("allow_reload", 143 extension_data->SetBoolean("allow_reload",
143 extension->location() == Extension::LOAD); 144 extension->location() == Extension::LOAD);
144 extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app()); 145 extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app());
145 extension_data->SetBoolean("homepageProvided", 146 extension_data->SetBoolean("homepageProvided",
146 extension->GetHomepageURL().is_valid()); 147 extension->GetHomepageURL().is_valid());
148 string16 automatically_disabled_text;
149 int disable_reasons =
150 extension_service_->extension_prefs()->GetDisableReasons(extension->id());
151 if ((disable_reasons & Extension::DISABLE_SIDELOAD_WIPEOUT) != 0) {
152 automatically_disabled_text = l10n_util::GetStringUTF16(
153 IDS_OPTIONS_SIDELOAD_WIPEOUT_AUTOMATIC_DISABLE);
154 }
155 extension_data->SetString("disableReason", automatically_disabled_text);
156
157 string16 location_text;
158 if (extension->location() == Extension::INTERNAL &&
159 !extension->from_webstore()) {
160 location_text = l10n_util::GetStringUTF16(
161 IDS_OPTIONS_SIDELOAD_WIPEOUT_DISABLE_REASON_UNKNOWN);
162 } else if (extension->location() == Extension::EXTERNAL_REGISTRY) {
163 location_text = l10n_util::GetStringUTF16(
164 IDS_OPTIONS_SIDELOAD_WIPEOUT_DISABLE_REASON_3RD_PARTY);
165 }
166 extension_data->SetString("locationText", location_text);
147 167
148 // Determine the sort order: Extensions loaded through --load-extensions show 168 // Determine the sort order: Extensions loaded through --load-extensions show
149 // up at the top. Disabled extensions show up at the bottom. 169 // up at the top. Disabled extensions show up at the bottom.
150 if (extension->location() == Extension::LOAD) 170 if (extension->location() == Extension::LOAD)
151 extension_data->SetInteger("order", 1); 171 extension_data->SetInteger("order", 1);
152 else 172 else
153 extension_data->SetInteger("order", 2); 173 extension_data->SetInteger("order", 2);
154 174
155 if (!extension_service_->extension_prefs()-> 175 if (!extension_service_->extension_prefs()->
156 GetBrowserActionVisibility(extension)) { 176 GetBrowserActionVisibility(extension)) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 localized_strings->SetString("extensionSettingsActivity", 297 localized_strings->SetString("extensionSettingsActivity",
278 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ACTIVITY_LINK)); 298 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ACTIVITY_LINK));
279 localized_strings->SetString("extensionSettingsVisitWebsite", 299 localized_strings->SetString("extensionSettingsVisitWebsite",
280 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE)); 300 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE));
281 localized_strings->SetString("extensionSettingsVisitWebStore", 301 localized_strings->SetString("extensionSettingsVisitWebStore",
282 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSTORE)); 302 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSTORE));
283 localized_strings->SetString("extensionSettingsPolicyControlled", 303 localized_strings->SetString("extensionSettingsPolicyControlled",
284 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_CONTROLLED)); 304 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_CONTROLLED));
285 localized_strings->SetString("extensionSettingsManagedMode", 305 localized_strings->SetString("extensionSettingsManagedMode",
286 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOCKED_MANAGED_MODE)); 306 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOCKED_MANAGED_MODE));
307 localized_strings->SetString("extensionSettingsSideloadWipeout",
308 l10n_util::GetStringUTF16(IDS_OPTIONS_SIDELOAD_WIPEOUT_BANNER));
309 localized_strings->SetString("sideloadWipeoutUrl",
310 chrome::kSideloadWipeoutHelpURL);
311 localized_strings->SetString("sideloadWipoutLearnMore",
312 l10n_util::GetStringUTF16(IDS_LEARN_MORE));
287 localized_strings->SetString("extensionSettingsShowButton", 313 localized_strings->SetString("extensionSettingsShowButton",
288 l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_BUTTON)); 314 l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_BUTTON));
289 localized_strings->SetString("extensionSettingsLoadUnpackedButton", 315 localized_strings->SetString("extensionSettingsLoadUnpackedButton",
290 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_UNPACKED_BUTTON)); 316 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_UNPACKED_BUTTON));
291 localized_strings->SetString("extensionSettingsPackButton", 317 localized_strings->SetString("extensionSettingsPackButton",
292 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PACK_BUTTON)); 318 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PACK_BUTTON));
293 localized_strings->SetString("extensionSettingsCommandsLink", 319 localized_strings->SetString("extensionSettingsCommandsLink",
294 l10n_util::GetStringUTF16(IDS_EXTENSIONS_COMMANDS_CONFIGURE)); 320 l10n_util::GetStringUTF16(IDS_EXTENSIONS_COMMANDS_CONFIGURE));
295 localized_strings->SetString("extensionSettingsUpdateButton", 321 localized_strings->SetString("extensionSettingsUpdateButton",
296 l10n_util::GetStringUTF16(IDS_EXTENSIONS_UPDATE_BUTTON)); 322 l10n_util::GetStringUTF16(IDS_EXTENSIONS_UPDATE_BUTTON));
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 warnings)); 542 warnings));
517 } 543 }
518 } 544 }
519 results.Set("extensions", extensions_list); 545 results.Set("extensions", extensions_list);
520 546
521 if (ManagedMode::IsInManagedMode()) { 547 if (ManagedMode::IsInManagedMode()) {
522 results.SetBoolean("managedMode", true); 548 results.SetBoolean("managedMode", true);
523 results.SetBoolean("developerMode", false); 549 results.SetBoolean("developerMode", false);
524 } else { 550 } else {
525 results.SetBoolean("managedMode", false); 551 results.SetBoolean("managedMode", false);
552 Profile* profile = Profile::FromWebUI(web_ui());
553 bool developer_mode =
554 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode);
555 results.SetBoolean("developerMode", developer_mode);
556 }
557
558 // Check to see if we have any wiped out extensions.
526 Profile* profile = Profile::FromWebUI(web_ui()); 559 Profile* profile = Profile::FromWebUI(web_ui());
527 bool developer_mode = 560 ExtensionService* extension_service =
528 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode); 561 extensions::ExtensionSystem::Get(profile)->extension_service();
529 results.SetBoolean("developerMode", developer_mode); 562 scoped_ptr<const ExtensionSet> wiped_out(
530 } 563 extension_service->GenerateSideloadWipoutExtensionsSet());
564 bool show_sideload_wipeout_extension_banner =
565 extensions::FeatureSwitch::sideload_wipeout()->IsEnabled() &&
566 (wiped_out->size() > 0);
567 results.SetBoolean("showDisabledExtensionsWarning",
568 show_sideload_wipeout_extension_banner);
531 569
532 bool load_unpacked_disabled = 570 bool load_unpacked_disabled =
533 extension_service_->extension_prefs()->ExtensionsBlacklistedByDefault(); 571 extension_service_->extension_prefs()->ExtensionsBlacklistedByDefault();
534 results.SetBoolean("loadUnpackedDisabled", load_unpacked_disabled); 572 results.SetBoolean("loadUnpackedDisabled", load_unpacked_disabled);
535 573
536 web_ui()->CallJavascriptFunction("ExtensionSettings.returnExtensionsData", 574 web_ui()->CallJavascriptFunction("ExtensionSettings.returnExtensionsData",
537 results); 575 results);
538 content::WebContentsObserver::Observe(web_ui()->GetWebContents()); 576 content::WebContentsObserver::Observe(web_ui()->GetWebContents());
539 577
540 MaybeRegisterForNotifications(); 578 MaybeRegisterForNotifications();
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 std::vector<std::string> requirement_errors) { 962 std::vector<std::string> requirement_errors) {
925 if (requirement_errors.empty()) { 963 if (requirement_errors.empty()) {
926 extension_service_->EnableExtension(extension_id); 964 extension_service_->EnableExtension(extension_id);
927 } else { 965 } else {
928 ExtensionErrorReporter::GetInstance()->ReportError( 966 ExtensionErrorReporter::GetInstance()->ReportError(
929 UTF8ToUTF16(JoinString(requirement_errors, ' ')), 967 UTF8ToUTF16(JoinString(requirement_errors, ' ')),
930 true /* be noisy */); 968 true /* be noisy */);
931 } 969 }
932 requirements_checker_.reset(); 970 requirements_checker_.reset();
933 } 971 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698