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/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 #include "chrome/browser/ui/chrome_select_file_policy.h" | 75 #include "chrome/browser/ui/chrome_select_file_policy.h" |
76 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" | 76 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" |
77 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 77 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
78 #include "chrome/browser/user_style_sheet_watcher.h" | 78 #include "chrome/browser/user_style_sheet_watcher.h" |
79 #include "chrome/browser/user_style_sheet_watcher_factory.h" | 79 #include "chrome/browser/user_style_sheet_watcher_factory.h" |
80 #include "chrome/browser/view_type_utils.h" | 80 #include "chrome/browser/view_type_utils.h" |
81 #include "chrome/common/child_process_logging.h" | 81 #include "chrome/common/child_process_logging.h" |
82 #include "chrome/common/chrome_constants.h" | 82 #include "chrome/common/chrome_constants.h" |
83 #include "chrome/common/chrome_paths.h" | 83 #include "chrome/common/chrome_paths.h" |
84 #include "chrome/common/chrome_switches.h" | 84 #include "chrome/common/chrome_switches.h" |
| 85 #include "chrome/common/extensions/background_info.h" |
85 #include "chrome/common/extensions/extension.h" | 86 #include "chrome/common/extensions/extension.h" |
86 #include "chrome/common/extensions/extension_process_policy.h" | 87 #include "chrome/common/extensions/extension_process_policy.h" |
87 #include "chrome/common/extensions/extension_set.h" | 88 #include "chrome/common/extensions/extension_set.h" |
88 #include "chrome/common/extensions/permissions/socket_permission.h" | 89 #include "chrome/common/extensions/permissions/socket_permission.h" |
89 #include "chrome/common/logging_chrome.h" | 90 #include "chrome/common/logging_chrome.h" |
90 #include "chrome/common/pref_names.h" | 91 #include "chrome/common/pref_names.h" |
91 #include "chrome/common/render_messages.h" | 92 #include "chrome/common/render_messages.h" |
92 #include "chrome/common/url_constants.h" | 93 #include "chrome/common/url_constants.h" |
93 #include "content/public/browser/browser_child_process_host.h" | 94 #include "content/public/browser/browser_child_process_host.h" |
94 #include "content/public/browser/browser_main_parts.h" | 95 #include "content/public/browser/browser_main_parts.h" |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url)); | 783 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url)); |
783 if (!extension) | 784 if (!extension) |
784 return false; | 785 return false; |
785 | 786 |
786 // If the URL is part of a hosted app that does not have the background | 787 // If the URL is part of a hosted app that does not have the background |
787 // permission, or that does not allow JavaScript access to the background | 788 // permission, or that does not allow JavaScript access to the background |
788 // page, we want to give each instance its own process to improve | 789 // page, we want to give each instance its own process to improve |
789 // responsiveness. | 790 // responsiveness. |
790 if (extension->GetType() == Manifest::TYPE_HOSTED_APP) { | 791 if (extension->GetType() == Manifest::TYPE_HOSTED_APP) { |
791 if (!extension->HasAPIPermission(APIPermission::kBackground) || | 792 if (!extension->HasAPIPermission(APIPermission::kBackground) || |
792 !extension->allow_background_js_access()) { | 793 !extensions::BackgroundInfo::AllowJSAccess(extension)) { |
793 return false; | 794 return false; |
794 } | 795 } |
795 } | 796 } |
796 | 797 |
797 // Hosted apps that have script access to their background page must use | 798 // Hosted apps that have script access to their background page must use |
798 // process per site, since all instances can make synchronous calls to the | 799 // process per site, since all instances can make synchronous calls to the |
799 // background window. Other extensions should use process per site as well. | 800 // background window. Other extensions should use process per site as well. |
800 return true; | 801 return true; |
801 } | 802 } |
802 | 803 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 ExtensionService* service = !profile ? NULL : | 907 ExtensionService* service = !profile ? NULL : |
907 extensions::ExtensionSystem::Get(profile)->extension_service(); | 908 extensions::ExtensionSystem::Get(profile)->extension_service(); |
908 if (!service) | 909 if (!service) |
909 return false; | 910 return false; |
910 | 911 |
911 // We have to have a valid extension with background page to proceed. | 912 // We have to have a valid extension with background page to proceed. |
912 const Extension* extension = | 913 const Extension* extension = |
913 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url)); | 914 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url)); |
914 if (!extension) | 915 if (!extension) |
915 return false; | 916 return false; |
916 if (!extension->has_background_page()) | 917 if (!extensions::BackgroundInfo::HasBackgroundPage(extension)) |
917 return false; | 918 return false; |
918 | 919 |
919 std::set<int> process_ids; | 920 std::set<int> process_ids; |
920 size_t max_process_count = | 921 size_t max_process_count = |
921 content::RenderProcessHost::GetMaxRendererProcessCount(); | 922 content::RenderProcessHost::GetMaxRendererProcessCount(); |
922 | 923 |
923 // Go through all profiles to ensure we have total count of extension | 924 // Go through all profiles to ensure we have total count of extension |
924 // processes containing background pages, otherwise one profile can | 925 // processes containing background pages, otherwise one profile can |
925 // starve the other. | 926 // starve the other. |
926 std::vector<Profile*> profiles = g_browser_process->profile_manager()-> | 927 std::vector<Profile*> profiles = g_browser_process->profile_manager()-> |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 } | 1633 } |
1633 | 1634 |
1634 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may | 1635 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may |
1635 // return a recently installed Extension even if this CanCreateWindow call | 1636 // return a recently installed Extension even if this CanCreateWindow call |
1636 // was made by an old copy of the page in a normal web process. That's ok, | 1637 // was made by an old copy of the page in a normal web process. That's ok, |
1637 // because the permission check above would have caused an early return | 1638 // because the permission check above would have caused an early return |
1638 // already. We must use the full URL to find hosted apps, though, and not | 1639 // already. We must use the full URL to find hosted apps, though, and not |
1639 // just the origin. | 1640 // just the origin. |
1640 const Extension* extension = map->extensions().GetExtensionOrAppByURL( | 1641 const Extension* extension = map->extensions().GetExtensionOrAppByURL( |
1641 ExtensionURLInfo(opener_url)); | 1642 ExtensionURLInfo(opener_url)); |
1642 if (extension && !extension->allow_background_js_access()) | 1643 if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension)) |
1643 *no_javascript_access = true; | 1644 *no_javascript_access = true; |
1644 } | 1645 } |
1645 return true; | 1646 return true; |
1646 } | 1647 } |
1647 | 1648 |
1648 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( | 1649 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( |
1649 const GURL& url, content::ResourceContext* context) { | 1650 const GURL& url, content::ResourceContext* context) { |
1650 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1651 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1651 // Check if it's an extension-created worker, in which case we want to use | 1652 // Check if it's an extension-created worker, in which case we want to use |
1652 // the name of the extension. | 1653 // the name of the extension. |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2089 io_thread_application_locale_ = locale; | 2090 io_thread_application_locale_ = locale; |
2090 } | 2091 } |
2091 | 2092 |
2092 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( | 2093 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( |
2093 const std::string& locale) { | 2094 const std::string& locale) { |
2094 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2095 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
2095 io_thread_application_locale_ = locale; | 2096 io_thread_application_locale_ = locale; |
2096 } | 2097 } |
2097 | 2098 |
2098 } // namespace chrome | 2099 } // namespace chrome |
OLD | NEW |