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

Side by Side Diff: chrome/browser/extensions/extension_service.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: Store ExtensionWarnings as values in set rather than pointers 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/extensions/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "chrome/browser/extensions/extension_error_reporter.h" 50 #include "chrome/browser/extensions/extension_error_reporter.h"
51 #include "chrome/browser/extensions/extension_error_ui.h" 51 #include "chrome/browser/extensions/extension_error_ui.h"
52 #include "chrome/browser/extensions/extension_host.h" 52 #include "chrome/browser/extensions/extension_host.h"
53 #include "chrome/browser/extensions/extension_install_ui.h" 53 #include "chrome/browser/extensions/extension_install_ui.h"
54 #include "chrome/browser/extensions/extension_preference_api.h" 54 #include "chrome/browser/extensions/extension_preference_api.h"
55 #include "chrome/browser/extensions/extension_process_manager.h" 55 #include "chrome/browser/extensions/extension_process_manager.h"
56 #include "chrome/browser/extensions/extension_sorting.h" 56 #include "chrome/browser/extensions/extension_sorting.h"
57 #include "chrome/browser/extensions/extension_special_storage_policy.h" 57 #include "chrome/browser/extensions/extension_special_storage_policy.h"
58 #include "chrome/browser/extensions/extension_sync_data.h" 58 #include "chrome/browser/extensions/extension_sync_data.h"
59 #include "chrome/browser/extensions/extension_system.h" 59 #include "chrome/browser/extensions/extension_system.h"
60 #include "chrome/browser/extensions/extension_warning_set.h"
60 #include "chrome/browser/extensions/extension_web_ui.h" 61 #include "chrome/browser/extensions/extension_web_ui.h"
61 #include "chrome/browser/extensions/external_provider_impl.h" 62 #include "chrome/browser/extensions/external_provider_impl.h"
62 #include "chrome/browser/extensions/external_provider_interface.h" 63 #include "chrome/browser/extensions/external_provider_interface.h"
63 #include "chrome/browser/extensions/installed_loader.h" 64 #include "chrome/browser/extensions/installed_loader.h"
64 #include "chrome/browser/extensions/lazy_background_task_queue.h" 65 #include "chrome/browser/extensions/lazy_background_task_queue.h"
65 #include "chrome/browser/extensions/pending_extension_manager.h" 66 #include "chrome/browser/extensions/pending_extension_manager.h"
66 #include "chrome/browser/extensions/permissions_updater.h" 67 #include "chrome/browser/extensions/permissions_updater.h"
67 #include "chrome/browser/extensions/platform_app_launcher.h" 68 #include "chrome/browser/extensions/platform_app_launcher.h"
68 #include "chrome/browser/extensions/settings/settings_frontend.h" 69 #include "chrome/browser/extensions/settings/settings_frontend.h"
69 #include "chrome/browser/extensions/shell_window_registry.h" 70 #include "chrome/browser/extensions/shell_window_registry.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 126
126 using content::BrowserContext; 127 using content::BrowserContext;
127 using content::BrowserThread; 128 using content::BrowserThread;
128 using content::DevToolsAgentHost; 129 using content::DevToolsAgentHost;
129 using content::DevToolsAgentHostRegistry; 130 using content::DevToolsAgentHostRegistry;
130 using content::PluginService; 131 using content::PluginService;
131 using extensions::CrxInstaller; 132 using extensions::CrxInstaller;
132 using extensions::Extension; 133 using extensions::Extension;
133 using extensions::ExtensionIdSet; 134 using extensions::ExtensionIdSet;
134 using extensions::ExtensionInfo; 135 using extensions::ExtensionInfo;
136 using extensions::ExtensionWarningService;
137 using extensions::ExtensionWarning;
135 using extensions::UnloadedExtensionInfo; 138 using extensions::UnloadedExtensionInfo;
136 using extensions::PermissionMessage; 139 using extensions::PermissionMessage;
137 using extensions::PermissionMessages; 140 using extensions::PermissionMessages;
138 using extensions::PermissionSet; 141 using extensions::PermissionSet;
139 142
140 namespace errors = extension_manifest_errors; 143 namespace errors = extension_manifest_errors;
141 144
142 namespace { 145 namespace {
143 146
144 #if defined(OS_LINUX) 147 #if defined(OS_LINUX)
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 show_extensions_prompts_(true), 333 show_extensions_prompts_(true),
331 ready_(false), 334 ready_(false),
332 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 335 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
333 menu_manager_(profile), 336 menu_manager_(profile),
334 app_notification_manager_( 337 app_notification_manager_(
335 new extensions::AppNotificationManager(profile)), 338 new extensions::AppNotificationManager(profile)),
336 event_routers_initialized_(false), 339 event_routers_initialized_(false),
337 update_once_all_providers_are_ready_(false), 340 update_once_all_providers_are_ready_(false),
338 app_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 341 app_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
339 extension_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 342 extension_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
340 extension_warnings_(profile),
341 app_shortcut_manager_(profile) { 343 app_shortcut_manager_(profile) {
342 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 344 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
343 345
344 // Figure out if extension installation should be enabled. 346 // Figure out if extension installation should be enabled.
345 if (command_line->HasSwitch(switches::kDisableExtensions)) { 347 if (command_line->HasSwitch(switches::kDisableExtensions)) {
346 extensions_enabled_ = false; 348 extensions_enabled_ = false;
347 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { 349 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) {
348 extensions_enabled_ = false; 350 extensions_enabled_ = false;
349 } 351 }
350 352
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 base::FieldTrialList::TrialExists(kDefaultAppsTrialName); 804 base::FieldTrialList::TrialExists(kDefaultAppsTrialName);
803 if (default_apps_trial_exists) { 805 if (default_apps_trial_exists) {
804 UMA_HISTOGRAM_ENUMERATION( 806 UMA_HISTOGRAM_ENUMERATION(
805 base::FieldTrial::MakeName("Extensions.ExtensionUninstalled", 807 base::FieldTrial::MakeName("Extensions.ExtensionUninstalled",
806 kDefaultAppsTrialName), 808 kDefaultAppsTrialName),
807 1, 2); 809 1, 2);
808 } 810 }
809 811
810 // Uninstalling one extension might have solved the problems of others. 812 // Uninstalling one extension might have solved the problems of others.
811 // Therefore, we clear warnings of this type for all extensions. 813 // Therefore, we clear warnings of this type for all extensions.
812 std::set<ExtensionWarningSet::WarningType> warnings; 814 std::set<ExtensionWarning::WarningType> warning_types;
battre 2012/09/11 21:56:41 I will move this into the if statement.
battre 2012/09/20 14:23:07 Done.
813 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); 815 ExtensionWarningService* warning_service = system_->warning_service();
814 extension_warnings_.ClearWarnings(warnings); 816 if (warning_service) { // May be NULL for unit tests.
817 warning_service->GetWarningTypesAffectingExtension(extension_id,
818 &warning_types);
Aaron Boodman 2012/09/18 18:48:56 Why not put this in UNLOAD rather than duplicating
battre 2012/09/20 14:23:07 Done.
819 warning_service->ClearWarnings(warning_types);
820 }
815 821
816 return true; 822 return true;
817 } 823 }
818 824
819 bool ExtensionService::IsExtensionEnabled( 825 bool ExtensionService::IsExtensionEnabled(
820 const std::string& extension_id) const { 826 const std::string& extension_id) const {
821 if (extensions_.Contains(extension_id) || 827 if (extensions_.Contains(extension_id) ||
822 terminated_extensions_.Contains(extension_id)) { 828 terminated_extensions_.Contains(extension_id)) {
823 return true; 829 return true;
824 } 830 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 extensions_.Remove(extension->id()); 910 extensions_.Remove(extension->id());
905 NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE); 911 NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE);
906 } else { 912 } else {
907 terminated_extensions_.Remove(extension->id()); 913 terminated_extensions_.Remove(extension->id());
908 } 914 }
909 915
910 SyncExtensionChangeIfNeeded(*extension); 916 SyncExtensionChangeIfNeeded(*extension);
911 917
912 // Deactivating one extension might have solved the problems of others. 918 // Deactivating one extension might have solved the problems of others.
913 // Therefore, we clear warnings of this type for all extensions. 919 // Therefore, we clear warnings of this type for all extensions.
914 std::set<ExtensionWarningSet::WarningType> warnings; 920 std::set<ExtensionWarning::WarningType> warning_types;
915 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); 921 ExtensionWarningService* warning_service = system_->warning_service();
916 extension_warnings_.ClearWarnings(warnings); 922 if (warning_service) { // May be NULL for unit tests.
923 warning_service->GetWarningTypesAffectingExtension(extension_id,
924 &warning_types);
925 warning_service->ClearWarnings(warning_types);
926 }
917 } 927 }
918 928
919 void ExtensionService::GrantPermissionsAndEnableExtension( 929 void ExtensionService::GrantPermissionsAndEnableExtension(
920 const Extension* extension, bool record_oauth2_grant) { 930 const Extension* extension, bool record_oauth2_grant) {
921 GrantPermissions(extension, record_oauth2_grant); 931 GrantPermissions(extension, record_oauth2_grant);
922 RecordPermissionMessagesHistogram( 932 RecordPermissionMessagesHistogram(
923 extension, "Extensions.Permissions_ReEnable"); 933 extension, "Extensions.Permissions_ReEnable");
924 extension_prefs_->SetDidExtensionEscalatePermissions(extension, false); 934 extension_prefs_->SetDidExtensionEscalatePermissions(extension, false);
925 EnableExtension(extension->id()); 935 EnableExtension(extension->id());
926 } 936 }
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
2625 extensions::ExtensionHost* extension_host) { 2635 extensions::ExtensionHost* extension_host) {
2626 if (!extension_host) 2636 if (!extension_host)
2627 return; 2637 return;
2628 2638
2629 #if !defined(OS_ANDROID) 2639 #if !defined(OS_ANDROID)
2630 extensions::LaunchPlatformApp(extension_host->profile(), 2640 extensions::LaunchPlatformApp(extension_host->profile(),
2631 extension_host->extension(), 2641 extension_host->extension(),
2632 NULL, FilePath()); 2642 NULL, FilePath());
2633 #endif 2643 #endif
2634 } 2644 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698