| OLD | NEW |
| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 show_extensions_prompts_(true), | 330 show_extensions_prompts_(true), |
| 331 ready_(false), | 331 ready_(false), |
| 332 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 332 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 333 menu_manager_(profile), | 333 menu_manager_(profile), |
| 334 app_notification_manager_( | 334 app_notification_manager_( |
| 335 new extensions::AppNotificationManager(profile)), | 335 new extensions::AppNotificationManager(profile)), |
| 336 event_routers_initialized_(false), | 336 event_routers_initialized_(false), |
| 337 update_once_all_providers_are_ready_(false), | 337 update_once_all_providers_are_ready_(false), |
| 338 app_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 338 app_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 339 extension_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 339 extension_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 340 extension_warnings_(profile), | |
| 341 app_shortcut_manager_(profile) { | 340 app_shortcut_manager_(profile) { |
| 342 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 341 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 343 | 342 |
| 344 // Figure out if extension installation should be enabled. | 343 // Figure out if extension installation should be enabled. |
| 345 if (command_line->HasSwitch(switches::kDisableExtensions) || | 344 if (command_line->HasSwitch(switches::kDisableExtensions) || |
| 346 profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { | 345 profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { |
| 347 extensions_enabled_ = false; | 346 extensions_enabled_ = false; |
| 348 } | 347 } |
| 349 | 348 |
| 350 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 349 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 | 798 |
| 800 static bool default_apps_trial_exists = | 799 static bool default_apps_trial_exists = |
| 801 base::FieldTrialList::TrialExists(kDefaultAppsTrialName); | 800 base::FieldTrialList::TrialExists(kDefaultAppsTrialName); |
| 802 if (default_apps_trial_exists) { | 801 if (default_apps_trial_exists) { |
| 803 UMA_HISTOGRAM_ENUMERATION( | 802 UMA_HISTOGRAM_ENUMERATION( |
| 804 base::FieldTrial::MakeName("Extensions.ExtensionUninstalled", | 803 base::FieldTrial::MakeName("Extensions.ExtensionUninstalled", |
| 805 kDefaultAppsTrialName), | 804 kDefaultAppsTrialName), |
| 806 1, 2); | 805 1, 2); |
| 807 } | 806 } |
| 808 | 807 |
| 809 // Uninstalling one extension might have solved the problems of others. | |
| 810 // Therefore, we clear warnings of this type for all extensions. | |
| 811 std::set<ExtensionWarningSet::WarningType> warnings; | |
| 812 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); | |
| 813 extension_warnings_.ClearWarnings(warnings); | |
| 814 | |
| 815 return true; | 808 return true; |
| 816 } | 809 } |
| 817 | 810 |
| 818 bool ExtensionService::IsExtensionEnabled( | 811 bool ExtensionService::IsExtensionEnabled( |
| 819 const std::string& extension_id) const { | 812 const std::string& extension_id) const { |
| 820 if (extensions_.Contains(extension_id) || | 813 if (extensions_.Contains(extension_id) || |
| 821 terminated_extensions_.Contains(extension_id)) { | 814 terminated_extensions_.Contains(extension_id)) { |
| 822 return true; | 815 return true; |
| 823 } | 816 } |
| 824 | 817 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 // for terminated extensions being disabled. | 892 // for terminated extensions being disabled. |
| 900 disabled_extensions_.Insert(make_scoped_refptr(extension)); | 893 disabled_extensions_.Insert(make_scoped_refptr(extension)); |
| 901 if (extensions_.Contains(extension->id())) { | 894 if (extensions_.Contains(extension->id())) { |
| 902 extensions_.Remove(extension->id()); | 895 extensions_.Remove(extension->id()); |
| 903 NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE); | 896 NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE); |
| 904 } else { | 897 } else { |
| 905 terminated_extensions_.Remove(extension->id()); | 898 terminated_extensions_.Remove(extension->id()); |
| 906 } | 899 } |
| 907 | 900 |
| 908 SyncExtensionChangeIfNeeded(*extension); | 901 SyncExtensionChangeIfNeeded(*extension); |
| 909 | |
| 910 // Deactivating one extension might have solved the problems of others. | |
| 911 // Therefore, we clear warnings of this type for all extensions. | |
| 912 std::set<ExtensionWarningSet::WarningType> warnings; | |
| 913 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); | |
| 914 extension_warnings_.ClearWarnings(warnings); | |
| 915 } | 902 } |
| 916 | 903 |
| 917 void ExtensionService::GrantPermissionsAndEnableExtension( | 904 void ExtensionService::GrantPermissionsAndEnableExtension( |
| 918 const Extension* extension, bool record_oauth2_grant) { | 905 const Extension* extension, bool record_oauth2_grant) { |
| 919 GrantPermissions(extension, record_oauth2_grant); | 906 GrantPermissions(extension, record_oauth2_grant); |
| 920 RecordPermissionMessagesHistogram( | 907 RecordPermissionMessagesHistogram( |
| 921 extension, "Extensions.Permissions_ReEnable"); | 908 extension, "Extensions.Permissions_ReEnable"); |
| 922 extension_prefs_->SetDidExtensionEscalatePermissions(extension, false); | 909 extension_prefs_->SetDidExtensionEscalatePermissions(extension, false); |
| 923 EnableExtension(extension->id()); | 910 EnableExtension(extension->id()); |
| 924 } | 911 } |
| (...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2666 extension_host->extension(), | 2653 extension_host->extension(), |
| 2667 NULL, FilePath()); | 2654 NULL, FilePath()); |
| 2668 #endif | 2655 #endif |
| 2669 } | 2656 } |
| 2670 | 2657 |
| 2671 void ExtensionService::InspectExtensionHost( | 2658 void ExtensionService::InspectExtensionHost( |
| 2672 extensions::ExtensionHost* host) { | 2659 extensions::ExtensionHost* host) { |
| 2673 if (host) | 2660 if (host) |
| 2674 DevToolsWindow::OpenDevToolsWindow(host->render_view_host()); | 2661 DevToolsWindow::OpenDevToolsWindow(host->render_view_host()); |
| 2675 } | 2662 } |
| OLD | NEW |