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_url_handler.h" | 90 #include "chrome/common/extensions/manifest_url_handler.h" |
90 #include "chrome/common/pref_names.h" | 91 #include "chrome/common/pref_names.h" |
91 #include "chrome/common/startup_metric_utils.h" | 92 #include "chrome/common/startup_metric_utils.h" |
(...skipping 2672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2764 for (ExtensionSet::const_iterator it = extensions_.begin(); | 2765 for (ExtensionSet::const_iterator it = extensions_.begin(); |
2765 it != extensions_.end(); ++it) { | 2766 it != extensions_.end(); ++it) { |
2766 if ((*it)->is_app() && (*it)->location() != Manifest::COMPONENT) | 2767 if ((*it)->is_app() && (*it)->location() != Manifest::COMPONENT) |
2767 result.insert((*it)->id()); | 2768 result.insert((*it)->id()); |
2768 } | 2769 } |
2769 | 2770 |
2770 return result; | 2771 return result; |
2771 } | 2772 } |
2772 | 2773 |
2773 bool ExtensionService::IsBackgroundPageReady(const Extension* extension) const { | 2774 bool ExtensionService::IsBackgroundPageReady(const Extension* extension) const { |
2774 if (!extension->has_persistent_background_page()) | 2775 if (!extensions::BackgroundInfo::HasPersistentBackgroundPage(extension)) |
2775 return true; | 2776 return true; |
2776 ExtensionRuntimeDataMap::const_iterator it = | 2777 ExtensionRuntimeDataMap::const_iterator it = |
2777 extension_runtime_data_.find(extension->id()); | 2778 extension_runtime_data_.find(extension->id()); |
2778 return it == extension_runtime_data_.end() ? false : | 2779 return it == extension_runtime_data_.end() ? false : |
2779 it->second.background_page_ready; | 2780 it->second.background_page_ready; |
2780 } | 2781 } |
2781 | 2782 |
2782 void ExtensionService::SetBackgroundPageReady(const Extension* extension) { | 2783 void ExtensionService::SetBackgroundPageReady(const Extension* extension) { |
2783 DCHECK(extension->has_background_page()); | 2784 DCHECK(extensions::BackgroundInfo::HasBackgroundPage(extension)); |
2784 extension_runtime_data_[extension->id()].background_page_ready = true; | 2785 extension_runtime_data_[extension->id()].background_page_ready = true; |
2785 content::NotificationService::current()->Notify( | 2786 content::NotificationService::current()->Notify( |
2786 chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, | 2787 chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, |
2787 content::Source<const Extension>(extension), | 2788 content::Source<const Extension>(extension), |
2788 content::NotificationService::NoDetails()); | 2789 content::NotificationService::NoDetails()); |
2789 } | 2790 } |
2790 | 2791 |
2791 void ExtensionService::InspectBackgroundPage(const Extension* extension) { | 2792 void ExtensionService::InspectBackgroundPage(const Extension* extension) { |
2792 DCHECK(extension); | 2793 DCHECK(extension); |
2793 | 2794 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3005 // If delayed updates are globally disabled, or just for this extension, | 3006 // If delayed updates are globally disabled, or just for this extension, |
3006 // don't delay. | 3007 // don't delay. |
3007 if (!install_updates_when_idle_ || !wait_for_idle) | 3008 if (!install_updates_when_idle_ || !wait_for_idle) |
3008 return false; | 3009 return false; |
3009 | 3010 |
3010 const Extension* old = GetInstalledExtension(extension_id); | 3011 const Extension* old = GetInstalledExtension(extension_id); |
3011 // If there is no old extension, this is not an update, so don't delay. | 3012 // If there is no old extension, this is not an update, so don't delay. |
3012 if (!old) | 3013 if (!old) |
3013 return false; | 3014 return false; |
3014 | 3015 |
3015 if (old->has_persistent_background_page()) { | 3016 if (extensions::BackgroundInfo::HasPersistentBackgroundPage(old)) { |
3016 // Delay installation if the extension listens for the onUpdateAvailable | 3017 // Delay installation if the extension listens for the onUpdateAvailable |
3017 // event. | 3018 // event. |
3018 return system_->event_router()->ExtensionHasEventListener( | 3019 return system_->event_router()->ExtensionHasEventListener( |
3019 extension_id, kOnUpdateAvailableEvent); | 3020 extension_id, kOnUpdateAvailableEvent); |
3020 } else { | 3021 } else { |
3021 // Delay installation if the extension is not idle. | 3022 // Delay installation if the extension is not idle. |
3022 return !IsExtensionIdle(extension_id); | 3023 return !IsExtensionIdle(extension_id); |
3023 } | 3024 } |
3024 } | 3025 } |
3025 | 3026 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3103 scoped_refptr<const Extension> extension = GetInstalledExtension(*it); | 3104 scoped_refptr<const Extension> extension = GetInstalledExtension(*it); |
3104 DCHECK(extension); | 3105 DCHECK(extension); |
3105 if (!extension) | 3106 if (!extension) |
3106 continue; | 3107 continue; |
3107 blacklisted_extensions_.Insert(extension); | 3108 blacklisted_extensions_.Insert(extension); |
3108 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); | 3109 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); |
3109 } | 3110 } |
3110 | 3111 |
3111 IdentifyAlertableExtensions(); | 3112 IdentifyAlertableExtensions(); |
3112 } | 3113 } |
OLD | NEW |