Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

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

Powered by Google App Engine
This is Rietveld 408576698