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

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

Issue 156843004: Remove ExtensionService::extension_prefs() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: additional cleanup Created 6 years, 10 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 "apps/app_load_service.h" 7 #include "apps/app_load_service.h"
8 #include "apps/app_restore_service.h" 8 #include "apps/app_restore_service.h"
9 #include "apps/saved_files_service.h" 9 #include "apps/saved_files_service.h"
10 #include "apps/shell_window.h" 10 #include "apps/shell_window.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 191 }
192 192
193 base::DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue( 193 base::DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue(
194 const Extension* extension, 194 const Extension* extension,
195 const std::vector<ExtensionPage>& pages, 195 const std::vector<ExtensionPage>& pages,
196 const ExtensionWarningService* warning_service) { 196 const ExtensionWarningService* warning_service) {
197 base::DictionaryValue* extension_data = new base::DictionaryValue(); 197 base::DictionaryValue* extension_data = new base::DictionaryValue();
198 bool enabled = extension_service_->IsExtensionEnabled(extension->id()); 198 bool enabled = extension_service_->IsExtensionEnabled(extension->id());
199 GetExtensionBasicInfo(extension, enabled, extension_data); 199 GetExtensionBasicInfo(extension, enabled, extension_data);
200 200
201 ExtensionPrefs* prefs = extension_service_->extension_prefs(); 201 ExtensionPrefs* prefs = ExtensionPrefs::Get(extension_service_->profile());
202 int disable_reasons = prefs->GetDisableReasons(extension->id()); 202 int disable_reasons = prefs->GetDisableReasons(extension->id());
203 203
204 bool suspicious_install = 204 bool suspicious_install =
205 (disable_reasons & Extension::DISABLE_NOT_VERIFIED) != 0; 205 (disable_reasons & Extension::DISABLE_NOT_VERIFIED) != 0;
206 extension_data->SetBoolean("suspiciousInstall", suspicious_install); 206 extension_data->SetBoolean("suspiciousInstall", suspicious_install);
207 if (suspicious_install) 207 if (suspicious_install)
208 should_do_verification_check_ = true; 208 should_do_verification_check_ = true;
209 209
210 bool managed_install = 210 bool managed_install =
211 !management_policy_->UserMayModifySettings(extension, NULL); 211 !management_policy_->UserMayModifySettings(extension, NULL);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 !ManifestURL::UpdatesFromGallery(extension)) { 252 !ManifestURL::UpdatesFromGallery(extension)) {
253 location_text = l10n_util::GetStringUTF16( 253 location_text = l10n_util::GetStringUTF16(
254 IDS_OPTIONS_INSTALL_LOCATION_UNKNOWN); 254 IDS_OPTIONS_INSTALL_LOCATION_UNKNOWN);
255 } else if (extension->location() == Manifest::EXTERNAL_REGISTRY) { 255 } else if (extension->location() == Manifest::EXTERNAL_REGISTRY) {
256 location_text = l10n_util::GetStringUTF16( 256 location_text = l10n_util::GetStringUTF16(
257 IDS_OPTIONS_INSTALL_LOCATION_3RD_PARTY); 257 IDS_OPTIONS_INSTALL_LOCATION_3RD_PARTY);
258 } 258 }
259 extension_data->SetString("locationText", location_text); 259 extension_data->SetString("locationText", location_text);
260 260
261 base::string16 blacklist_text; 261 base::string16 blacklist_text;
262 switch (extension_service_->extension_prefs()->GetExtensionBlacklistState( 262 switch (prefs->GetExtensionBlacklistState(extension->id())) {
263 extension->id())) {
264 case BLACKLISTED_SECURITY_VULNERABILITY: 263 case BLACKLISTED_SECURITY_VULNERABILITY:
265 blacklist_text = l10n_util::GetStringUTF16( 264 blacklist_text = l10n_util::GetStringUTF16(
266 IDS_OPTIONS_BLACKLISTED_SECURITY_VULNERABILITY); 265 IDS_OPTIONS_BLACKLISTED_SECURITY_VULNERABILITY);
267 break; 266 break;
268 267
269 case BLACKLISTED_CWS_POLICY_VIOLATION: 268 case BLACKLISTED_CWS_POLICY_VIOLATION:
270 blacklist_text = l10n_util::GetStringUTF16( 269 blacklist_text = l10n_util::GetStringUTF16(
271 IDS_OPTIONS_BLACKLISTED_CWS_POLICY_VIOLATION); 270 IDS_OPTIONS_BLACKLISTED_CWS_POLICY_VIOLATION);
272 break; 271 break;
273 272
274 case BLACKLISTED_POTENTIALLY_UNWANTED: 273 case BLACKLISTED_POTENTIALLY_UNWANTED:
275 blacklist_text = l10n_util::GetStringUTF16( 274 blacklist_text = l10n_util::GetStringUTF16(
276 IDS_OPTIONS_BLACKLISTED_POTENTIALLY_UNWANTED); 275 IDS_OPTIONS_BLACKLISTED_POTENTIALLY_UNWANTED);
277 break; 276 break;
278 277
279 default: 278 default:
280 break; 279 break;
281 } 280 }
282 extension_data->SetString("blacklistText", blacklist_text); 281 extension_data->SetString("blacklistText", blacklist_text);
283 282
284 // Force unpacked extensions to show at the top. 283 // Force unpacked extensions to show at the top.
285 if (Manifest::IsUnpackedLocation(extension->location())) 284 if (Manifest::IsUnpackedLocation(extension->location()))
286 extension_data->SetInteger("order", 1); 285 extension_data->SetInteger("order", 1);
287 else 286 else
288 extension_data->SetInteger("order", 2); 287 extension_data->SetInteger("order", 2);
289 288
290 if (!ExtensionActionAPI::GetBrowserActionVisibility( 289 if (!ExtensionActionAPI::GetBrowserActionVisibility(prefs, extension->id())) {
291 extension_service_->extension_prefs(), extension->id())) {
292 extension_data->SetBoolean("enable_show_button", true); 290 extension_data->SetBoolean("enable_show_button", true);
293 } 291 }
294 292
295 // Add views 293 // Add views
296 base::ListValue* views = new base::ListValue; 294 base::ListValue* views = new base::ListValue;
297 for (std::vector<ExtensionPage>::const_iterator iter = pages.begin(); 295 for (std::vector<ExtensionPage>::const_iterator iter = pages.begin();
298 iter != pages.end(); ++iter) { 296 iter != pages.end(); ++iter) {
299 base::DictionaryValue* view_value = new base::DictionaryValue; 297 base::DictionaryValue* view_value = new base::DictionaryValue;
300 if (iter->url.scheme() == kExtensionScheme) { 298 if (iter->url.scheme() == kExtensionScheme) {
301 // No leading slash. 299 // No leading slash.
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 results.Set("extensions", extensions_list); 743 results.Set("extensions", extensions_list);
746 744
747 bool is_managed = profile->IsManaged(); 745 bool is_managed = profile->IsManaged();
748 bool developer_mode = 746 bool developer_mode =
749 !is_managed && 747 !is_managed &&
750 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode); 748 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode);
751 results.SetBoolean("profileIsManaged", is_managed); 749 results.SetBoolean("profileIsManaged", is_managed);
752 results.SetBoolean("developerMode", developer_mode); 750 results.SetBoolean("developerMode", developer_mode);
753 751
754 bool load_unpacked_disabled = 752 bool load_unpacked_disabled =
755 extension_service_->extension_prefs()->ExtensionsBlacklistedByDefault(); 753 ExtensionPrefs::Get(profile)->ExtensionsBlacklistedByDefault();
756 results.SetBoolean("loadUnpackedDisabled", load_unpacked_disabled); 754 results.SetBoolean("loadUnpackedDisabled", load_unpacked_disabled);
757 755
758 web_ui()->CallJavascriptFunction( 756 web_ui()->CallJavascriptFunction(
759 "extensions.ExtensionSettings.returnExtensionsData", results); 757 "extensions.ExtensionSettings.returnExtensionsData", results);
760 758
761 MaybeRegisterForNotifications(); 759 MaybeRegisterForNotifications();
762 UMA_HISTOGRAM_BOOLEAN("ExtensionSettings.ShouldDoVerificationCheck", 760 UMA_HISTOGRAM_BOOLEAN("ExtensionSettings.ShouldDoVerificationCheck",
763 should_do_verification_check_); 761 should_do_verification_check_);
764 if (should_do_verification_check_) { 762 if (should_do_verification_check_) {
765 should_do_verification_check_ = false; 763 should_do_verification_check_ = false;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 const Extension* extension = 844 const Extension* extension =
847 extension_service_->GetInstalledExtension(extension_id); 845 extension_service_->GetInstalledExtension(extension_id);
848 if (!extension || 846 if (!extension ||
849 !management_policy_->UserMayModifySettings(extension, NULL)) { 847 !management_policy_->UserMayModifySettings(extension, NULL)) {
850 LOG(ERROR) << "Attempt to enable an extension that is non-usermanagable was" 848 LOG(ERROR) << "Attempt to enable an extension that is non-usermanagable was"
851 << "made. Extension id: " << extension->id(); 849 << "made. Extension id: " << extension->id();
852 return; 850 return;
853 } 851 }
854 852
855 if (enable_str == "true") { 853 if (enable_str == "true") {
856 ExtensionPrefs* prefs = extension_service_->extension_prefs(); 854 ExtensionPrefs* prefs = ExtensionPrefs::Get(extension_service_->profile());
857 if (prefs->DidExtensionEscalatePermissions(extension_id)) { 855 if (prefs->DidExtensionEscalatePermissions(extension_id)) {
858 ShowExtensionDisabledDialog( 856 ShowExtensionDisabledDialog(
859 extension_service_, web_ui()->GetWebContents(), extension); 857 extension_service_, web_ui()->GetWebContents(), extension);
860 } else if ((prefs->GetDisableReasons(extension_id) & 858 } else if ((prefs->GetDisableReasons(extension_id) &
861 Extension::DISABLE_UNSUPPORTED_REQUIREMENT) && 859 Extension::DISABLE_UNSUPPORTED_REQUIREMENT) &&
862 !requirements_checker_.get()) { 860 !requirements_checker_.get()) {
863 // Recheck the requirements. 861 // Recheck the requirements.
864 scoped_refptr<const Extension> extension = 862 scoped_refptr<const Extension> extension =
865 extension_service_->GetExtensionById(extension_id, 863 extension_service_->GetExtensionById(extension_id,
866 true /* include disabled */); 864 true /* include disabled */);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 prompt_->ReviewPermissions( 989 prompt_->ReviewPermissions(
992 new BrokerDelegate(AsWeakPtr()), extension, retained_file_paths); 990 new BrokerDelegate(AsWeakPtr()), extension, retained_file_paths);
993 } 991 }
994 992
995 void ExtensionSettingsHandler::HandleShowButtonMessage( 993 void ExtensionSettingsHandler::HandleShowButtonMessage(
996 const base::ListValue* args) { 994 const base::ListValue* args) {
997 const Extension* extension = GetActiveExtension(args); 995 const Extension* extension = GetActiveExtension(args);
998 if (!extension) 996 if (!extension)
999 return; 997 return;
1000 ExtensionActionAPI::SetBrowserActionVisibility( 998 ExtensionActionAPI::SetBrowserActionVisibility(
1001 extension_service_->extension_prefs(), extension->id(), true); 999 ExtensionPrefs::Get(extension_service_->profile()),
1000 extension->id(),
1001 true);
1002 } 1002 }
1003 1003
1004 void ExtensionSettingsHandler::HandleAutoUpdateMessage( 1004 void ExtensionSettingsHandler::HandleAutoUpdateMessage(
1005 const base::ListValue* args) { 1005 const base::ListValue* args) {
1006 ExtensionUpdater* updater = extension_service_->updater(); 1006 ExtensionUpdater* updater = extension_service_->updater();
1007 if (updater) { 1007 if (updater) {
1008 ExtensionUpdater::CheckParams params; 1008 ExtensionUpdater::CheckParams params;
1009 params.install_immediately = true; 1009 params.install_immediately = true;
1010 updater->CheckNow(params); 1010 updater->CheckNow(params);
1011 } 1011 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 content::NotificationService::AllBrowserContextsAndSources()); 1076 content::NotificationService::AllBrowserContextsAndSources());
1077 registrar_.Add(this, 1077 registrar_.Add(this,
1078 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, 1078 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED,
1079 content::NotificationService::AllBrowserContextsAndSources()); 1079 content::NotificationService::AllBrowserContextsAndSources());
1080 registrar_.Add(this, 1080 registrar_.Add(this,
1081 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, 1081 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED,
1082 content::NotificationService::AllBrowserContextsAndSources()); 1082 content::NotificationService::AllBrowserContextsAndSources());
1083 registrar_.Add( 1083 registrar_.Add(
1084 this, 1084 this,
1085 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, 1085 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED,
1086 content::Source<ExtensionPrefs>( 1086 content::Source<ExtensionPrefs>(ExtensionPrefs::Get(profile)));
1087 profile->GetExtensionService()->extension_prefs()));
1088 registrar_.Add(this, 1087 registrar_.Add(this,
1089 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, 1088 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
1090 content::NotificationService::AllBrowserContextsAndSources()); 1089 content::NotificationService::AllBrowserContextsAndSources());
1091 1090
1092 registrar_.Add(this, 1091 registrar_.Add(this,
1093 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 1092 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
1094 content::NotificationService::AllBrowserContextsAndSources()); 1093 content::NotificationService::AllBrowserContextsAndSources());
1095 1094
1096 content::WebContentsObserver::Observe(web_ui()->GetWebContents()); 1095 content::WebContentsObserver::Observe(web_ui()->GetWebContents());
1097 1096
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 extension_service_->EnableExtension(extension_id); 1246 extension_service_->EnableExtension(extension_id);
1248 } else { 1247 } else {
1249 ExtensionErrorReporter::GetInstance()->ReportError( 1248 ExtensionErrorReporter::GetInstance()->ReportError(
1250 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), 1249 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')),
1251 true /* be noisy */); 1250 true /* be noisy */);
1252 } 1251 }
1253 requirements_checker_.reset(); 1252 requirements_checker_.reset();
1254 } 1253 }
1255 1254
1256 } // namespace extensions 1255 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698