| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 using content::BrowserThread; | 159 using content::BrowserThread; |
| 160 using content::BrowserURLHandler; | 160 using content::BrowserURLHandler; |
| 161 using content::ChildProcessSecurityPolicy; | 161 using content::ChildProcessSecurityPolicy; |
| 162 using content::FileDescriptorInfo; | 162 using content::FileDescriptorInfo; |
| 163 using content::QuotaPermissionContext; | 163 using content::QuotaPermissionContext; |
| 164 using content::RenderViewHost; | 164 using content::RenderViewHost; |
| 165 using content::SiteInstance; | 165 using content::SiteInstance; |
| 166 using content::WebContents; | 166 using content::WebContents; |
| 167 using extensions::APIPermission; | 167 using extensions::APIPermission; |
| 168 using extensions::Extension; | 168 using extensions::Extension; |
| 169 using extensions::Manifest; |
| 169 using webkit_glue::WebPreferences; | 170 using webkit_glue::WebPreferences; |
| 170 | 171 |
| 171 namespace { | 172 namespace { |
| 172 | 173 |
| 173 const char* kPredefinedAllowedSocketOrigins[] = { | 174 const char* kPredefinedAllowedSocketOrigins[] = { |
| 174 "okddffdblfhhnmhodogpojmfkjmhinfp", // Test SSH Client | 175 "okddffdblfhhnmhodogpojmfkjmhinfp", // Test SSH Client |
| 175 "pnhechapfaindjhompbnflcldabbghjo", // HTerm App (SSH Client) | 176 "pnhechapfaindjhompbnflcldabbghjo", // HTerm App (SSH Client) |
| 176 "bglhmjfplikpjnfoegeomebmfnkjomhe", // see crbug.com/122126 | 177 "bglhmjfplikpjnfoegeomebmfnkjomhe", // see crbug.com/122126 |
| 177 "gbchcmhmhahfdphkhkmpfmihenigjmpp", // Chrome Remote Desktop | 178 "gbchcmhmhahfdphkhkmpfmihenigjmpp", // Chrome Remote Desktop |
| 178 "kgngmbheleoaphbjbaiobfdepmghbfah", // Pre-release Chrome Remote Desktop | 179 "kgngmbheleoaphbjbaiobfdepmghbfah", // Pre-release Chrome Remote Desktop |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 | 794 |
| 794 const Extension* extension = extension_service->extensions()-> | 795 const Extension* extension = extension_service->extensions()-> |
| 795 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url)); | 796 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url)); |
| 796 if (!extension) | 797 if (!extension) |
| 797 return false; | 798 return false; |
| 798 | 799 |
| 799 // If the URL is part of a hosted app that does not have the background | 800 // If the URL is part of a hosted app that does not have the background |
| 800 // permission, or that does not allow JavaScript access to the background | 801 // permission, or that does not allow JavaScript access to the background |
| 801 // page, we want to give each instance its own process to improve | 802 // page, we want to give each instance its own process to improve |
| 802 // responsiveness. | 803 // responsiveness. |
| 803 if (extension->GetType() == Extension::TYPE_HOSTED_APP) { | 804 if (extension->GetType() == Manifest::TYPE_HOSTED_APP) { |
| 804 if (!extension->HasAPIPermission(APIPermission::kBackground) || | 805 if (!extension->HasAPIPermission(APIPermission::kBackground) || |
| 805 !extension->allow_background_js_access()) { | 806 !extension->allow_background_js_access()) { |
| 806 return false; | 807 return false; |
| 807 } | 808 } |
| 808 } | 809 } |
| 809 | 810 |
| 810 // Hosted apps that have script access to their background page must use | 811 // Hosted apps that have script access to their background page must use |
| 811 // process per site, since all instances can make synchronous calls to the | 812 // process per site, since all instances can make synchronous calls to the |
| 812 // background window. Other extensions should use process per site as well. | 813 // background window. Other extensions should use process per site as well. |
| 813 return true; | 814 return true; |
| (...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1921 } | 1922 } |
| 1922 | 1923 |
| 1923 // Need to check this now and not on construction because otherwise it won't | 1924 // Need to check this now and not on construction because otherwise it won't |
| 1924 // work with browser_tests. | 1925 // work with browser_tests. |
| 1925 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1926 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 1926 std::string allowed_list = | 1927 std::string allowed_list = |
| 1927 command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI); | 1928 command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI); |
| 1928 if (allowed_list == "*") { | 1929 if (allowed_list == "*") { |
| 1929 // The wildcard allows socket API only for packaged and platform apps. | 1930 // The wildcard allows socket API only for packaged and platform apps. |
| 1930 return extension && | 1931 return extension && |
| 1931 (extension->GetType() == Extension::TYPE_LEGACY_PACKAGED_APP || | 1932 (extension->GetType() == Manifest::TYPE_LEGACY_PACKAGED_APP || |
| 1932 extension->GetType() == Extension::TYPE_PLATFORM_APP); | 1933 extension->GetType() == Manifest::TYPE_PLATFORM_APP); |
| 1933 } else if (!allowed_list.empty()) { | 1934 } else if (!allowed_list.empty()) { |
| 1934 StringTokenizer t(allowed_list, ","); | 1935 StringTokenizer t(allowed_list, ","); |
| 1935 while (t.GetNext()) { | 1936 while (t.GetNext()) { |
| 1936 if (t.token() == host) | 1937 if (t.token() == host) |
| 1937 return true; | 1938 return true; |
| 1938 } | 1939 } |
| 1939 } | 1940 } |
| 1940 | 1941 |
| 1941 if (!extension) | 1942 if (!extension) |
| 1942 return false; | 1943 return false; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2054 io_thread_application_locale_ = locale; | 2055 io_thread_application_locale_ = locale; |
| 2055 } | 2056 } |
| 2056 | 2057 |
| 2057 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( | 2058 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( |
| 2058 const std::string& locale) { | 2059 const std::string& locale) { |
| 2059 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2060 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 2060 io_thread_application_locale_ = locale; | 2061 io_thread_application_locale_ = locale; |
| 2061 } | 2062 } |
| 2062 | 2063 |
| 2063 } // namespace chrome | 2064 } // namespace chrome |
| OLD | NEW |