| 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/search/search.h" | 75 #include "chrome/browser/ui/search/search.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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url)); | 745 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url)); |
| 745 if (!extension) | 746 if (!extension) |
| 746 return false; | 747 return false; |
| 747 | 748 |
| 748 // If the URL is part of a hosted app that does not have the background | 749 // If the URL is part of a hosted app that does not have the background |
| 749 // permission, or that does not allow JavaScript access to the background | 750 // permission, or that does not allow JavaScript access to the background |
| 750 // page, we want to give each instance its own process to improve | 751 // page, we want to give each instance its own process to improve |
| 751 // responsiveness. | 752 // responsiveness. |
| 752 if (extension->GetType() == Manifest::TYPE_HOSTED_APP) { | 753 if (extension->GetType() == Manifest::TYPE_HOSTED_APP) { |
| 753 if (!extension->HasAPIPermission(APIPermission::kBackground) || | 754 if (!extension->HasAPIPermission(APIPermission::kBackground) || |
| 754 !extension->allow_background_js_access()) { | 755 !extensions::BackgroundInfo::AllowJSAccess(extension)) { |
| 755 return false; | 756 return false; |
| 756 } | 757 } |
| 757 } | 758 } |
| 758 | 759 |
| 759 // Hosted apps that have script access to their background page must use | 760 // Hosted apps that have script access to their background page must use |
| 760 // process per site, since all instances can make synchronous calls to the | 761 // process per site, since all instances can make synchronous calls to the |
| 761 // background window. Other extensions should use process per site as well. | 762 // background window. Other extensions should use process per site as well. |
| 762 return true; | 763 return true; |
| 763 } | 764 } |
| 764 | 765 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 ExtensionService* service = !profile ? NULL : | 869 ExtensionService* service = !profile ? NULL : |
| 869 extensions::ExtensionSystem::Get(profile)->extension_service(); | 870 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 870 if (!service) | 871 if (!service) |
| 871 return false; | 872 return false; |
| 872 | 873 |
| 873 // We have to have a valid extension with background page to proceed. | 874 // We have to have a valid extension with background page to proceed. |
| 874 const Extension* extension = | 875 const Extension* extension = |
| 875 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url)); | 876 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url)); |
| 876 if (!extension) | 877 if (!extension) |
| 877 return false; | 878 return false; |
| 878 if (!extension->has_background_page()) | 879 if (!extensions::BackgroundInfo::HasBackgroundPage(extension)) |
| 879 return false; | 880 return false; |
| 880 | 881 |
| 881 std::set<int> process_ids; | 882 std::set<int> process_ids; |
| 882 size_t max_process_count = | 883 size_t max_process_count = |
| 883 content::RenderProcessHost::GetMaxRendererProcessCount(); | 884 content::RenderProcessHost::GetMaxRendererProcessCount(); |
| 884 | 885 |
| 885 // Go through all profiles to ensure we have total count of extension | 886 // Go through all profiles to ensure we have total count of extension |
| 886 // processes containing background pages, otherwise one profile can | 887 // processes containing background pages, otherwise one profile can |
| 887 // starve the other. | 888 // starve the other. |
| 888 std::vector<Profile*> profiles = g_browser_process->profile_manager()-> | 889 std::vector<Profile*> profiles = g_browser_process->profile_manager()-> |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 } | 1638 } |
| 1638 | 1639 |
| 1639 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may | 1640 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may |
| 1640 // return a recently installed Extension even if this CanCreateWindow call | 1641 // return a recently installed Extension even if this CanCreateWindow call |
| 1641 // was made by an old copy of the page in a normal web process. That's ok, | 1642 // was made by an old copy of the page in a normal web process. That's ok, |
| 1642 // because the permission check above would have caused an early return | 1643 // because the permission check above would have caused an early return |
| 1643 // already. We must use the full URL to find hosted apps, though, and not | 1644 // already. We must use the full URL to find hosted apps, though, and not |
| 1644 // just the origin. | 1645 // just the origin. |
| 1645 const Extension* extension = map->extensions().GetExtensionOrAppByURL( | 1646 const Extension* extension = map->extensions().GetExtensionOrAppByURL( |
| 1646 ExtensionURLInfo(opener_url)); | 1647 ExtensionURLInfo(opener_url)); |
| 1647 if (extension && !extension->allow_background_js_access()) | 1648 if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension)) |
| 1648 *no_javascript_access = true; | 1649 *no_javascript_access = true; |
| 1649 } | 1650 } |
| 1650 return true; | 1651 return true; |
| 1651 } | 1652 } |
| 1652 | 1653 |
| 1653 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( | 1654 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( |
| 1654 const GURL& url, content::ResourceContext* context) { | 1655 const GURL& url, content::ResourceContext* context) { |
| 1655 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1656 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1656 // Check if it's an extension-created worker, in which case we want to use | 1657 // Check if it's an extension-created worker, in which case we want to use |
| 1657 // the name of the extension. | 1658 // the name of the extension. |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2095 io_thread_application_locale_ = locale; | 2096 io_thread_application_locale_ = locale; |
| 2096 } | 2097 } |
| 2097 | 2098 |
| 2098 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( | 2099 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( |
| 2099 const std::string& locale) { | 2100 const std::string& locale) { |
| 2100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 2101 io_thread_application_locale_ = locale; | 2102 io_thread_application_locale_ = locale; |
| 2102 } | 2103 } |
| 2103 | 2104 |
| 2104 } // namespace chrome | 2105 } // namespace chrome |
| OLD | NEW |