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

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
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
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());
147 148
149 string16 automatically_disabled_text;
150 int disable_reasons =
151 extension_service_->extension_prefs()->GetDisableReasons(extension->id());
152 if ((disable_reasons & Extension::DISABLE_SIDELOAD_WIPEOUT) != 0) {
153 automatically_disabled_text = l10n_util::GetStringUTF16(
154 IDS_OPTIONS_SIDELOAD_WIPEOUT_AUTOMATIC_DISABLE);
155 }
156 extension_data->SetString("disableReason", automatically_disabled_text);
157
158 string16 location_text;
159 if (extension->location() == Extension::INTERNAL &&
160 !extension->from_webstore()) {
161 location_text = l10n_util::GetStringUTF16(
162 IDS_OPTIONS_SIDELOAD_WIPEOUT_DISABLE_REASON_UNKNOWN);
163 } else if (extension->location() == Extension::EXTERNAL_REGISTRY) {
164 location_text = l10n_util::GetStringUTF16(
165 IDS_OPTIONS_SIDELOAD_WIPEOUT_DISABLE_REASON_3RD_PARTY);
166 }
167 extension_data->SetString("locationText", location_text);
168
148 // Determine the sort order: Extensions loaded through --load-extensions show 169 // Determine the sort order: Extensions loaded through --load-extensions show
149 // up at the top. Disabled extensions show up at the bottom. 170 // up at the top. Disabled extensions show up at the bottom.
150 if (extension->location() == Extension::LOAD) 171 if (extension->location() == Extension::LOAD)
151 extension_data->SetInteger("order", 1); 172 extension_data->SetInteger("order", 1);
152 else 173 else
153 extension_data->SetInteger("order", 2); 174 extension_data->SetInteger("order", 2);
154 175
155 if (!extension_service_->extension_prefs()-> 176 if (!extension_service_->extension_prefs()->
156 GetBrowserActionVisibility(extension)) { 177 GetBrowserActionVisibility(extension)) {
157 extension_data->SetBoolean("enable_show_button", true); 178 extension_data->SetBoolean("enable_show_button", true);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 localized_strings->SetString("extensionSettingsActivity", 298 localized_strings->SetString("extensionSettingsActivity",
278 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ACTIVITY_LINK)); 299 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ACTIVITY_LINK));
279 localized_strings->SetString("extensionSettingsVisitWebsite", 300 localized_strings->SetString("extensionSettingsVisitWebsite",
280 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE)); 301 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE));
281 localized_strings->SetString("extensionSettingsVisitWebStore", 302 localized_strings->SetString("extensionSettingsVisitWebStore",
282 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSTORE)); 303 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSTORE));
283 localized_strings->SetString("extensionSettingsPolicyControlled", 304 localized_strings->SetString("extensionSettingsPolicyControlled",
284 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_CONTROLLED)); 305 l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_CONTROLLED));
285 localized_strings->SetString("extensionSettingsManagedMode", 306 localized_strings->SetString("extensionSettingsManagedMode",
286 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOCKED_MANAGED_MODE)); 307 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOCKED_MANAGED_MODE));
308 localized_strings->SetString("extensionSettingsSideloadWipeout",
309 l10n_util::GetStringUTF16(IDS_OPTIONS_SIDELOAD_WIPEOUT_BANNER));
310 localized_strings->SetString("sideloadWipeoutUrl",
311 chrome::kSideloadWipeoutHelpURL);
312 localized_strings->SetString("sideloadWipoutLearnMore",
313 l10n_util::GetStringUTF16(IDS_LEARN_MORE));
287 localized_strings->SetString("extensionSettingsShowButton", 314 localized_strings->SetString("extensionSettingsShowButton",
288 l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_BUTTON)); 315 l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_BUTTON));
289 localized_strings->SetString("extensionSettingsLoadUnpackedButton", 316 localized_strings->SetString("extensionSettingsLoadUnpackedButton",
290 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_UNPACKED_BUTTON)); 317 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_UNPACKED_BUTTON));
291 localized_strings->SetString("extensionSettingsPackButton", 318 localized_strings->SetString("extensionSettingsPackButton",
292 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PACK_BUTTON)); 319 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PACK_BUTTON));
293 localized_strings->SetString("extensionSettingsCommandsLink", 320 localized_strings->SetString("extensionSettingsCommandsLink",
294 l10n_util::GetStringUTF16(IDS_EXTENSIONS_COMMANDS_CONFIGURE)); 321 l10n_util::GetStringUTF16(IDS_EXTENSIONS_COMMANDS_CONFIGURE));
295 localized_strings->SetString("extensionSettingsUpdateButton", 322 localized_strings->SetString("extensionSettingsUpdateButton",
296 l10n_util::GetStringUTF16(IDS_EXTENSIONS_UPDATE_BUTTON)); 323 l10n_util::GetStringUTF16(IDS_EXTENSIONS_UPDATE_BUTTON));
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 warnings)); 543 warnings));
517 } 544 }
518 } 545 }
519 results.Set("extensions", extensions_list); 546 results.Set("extensions", extensions_list);
520 547
521 if (ManagedMode::IsInManagedMode()) { 548 if (ManagedMode::IsInManagedMode()) {
522 results.SetBoolean("managedMode", true); 549 results.SetBoolean("managedMode", true);
523 results.SetBoolean("developerMode", false); 550 results.SetBoolean("developerMode", false);
524 } else { 551 } else {
525 results.SetBoolean("managedMode", false); 552 results.SetBoolean("managedMode", false);
553 Profile* profile = Profile::FromWebUI(web_ui());
554 bool developer_mode =
555 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode);
556 results.SetBoolean("developerMode", developer_mode);
557 }
558
559 // Check to see if we have any wiped out extensions.
526 Profile* profile = Profile::FromWebUI(web_ui()); 560 Profile* profile = Profile::FromWebUI(web_ui());
527 bool developer_mode = 561 ExtensionService* extension_service =
528 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode); 562 extensions::ExtensionSystem::Get(profile)->extension_service();
529 results.SetBoolean("developerMode", developer_mode); 563 scoped_ptr<const ExtensionSet> wiped_out(
530 } 564 extension_service->GetWipedOutExtensions());
565 results.SetBoolean("showDisabledExtensionsWarning", wiped_out->size() > 0);
531 566
532 bool load_unpacked_disabled = 567 bool load_unpacked_disabled =
533 extension_service_->extension_prefs()->ExtensionsBlacklistedByDefault(); 568 extension_service_->extension_prefs()->ExtensionsBlacklistedByDefault();
534 results.SetBoolean("loadUnpackedDisabled", load_unpacked_disabled); 569 results.SetBoolean("loadUnpackedDisabled", load_unpacked_disabled);
535 570
536 web_ui()->CallJavascriptFunction("ExtensionSettings.returnExtensionsData", 571 web_ui()->CallJavascriptFunction("ExtensionSettings.returnExtensionsData",
537 results); 572 results);
538 content::WebContentsObserver::Observe(web_ui()->GetWebContents()); 573 content::WebContentsObserver::Observe(web_ui()->GetWebContents());
539 574
540 MaybeRegisterForNotifications(); 575 MaybeRegisterForNotifications();
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 std::vector<std::string> requirement_errors) { 959 std::vector<std::string> requirement_errors) {
925 if (requirement_errors.empty()) { 960 if (requirement_errors.empty()) {
926 extension_service_->EnableExtension(extension_id); 961 extension_service_->EnableExtension(extension_id);
927 } else { 962 } else {
928 ExtensionErrorReporter::GetInstance()->ReportError( 963 ExtensionErrorReporter::GetInstance()->ReportError(
929 UTF8ToUTF16(JoinString(requirement_errors, ' ')), 964 UTF8ToUTF16(JoinString(requirement_errors, ' ')),
930 true /* be noisy */); 965 true /* be noisy */);
931 } 966 }
932 requirements_checker_.reset(); 967 requirements_checker_.reset();
933 } 968 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698