| 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 <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1864 PrefService* prefs = profile->GetPrefs(); | 1864 PrefService* prefs = profile->GetPrefs(); |
| 1865 return prefs && prefs->GetBoolean(prefs::kDataSaverEnabled); | 1865 return prefs && prefs->GetBoolean(prefs::kDataSaverEnabled); |
| 1866 } | 1866 } |
| 1867 | 1867 |
| 1868 bool ChromeContentBrowserClient::AllowAppCache( | 1868 bool ChromeContentBrowserClient::AllowAppCache( |
| 1869 const GURL& manifest_url, | 1869 const GURL& manifest_url, |
| 1870 const GURL& first_party, | 1870 const GURL& first_party, |
| 1871 content::ResourceContext* context) { | 1871 content::ResourceContext* context) { |
| 1872 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1872 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1873 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 1873 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
| 1874 return io_data->GetCookieSettings()-> | 1874 return io_data->GetCookieSettings()->IsCookieAccessAllowed(manifest_url, |
| 1875 IsSettingCookieAllowed(manifest_url, first_party); | 1875 first_party); |
| 1876 } | 1876 } |
| 1877 | 1877 |
| 1878 bool ChromeContentBrowserClient::AllowServiceWorker( | 1878 bool ChromeContentBrowserClient::AllowServiceWorker( |
| 1879 const GURL& scope, | 1879 const GURL& scope, |
| 1880 const GURL& first_party_url, | 1880 const GURL& first_party_url, |
| 1881 content::ResourceContext* context, | 1881 content::ResourceContext* context, |
| 1882 const base::Callback<content::WebContents*(void)>& wc_getter) { | 1882 const base::Callback<content::WebContents*(void)>& wc_getter) { |
| 1883 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1883 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1884 | 1884 |
| 1885 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1885 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1901 content_settings::SettingInfo info; | 1901 content_settings::SettingInfo info; |
| 1902 std::unique_ptr<base::Value> value = | 1902 std::unique_ptr<base::Value> value = |
| 1903 io_data->GetHostContentSettingsMap()->GetWebsiteSetting( | 1903 io_data->GetHostContentSettingsMap()->GetWebsiteSetting( |
| 1904 first_party_url, first_party_url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 1904 first_party_url, first_party_url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
| 1905 std::string(), &info); | 1905 std::string(), &info); |
| 1906 ContentSetting setting = content_settings::ValueToContentSetting(value.get()); | 1906 ContentSetting setting = content_settings::ValueToContentSetting(value.get()); |
| 1907 bool allow_javascript = (setting == CONTENT_SETTING_ALLOW); | 1907 bool allow_javascript = (setting == CONTENT_SETTING_ALLOW); |
| 1908 | 1908 |
| 1909 // Check if cookies are allowed. | 1909 // Check if cookies are allowed. |
| 1910 bool allow_serviceworker = | 1910 bool allow_serviceworker = |
| 1911 io_data->GetCookieSettings()->IsSettingCookieAllowed(scope, | 1911 io_data->GetCookieSettings()->IsCookieAccessAllowed(scope, |
| 1912 first_party_url); | 1912 first_party_url); |
| 1913 // Record access to database for potential display in UI. | 1913 // Record access to database for potential display in UI. |
| 1914 // Only post the task if this is for a specific tab. | 1914 // Only post the task if this is for a specific tab. |
| 1915 if (!wc_getter.is_null()) { | 1915 if (!wc_getter.is_null()) { |
| 1916 BrowserThread::PostTask( | 1916 BrowserThread::PostTask( |
| 1917 BrowserThread::UI, FROM_HERE, | 1917 BrowserThread::UI, FROM_HERE, |
| 1918 base::Bind(&TabSpecificContentSettings::ServiceWorkerAccessed, | 1918 base::Bind(&TabSpecificContentSettings::ServiceWorkerAccessed, |
| 1919 wc_getter, scope, !allow_javascript, !allow_serviceworker)); | 1919 wc_getter, scope, !allow_javascript, !allow_serviceworker)); |
| 1920 } | 1920 } |
| 1921 return allow_javascript && allow_serviceworker; | 1921 return allow_javascript && allow_serviceworker; |
| 1922 } | 1922 } |
| 1923 | 1923 |
| 1924 bool ChromeContentBrowserClient::AllowGetCookie( | 1924 bool ChromeContentBrowserClient::AllowGetCookie( |
| 1925 const GURL& url, | 1925 const GURL& url, |
| 1926 const GURL& first_party, | 1926 const GURL& first_party, |
| 1927 const net::CookieList& cookie_list, | 1927 const net::CookieList& cookie_list, |
| 1928 content::ResourceContext* context, | 1928 content::ResourceContext* context, |
| 1929 int render_process_id, | 1929 int render_process_id, |
| 1930 int render_frame_id) { | 1930 int render_frame_id) { |
| 1931 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1931 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1932 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 1932 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
| 1933 bool allow = io_data->GetCookieSettings()-> | 1933 bool allow = |
| 1934 IsReadingCookieAllowed(url, first_party); | 1934 io_data->GetCookieSettings()->IsCookieAccessAllowed(url, first_party); |
| 1935 | 1935 |
| 1936 base::Callback<content::WebContents*(void)> wc_getter = | 1936 base::Callback<content::WebContents*(void)> wc_getter = |
| 1937 base::Bind(&GetWebContents, render_process_id, render_frame_id); | 1937 base::Bind(&GetWebContents, render_process_id, render_frame_id); |
| 1938 BrowserThread::PostTask( | 1938 BrowserThread::PostTask( |
| 1939 BrowserThread::UI, FROM_HERE, | 1939 BrowserThread::UI, FROM_HERE, |
| 1940 base::Bind(&TabSpecificContentSettings::CookiesRead, wc_getter, url, | 1940 base::Bind(&TabSpecificContentSettings::CookiesRead, wc_getter, url, |
| 1941 first_party, cookie_list, !allow)); | 1941 first_party, cookie_list, !allow)); |
| 1942 return allow; | 1942 return allow; |
| 1943 } | 1943 } |
| 1944 | 1944 |
| 1945 bool ChromeContentBrowserClient::AllowSetCookie( | 1945 bool ChromeContentBrowserClient::AllowSetCookie( |
| 1946 const GURL& url, | 1946 const GURL& url, |
| 1947 const GURL& first_party, | 1947 const GURL& first_party, |
| 1948 const std::string& cookie_line, | 1948 const std::string& cookie_line, |
| 1949 content::ResourceContext* context, | 1949 content::ResourceContext* context, |
| 1950 int render_process_id, | 1950 int render_process_id, |
| 1951 int render_frame_id, | 1951 int render_frame_id, |
| 1952 const net::CookieOptions& options) { | 1952 const net::CookieOptions& options) { |
| 1953 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1953 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1954 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 1954 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
| 1955 content_settings::CookieSettings* cookie_settings = | 1955 content_settings::CookieSettings* cookie_settings = |
| 1956 io_data->GetCookieSettings(); | 1956 io_data->GetCookieSettings(); |
| 1957 bool allow = cookie_settings->IsSettingCookieAllowed(url, first_party); | 1957 bool allow = cookie_settings->IsCookieAccessAllowed(url, first_party); |
| 1958 | 1958 |
| 1959 base::Callback<content::WebContents*(void)> wc_getter = | 1959 base::Callback<content::WebContents*(void)> wc_getter = |
| 1960 base::Bind(&GetWebContents, render_process_id, render_frame_id); | 1960 base::Bind(&GetWebContents, render_process_id, render_frame_id); |
| 1961 BrowserThread::PostTask( | 1961 BrowserThread::PostTask( |
| 1962 BrowserThread::UI, FROM_HERE, | 1962 BrowserThread::UI, FROM_HERE, |
| 1963 base::Bind(&TabSpecificContentSettings::CookieChanged, wc_getter, url, | 1963 base::Bind(&TabSpecificContentSettings::CookieChanged, wc_getter, url, |
| 1964 first_party, cookie_line, options, !allow)); | 1964 first_party, cookie_line, options, !allow)); |
| 1965 return allow; | 1965 return allow; |
| 1966 } | 1966 } |
| 1967 | 1967 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1980 | 1980 |
| 1981 void ChromeContentBrowserClient::AllowWorkerFileSystem( | 1981 void ChromeContentBrowserClient::AllowWorkerFileSystem( |
| 1982 const GURL& url, | 1982 const GURL& url, |
| 1983 content::ResourceContext* context, | 1983 content::ResourceContext* context, |
| 1984 const std::vector<std::pair<int, int> >& render_frames, | 1984 const std::vector<std::pair<int, int> >& render_frames, |
| 1985 base::Callback<void(bool)> callback) { | 1985 base::Callback<void(bool)> callback) { |
| 1986 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1986 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1987 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 1987 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
| 1988 content_settings::CookieSettings* cookie_settings = | 1988 content_settings::CookieSettings* cookie_settings = |
| 1989 io_data->GetCookieSettings(); | 1989 io_data->GetCookieSettings(); |
| 1990 bool allow = cookie_settings->IsSettingCookieAllowed(url, url); | 1990 bool allow = cookie_settings->IsCookieAccessAllowed(url, url); |
| 1991 | 1991 |
| 1992 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1992 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 1993 GuestPermissionRequestHelper(url, render_frames, callback, allow); | 1993 GuestPermissionRequestHelper(url, render_frames, callback, allow); |
| 1994 #else | 1994 #else |
| 1995 FileSystemAccessed(url, render_frames, callback, allow); | 1995 FileSystemAccessed(url, render_frames, callback, allow); |
| 1996 #endif | 1996 #endif |
| 1997 } | 1997 } |
| 1998 | 1998 |
| 1999 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1999 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 2000 void ChromeContentBrowserClient::GuestPermissionRequestHelper( | 2000 void ChromeContentBrowserClient::GuestPermissionRequestHelper( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2074 | 2074 |
| 2075 bool ChromeContentBrowserClient::AllowWorkerIndexedDB( | 2075 bool ChromeContentBrowserClient::AllowWorkerIndexedDB( |
| 2076 const GURL& url, | 2076 const GURL& url, |
| 2077 const base::string16& name, | 2077 const base::string16& name, |
| 2078 content::ResourceContext* context, | 2078 content::ResourceContext* context, |
| 2079 const std::vector<std::pair<int, int> >& render_frames) { | 2079 const std::vector<std::pair<int, int> >& render_frames) { |
| 2080 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 2080 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 2081 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 2081 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
| 2082 content_settings::CookieSettings* cookie_settings = | 2082 content_settings::CookieSettings* cookie_settings = |
| 2083 io_data->GetCookieSettings(); | 2083 io_data->GetCookieSettings(); |
| 2084 bool allow = cookie_settings->IsSettingCookieAllowed(url, url); | 2084 bool allow = cookie_settings->IsCookieAccessAllowed(url, url); |
| 2085 | 2085 |
| 2086 // Record access to IndexedDB for potential display in UI. | 2086 // Record access to IndexedDB for potential display in UI. |
| 2087 std::vector<std::pair<int, int> >::const_iterator i; | 2087 std::vector<std::pair<int, int> >::const_iterator i; |
| 2088 for (i = render_frames.begin(); i != render_frames.end(); ++i) { | 2088 for (i = render_frames.begin(); i != render_frames.end(); ++i) { |
| 2089 BrowserThread::PostTask( | 2089 BrowserThread::PostTask( |
| 2090 BrowserThread::UI, FROM_HERE, | 2090 BrowserThread::UI, FROM_HERE, |
| 2091 base::Bind(&TabSpecificContentSettings::IndexedDBAccessed, | 2091 base::Bind(&TabSpecificContentSettings::IndexedDBAccessed, |
| 2092 i->first, i->second, url, name, !allow)); | 2092 i->first, i->second, url, name, !allow)); |
| 2093 } | 2093 } |
| 2094 | 2094 |
| 2095 return allow; | 2095 return allow; |
| 2096 } | 2096 } |
| 2097 | 2097 |
| 2098 #if BUILDFLAG(ENABLE_WEBRTC) | 2098 #if BUILDFLAG(ENABLE_WEBRTC) |
| 2099 bool ChromeContentBrowserClient::AllowWebRTCIdentityCache( | 2099 bool ChromeContentBrowserClient::AllowWebRTCIdentityCache( |
| 2100 const GURL& url, | 2100 const GURL& url, |
| 2101 const GURL& first_party_url, | 2101 const GURL& first_party_url, |
| 2102 content::ResourceContext* context) { | 2102 content::ResourceContext* context) { |
| 2103 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 2103 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 2104 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 2104 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
| 2105 content_settings::CookieSettings* cookie_settings = | 2105 content_settings::CookieSettings* cookie_settings = |
| 2106 io_data->GetCookieSettings(); | 2106 io_data->GetCookieSettings(); |
| 2107 return cookie_settings->IsReadingCookieAllowed(url, first_party_url) && | 2107 return cookie_settings->IsCookieAccessAllowed(url, first_party_url); |
| 2108 cookie_settings->IsSettingCookieAllowed(url, first_party_url); | |
| 2109 } | 2108 } |
| 2110 #endif // BUILDFLAG(ENABLE_WEBRTC) | 2109 #endif // BUILDFLAG(ENABLE_WEBRTC) |
| 2111 | 2110 |
| 2112 ChromeContentBrowserClient::AllowWebBluetoothResult | 2111 ChromeContentBrowserClient::AllowWebBluetoothResult |
| 2113 ChromeContentBrowserClient::AllowWebBluetooth( | 2112 ChromeContentBrowserClient::AllowWebBluetooth( |
| 2114 content::BrowserContext* browser_context, | 2113 content::BrowserContext* browser_context, |
| 2115 const url::Origin& requesting_origin, | 2114 const url::Origin& requesting_origin, |
| 2116 const url::Origin& embedding_origin) { | 2115 const url::Origin& embedding_origin) { |
| 2117 // TODO(crbug.com/598890): Don't disable if | 2116 // TODO(crbug.com/598890): Don't disable if |
| 2118 // base::CommandLine::ForCurrentProcess()-> | 2117 // base::CommandLine::ForCurrentProcess()-> |
| (...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3401 bool ChromeContentBrowserClient::ShouldRedirectDOMStorageTaskRunner() { | 3400 bool ChromeContentBrowserClient::ShouldRedirectDOMStorageTaskRunner() { |
| 3402 return variations::GetVariationParamValue( | 3401 return variations::GetVariationParamValue( |
| 3403 "BrowserScheduler", "RedirectDOMStorageTaskRunner") == "true"; | 3402 "BrowserScheduler", "RedirectDOMStorageTaskRunner") == "true"; |
| 3404 } | 3403 } |
| 3405 | 3404 |
| 3406 bool ChromeContentBrowserClient:: | 3405 bool ChromeContentBrowserClient:: |
| 3407 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { | 3406 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { |
| 3408 return variations::GetVariationParamValue( | 3407 return variations::GetVariationParamValue( |
| 3409 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; | 3408 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; |
| 3410 } | 3409 } |
| OLD | NEW |