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 <iterator> | 8 #include <iterator> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 #include "chrome/browser/themes/theme_service.h" | 72 #include "chrome/browser/themes/theme_service.h" |
73 #include "chrome/browser/themes/theme_service_factory.h" | 73 #include "chrome/browser/themes/theme_service_factory.h" |
74 #include "chrome/browser/ui/webui/favicon_source.h" | 74 #include "chrome/browser/ui/webui/favicon_source.h" |
75 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 75 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
76 #include "chrome/browser/ui/webui/theme_source.h" | 76 #include "chrome/browser/ui/webui/theme_source.h" |
77 #include "chrome/common/child_process_logging.h" | 77 #include "chrome/common/child_process_logging.h" |
78 #include "chrome/common/chrome_notification_types.h" | 78 #include "chrome/common/chrome_notification_types.h" |
79 #include "chrome/common/chrome_paths.h" | 79 #include "chrome/common/chrome_paths.h" |
80 #include "chrome/common/chrome_switches.h" | 80 #include "chrome/common/chrome_switches.h" |
81 #include "chrome/common/chrome_version_info.h" | 81 #include "chrome/common/chrome_version_info.h" |
| 82 #include "chrome/common/extensions/background_info.h" |
82 #include "chrome/common/extensions/extension.h" | 83 #include "chrome/common/extensions/extension.h" |
83 #include "chrome/common/extensions/extension_file_util.h" | 84 #include "chrome/common/extensions/extension_file_util.h" |
84 #include "chrome/common/extensions/extension_manifest_constants.h" | 85 #include "chrome/common/extensions/extension_manifest_constants.h" |
85 #include "chrome/common/extensions/extension_messages.h" | 86 #include "chrome/common/extensions/extension_messages.h" |
86 #include "chrome/common/extensions/extension_resource.h" | 87 #include "chrome/common/extensions/extension_resource.h" |
87 #include "chrome/common/extensions/feature_switch.h" | 88 #include "chrome/common/extensions/feature_switch.h" |
88 #include "chrome/common/extensions/features/feature.h" | 89 #include "chrome/common/extensions/features/feature.h" |
89 #include "chrome/common/extensions/manifest.h" | 90 #include "chrome/common/extensions/manifest.h" |
90 #include "chrome/common/extensions/manifest_url_handler.h" | 91 #include "chrome/common/extensions/manifest_url_handler.h" |
91 #include "chrome/common/pref_names.h" | 92 #include "chrome/common/pref_names.h" |
(...skipping 2688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2780 for (ExtensionSet::const_iterator it = extensions_.begin(); | 2781 for (ExtensionSet::const_iterator it = extensions_.begin(); |
2781 it != extensions_.end(); ++it) { | 2782 it != extensions_.end(); ++it) { |
2782 if ((*it)->is_app() && (*it)->location() != Manifest::COMPONENT) | 2783 if ((*it)->is_app() && (*it)->location() != Manifest::COMPONENT) |
2783 result.insert((*it)->id()); | 2784 result.insert((*it)->id()); |
2784 } | 2785 } |
2785 | 2786 |
2786 return result; | 2787 return result; |
2787 } | 2788 } |
2788 | 2789 |
2789 bool ExtensionService::IsBackgroundPageReady(const Extension* extension) const { | 2790 bool ExtensionService::IsBackgroundPageReady(const Extension* extension) const { |
2790 if (!extension->has_persistent_background_page()) | 2791 if (!extensions::BackgroundInfo::HasPersistentBackgroundPage(extension)) |
2791 return true; | 2792 return true; |
2792 ExtensionRuntimeDataMap::const_iterator it = | 2793 ExtensionRuntimeDataMap::const_iterator it = |
2793 extension_runtime_data_.find(extension->id()); | 2794 extension_runtime_data_.find(extension->id()); |
2794 return it == extension_runtime_data_.end() ? false : | 2795 return it == extension_runtime_data_.end() ? false : |
2795 it->second.background_page_ready; | 2796 it->second.background_page_ready; |
2796 } | 2797 } |
2797 | 2798 |
2798 void ExtensionService::SetBackgroundPageReady(const Extension* extension) { | 2799 void ExtensionService::SetBackgroundPageReady(const Extension* extension) { |
2799 DCHECK(extension->has_background_page()); | 2800 DCHECK(extensions::BackgroundInfo::HasBackgroundPage(extension)); |
2800 extension_runtime_data_[extension->id()].background_page_ready = true; | 2801 extension_runtime_data_[extension->id()].background_page_ready = true; |
2801 content::NotificationService::current()->Notify( | 2802 content::NotificationService::current()->Notify( |
2802 chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, | 2803 chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, |
2803 content::Source<const Extension>(extension), | 2804 content::Source<const Extension>(extension), |
2804 content::NotificationService::NoDetails()); | 2805 content::NotificationService::NoDetails()); |
2805 } | 2806 } |
2806 | 2807 |
2807 void ExtensionService::InspectBackgroundPage(const Extension* extension) { | 2808 void ExtensionService::InspectBackgroundPage(const Extension* extension) { |
2808 DCHECK(extension); | 2809 DCHECK(extension); |
2809 | 2810 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3021 // If delayed updates are globally disabled, or just for this extension, | 3022 // If delayed updates are globally disabled, or just for this extension, |
3022 // don't delay. | 3023 // don't delay. |
3023 if (!install_updates_when_idle_ || !wait_for_idle) | 3024 if (!install_updates_when_idle_ || !wait_for_idle) |
3024 return false; | 3025 return false; |
3025 | 3026 |
3026 const Extension* old = GetInstalledExtension(extension_id); | 3027 const Extension* old = GetInstalledExtension(extension_id); |
3027 // If there is no old extension, this is not an update, so don't delay. | 3028 // If there is no old extension, this is not an update, so don't delay. |
3028 if (!old) | 3029 if (!old) |
3029 return false; | 3030 return false; |
3030 | 3031 |
3031 if (old->has_persistent_background_page()) { | 3032 if (extensions::BackgroundInfo::HasPersistentBackgroundPage(old)) { |
3032 // Delay installation if the extension listens for the onUpdateAvailable | 3033 // Delay installation if the extension listens for the onUpdateAvailable |
3033 // event. | 3034 // event. |
3034 return system_->event_router()->ExtensionHasEventListener( | 3035 return system_->event_router()->ExtensionHasEventListener( |
3035 extension_id, kOnUpdateAvailableEvent); | 3036 extension_id, kOnUpdateAvailableEvent); |
3036 } else { | 3037 } else { |
3037 // Delay installation if the extension is not idle. | 3038 // Delay installation if the extension is not idle. |
3038 return !IsExtensionIdle(extension_id); | 3039 return !IsExtensionIdle(extension_id); |
3039 } | 3040 } |
3040 } | 3041 } |
3041 | 3042 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3123 if (!extension) | 3124 if (!extension) |
3124 continue; | 3125 continue; |
3125 blacklisted_extensions_.Insert(extension); | 3126 blacklisted_extensions_.Insert(extension); |
3126 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); | 3127 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); |
3127 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.BlacklistInstalled", | 3128 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.BlacklistInstalled", |
3128 extension->location(), Manifest::NUM_LOCATIONS); | 3129 extension->location(), Manifest::NUM_LOCATIONS); |
3129 } | 3130 } |
3130 | 3131 |
3131 IdentifyAlertableExtensions(); | 3132 IdentifyAlertableExtensions(); |
3132 } | 3133 } |
OLD | NEW |