OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <iterator> | 8 #include <iterator> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #include "chrome/browser/extensions/management_policy.h" | 59 #include "chrome/browser/extensions/management_policy.h" |
60 #include "chrome/browser/extensions/pending_extension_manager.h" | 60 #include "chrome/browser/extensions/pending_extension_manager.h" |
61 #include "chrome/browser/extensions/permissions_updater.h" | 61 #include "chrome/browser/extensions/permissions_updater.h" |
62 #include "chrome/browser/extensions/platform_app_launcher.h" | 62 #include "chrome/browser/extensions/platform_app_launcher.h" |
63 #include "chrome/browser/extensions/shell_window_registry.h" | 63 #include "chrome/browser/extensions/shell_window_registry.h" |
64 #include "chrome/browser/extensions/unpacked_installer.h" | 64 #include "chrome/browser/extensions/unpacked_installer.h" |
65 #include "chrome/browser/extensions/update_observer.h" | 65 #include "chrome/browser/extensions/update_observer.h" |
66 #include "chrome/browser/extensions/updater/extension_updater.h" | 66 #include "chrome/browser/extensions/updater/extension_updater.h" |
67 #include "chrome/browser/profiles/profile.h" | 67 #include "chrome/browser/profiles/profile.h" |
68 #include "chrome/browser/profiles/profile_manager.h" | 68 #include "chrome/browser/profiles/profile_manager.h" |
69 #include "chrome/browser/themes/theme_service.h" | |
70 #include "chrome/browser/themes/theme_service_factory.h" | |
71 #include "chrome/browser/ui/webui/favicon_source.h" | 69 #include "chrome/browser/ui/webui/favicon_source.h" |
72 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 70 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
73 #include "chrome/browser/ui/webui/theme_source.h" | 71 #include "chrome/browser/ui/webui/theme_source.h" |
74 #include "chrome/common/child_process_logging.h" | 72 #include "chrome/common/child_process_logging.h" |
75 #include "chrome/common/chrome_switches.h" | 73 #include "chrome/common/chrome_switches.h" |
76 #include "chrome/common/chrome_version_info.h" | 74 #include "chrome/common/chrome_version_info.h" |
77 #include "chrome/common/extensions/background_info.h" | 75 #include "chrome/common/extensions/background_info.h" |
78 #include "chrome/common/extensions/extension.h" | 76 #include "chrome/common/extensions/extension.h" |
79 #include "chrome/common/extensions/extension_constants.h" | 77 #include "chrome/common/extensions/extension_constants.h" |
80 #include "chrome/common/extensions/extension_file_util.h" | 78 #include "chrome/common/extensions/extension_file_util.h" |
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 | 1110 |
1113 void ExtensionService::NotifyExtensionUnloaded( | 1111 void ExtensionService::NotifyExtensionUnloaded( |
1114 const Extension* extension, | 1112 const Extension* extension, |
1115 extension_misc::UnloadedExtensionReason reason) { | 1113 extension_misc::UnloadedExtensionReason reason) { |
1116 UnloadedExtensionInfo details(extension, reason); | 1114 UnloadedExtensionInfo details(extension, reason); |
1117 content::NotificationService::current()->Notify( | 1115 content::NotificationService::current()->Notify( |
1118 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 1116 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
1119 content::Source<Profile>(profile_), | 1117 content::Source<Profile>(profile_), |
1120 content::Details<UnloadedExtensionInfo>(&details)); | 1118 content::Details<UnloadedExtensionInfo>(&details)); |
1121 | 1119 |
1122 #if defined(ENABLE_THEMES) | |
1123 // If the current theme is being unloaded, tell ThemeService to revert back | |
1124 // to the default theme. | |
1125 if (reason != extension_misc::UNLOAD_REASON_UPDATE && extension->is_theme()) { | |
1126 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile_); | |
1127 if (extension->id() == theme_service->GetThemeID()) | |
1128 theme_service->UseDefaultTheme(); | |
1129 } | |
1130 #endif | |
1131 | |
1132 for (content::RenderProcessHost::iterator i( | 1120 for (content::RenderProcessHost::iterator i( |
1133 content::RenderProcessHost::AllHostsIterator()); | 1121 content::RenderProcessHost::AllHostsIterator()); |
1134 !i.IsAtEnd(); i.Advance()) { | 1122 !i.IsAtEnd(); i.Advance()) { |
1135 content::RenderProcessHost* host = i.GetCurrentValue(); | 1123 content::RenderProcessHost* host = i.GetCurrentValue(); |
1136 Profile* host_profile = | 1124 Profile* host_profile = |
1137 Profile::FromBrowserContext(host->GetBrowserContext()); | 1125 Profile::FromBrowserContext(host->GetBrowserContext()); |
1138 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile()) | 1126 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile()) |
1139 host->Send(new ExtensionMsg_Unloaded(extension->id())); | 1127 host->Send(new ExtensionMsg_Unloaded(extension->id())); |
1140 } | 1128 } |
1141 | 1129 |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 info->at(i)->extension_path)); | 1931 info->at(i)->extension_path)); |
1944 | 1932 |
1945 if (!GetFileTaskRunner()->PostTask( | 1933 if (!GetFileTaskRunner()->PostTask( |
1946 FROM_HERE, | 1934 FROM_HERE, |
1947 base::Bind( | 1935 base::Bind( |
1948 &extension_file_util::GarbageCollectExtensions, | 1936 &extension_file_util::GarbageCollectExtensions, |
1949 install_directory_, | 1937 install_directory_, |
1950 extension_paths))) { | 1938 extension_paths))) { |
1951 NOTREACHED(); | 1939 NOTREACHED(); |
1952 } | 1940 } |
1953 | |
1954 #if defined(ENABLE_THEMES) | |
1955 // Also garbage-collect themes. We check |profile_| to be | |
1956 // defensive; in the future, we may call GarbageCollectExtensions() | |
1957 // from somewhere other than Init() (e.g., in a timer). | |
1958 if (profile_) { | |
1959 ThemeServiceFactory::GetForProfile(profile_)->RemoveUnusedThemes(); | |
1960 } | |
1961 #endif | |
1962 } | 1941 } |
1963 | 1942 |
1964 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { | 1943 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { |
1965 if (extensions::sync_helper::IsSyncableApp(&extension)) { | 1944 if (extensions::sync_helper::IsSyncableApp(&extension)) { |
1966 if (app_sync_bundle_.IsSyncing()) | 1945 if (app_sync_bundle_.IsSyncing()) |
1967 app_sync_bundle_.SyncChangeIfNeeded(extension); | 1946 app_sync_bundle_.SyncChangeIfNeeded(extension); |
1968 else if (is_ready() && !flare_.is_null()) | 1947 else if (is_ready() && !flare_.is_null()) |
1969 flare_.Run(syncer::APPS); | 1948 flare_.Run(syncer::APPS); |
1970 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { | 1949 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { |
1971 if (extension_sync_bundle_.IsSyncing()) | 1950 if (extension_sync_bundle_.IsSyncing()) |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2514 | 2493 |
2515 // Unpacked extensions default to allowing file access, but if that has been | 2494 // Unpacked extensions default to allowing file access, but if that has been |
2516 // overridden, don't reset the value. | 2495 // overridden, don't reset the value. |
2517 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) && | 2496 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) && |
2518 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { | 2497 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { |
2519 extension_prefs_->SetAllowFileAccess(extension->id(), true); | 2498 extension_prefs_->SetAllowFileAccess(extension->id(), true); |
2520 } | 2499 } |
2521 | 2500 |
2522 AddExtension(extension); | 2501 AddExtension(extension); |
2523 | 2502 |
2524 #if defined(ENABLE_THEMES) | |
2525 // We do this here since AddExtension() is always called on browser startup, | |
2526 // and we only really care about the last theme installed. | |
2527 // If that ever changes and we have to move this code somewhere | |
2528 // else, it should be somewhere that's not in the startup path. | |
2529 if (extension->is_theme() && extensions_.GetByID(extension->id())) { | |
2530 DCHECK_EQ(extensions_.GetByID(extension->id()), extension); | |
2531 // Now that the theme extension is visible from outside the | |
2532 // ExtensionService, notify the ThemeService about the | |
2533 // newly-installed theme. | |
2534 ThemeServiceFactory::GetForProfile(profile_)->SetTheme(extension); | |
2535 } | |
2536 #endif | |
2537 | |
2538 // If this is a new external extension that was disabled, alert the user | 2503 // If this is a new external extension that was disabled, alert the user |
2539 // so he can reenable it. We do this last so that it has already been | 2504 // so he can reenable it. We do this last so that it has already been |
2540 // added to our list of extensions. | 2505 // added to our list of extensions. |
2541 if (unacknowledged_external) { | 2506 if (unacknowledged_external) { |
2542 UpdateExternalExtensionAlert(); | 2507 UpdateExternalExtensionAlert(); |
2543 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", | 2508 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", |
2544 EXTERNAL_EXTENSION_INSTALLED, | 2509 EXTERNAL_EXTENSION_INSTALLED, |
2545 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); | 2510 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); |
2546 } | 2511 } |
2547 | 2512 |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3084 } | 3049 } |
3085 | 3050 |
3086 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 3051 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
3087 update_observers_.AddObserver(observer); | 3052 update_observers_.AddObserver(observer); |
3088 } | 3053 } |
3089 | 3054 |
3090 void ExtensionService::RemoveUpdateObserver( | 3055 void ExtensionService::RemoveUpdateObserver( |
3091 extensions::UpdateObserver* observer) { | 3056 extensions::UpdateObserver* observer) { |
3092 update_observers_.RemoveObserver(observer); | 3057 update_observers_.RemoveObserver(observer); |
3093 } | 3058 } |
OLD | NEW |