| 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_process_manager.h" | 5 #include "chrome/browser/extensions/extension_process_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/extensions/api/runtime/runtime_api.h" | 18 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
| 19 #include "chrome/browser/extensions/extension_host.h" | 19 #include "chrome/browser/extensions/extension_host.h" |
| 20 #include "chrome/browser/extensions/extension_info_map.h" | 20 #include "chrome/browser/extensions/extension_info_map.h" |
| 21 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 22 #include "chrome/browser/extensions/extension_system.h" | 22 #include "chrome/browser/extensions/extension_system.h" |
| 23 #include "chrome/browser/extensions/extension_util.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
| 25 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/browser/ui/browser_finder.h" | 27 #include "chrome/browser/ui/browser_finder.h" |
| 27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/extensions/background_info.h" | 29 #include "chrome/common/extensions/background_info.h" |
| 29 #include "chrome/common/extensions/extension.h" | 30 #include "chrome/common/extensions/extension.h" |
| 30 #include "chrome/common/extensions/extension_messages.h" | 31 #include "chrome/common/extensions/extension_messages.h" |
| 31 #include "chrome/common/extensions/incognito_handler.h" | 32 #include "chrome/common/extensions/incognito_handler.h" |
| 32 #include "chrome/common/extensions/manifest_url_handler.h" | 33 #include "chrome/common/extensions/manifest_url_handler.h" |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 return original_manager_->GetSiteInstanceForURL(url); | 910 return original_manager_->GetSiteInstanceForURL(url); |
| 910 } | 911 } |
| 911 } | 912 } |
| 912 return ExtensionProcessManager::GetSiteInstanceForURL(url); | 913 return ExtensionProcessManager::GetSiteInstanceForURL(url); |
| 913 } | 914 } |
| 914 | 915 |
| 915 bool IncognitoExtensionProcessManager::IsIncognitoEnabled( | 916 bool IncognitoExtensionProcessManager::IsIncognitoEnabled( |
| 916 const Extension* extension) { | 917 const Extension* extension) { |
| 917 // Keep in sync with duplicate in extension_info_map.cc. | 918 // Keep in sync with duplicate in extension_info_map.cc. |
| 918 ExtensionService* service = GetProfile()->GetExtensionService(); | 919 ExtensionService* service = GetProfile()->GetExtensionService(); |
| 919 return service && service->IsIncognitoEnabled(extension->id()); | 920 return extension_util::IsIncognitoEnabled(extension->id(), service); |
| 920 } | 921 } |
| 921 | 922 |
| 922 void IncognitoExtensionProcessManager::Observe( | 923 void IncognitoExtensionProcessManager::Observe( |
| 923 int type, | 924 int type, |
| 924 const content::NotificationSource& source, | 925 const content::NotificationSource& source, |
| 925 const content::NotificationDetails& details) { | 926 const content::NotificationDetails& details) { |
| 926 switch (type) { | 927 switch (type) { |
| 927 // Do not use ExtensionProcessManager's handler for | 928 // Do not use ExtensionProcessManager's handler for |
| 928 // NOTIFICATION_BROWSER_WINDOW_READY. | 929 // NOTIFICATION_BROWSER_WINDOW_READY. |
| 929 case chrome::NOTIFICATION_BROWSER_WINDOW_READY: { | 930 case chrome::NOTIFICATION_BROWSER_WINDOW_READY: { |
| 930 // We want to spawn our background hosts as soon as the user opens an | 931 // We want to spawn our background hosts as soon as the user opens an |
| 931 // incognito window. Watch for new browsers and create the hosts if | 932 // incognito window. Watch for new browsers and create the hosts if |
| 932 // it matches our profile. | 933 // it matches our profile. |
| 933 Browser* browser = content::Source<Browser>(source).ptr(); | 934 Browser* browser = content::Source<Browser>(source).ptr(); |
| 934 if (browser->profile() == site_instance_->GetBrowserContext()) { | 935 if (browser->profile() == site_instance_->GetBrowserContext()) { |
| 935 // On Chrome OS, a login screen is implemented as a browser. | 936 // On Chrome OS, a login screen is implemented as a browser. |
| 936 // This browser has no extension service. In this case, | 937 // This browser has no extension service. In this case, |
| 937 // service will be NULL. | 938 // service will be NULL. |
| 938 ExtensionService* service = GetProfile()->GetExtensionService(); | 939 ExtensionService* service = GetProfile()->GetExtensionService(); |
| 939 if (service && service->is_ready()) | 940 if (service && service->is_ready()) |
| 940 CreateBackgroundHostsForProfileStartup(); | 941 CreateBackgroundHostsForProfileStartup(); |
| 941 } | 942 } |
| 942 break; | 943 break; |
| 943 } | 944 } |
| 944 default: | 945 default: |
| 945 ExtensionProcessManager::Observe(type, source, details); | 946 ExtensionProcessManager::Observe(type, source, details); |
| 946 break; | 947 break; |
| 947 } | 948 } |
| 948 } | 949 } |
| OLD | NEW |