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

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

Issue 6995013: More progress towards removing content settings code from the content layer. We can't use Cookie... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments and sync Created 9 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/app/breakpad_mac.h" 8 #include "chrome/app/breakpad_mac.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/character_encoding.h" 10 #include "chrome/browser/character_encoding.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" 22 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h"
23 #include "chrome/browser/renderer_host/text_input_client_message_filter.h" 23 #include "chrome/browser/renderer_host/text_input_client_message_filter.h"
24 #include "chrome/browser/search_engines/search_provider_install_state_message_fi lter.h" 24 #include "chrome/browser/search_engines/search_provider_install_state_message_fi lter.h"
25 #include "chrome/browser/spellcheck_message_filter.h" 25 #include "chrome/browser/spellcheck_message_filter.h"
26 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" 26 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
27 #include "chrome/common/child_process_logging.h" 27 #include "chrome/common/child_process_logging.h"
28 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
30 #include "content/browser/renderer_host/browser_render_process_host.h" 30 #include "content/browser/renderer_host/browser_render_process_host.h"
31 #include "content/browser/renderer_host/render_view_host.h" 31 #include "content/browser/renderer_host/render_view_host.h"
32 #include "content/browser/renderer_host/render_view_host_notification_task.h"
32 #include "content/browser/resource_context.h" 33 #include "content/browser/resource_context.h"
33 #include "content/browser/tab_contents/tab_contents.h" 34 #include "content/browser/tab_contents/tab_contents.h"
34 #include "content/browser/worker_host/worker_process_host.h" 35 #include "content/browser/worker_host/worker_process_host.h"
36 #include "net/base/cookie_monster.h"
37 #include "net/base/cookie_options.h"
38 #include "net/base/static_cookie_policy.h"
35 39
36 #if defined(OS_LINUX) 40 #if defined(OS_LINUX)
37 #include "base/linux_util.h" 41 #include "base/linux_util.h"
38 #include "chrome/browser/crash_handler_host_linux.h" 42 #include "chrome/browser/crash_handler_host_linux.h"
39 #endif // OS_LINUX 43 #endif // OS_LINUX
40 44
41 namespace chrome { 45 namespace chrome {
42 46
43 void ChromeContentBrowserClient::RenderViewHostCreated( 47 void ChromeContentBrowserClient::RenderViewHostCreated(
44 RenderViewHost* render_view_host) { 48 RenderViewHost* render_view_host) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 if (!g_browser_process->safe_browsing_detection_service()) 180 if (!g_browser_process->safe_browsing_detection_service())
177 command_line->AppendSwitch(switches::kDisableClientSidePhishingDetection); 181 command_line->AppendSwitch(switches::kDisableClientSidePhishingDetection);
178 } 182 }
179 } 183 }
180 184
181 std::string ChromeContentBrowserClient::GetApplicationLocale() { 185 std::string ChromeContentBrowserClient::GetApplicationLocale() {
182 return g_browser_process->GetApplicationLocale(); 186 return g_browser_process->GetApplicationLocale();
183 } 187 }
184 188
185 bool ChromeContentBrowserClient::AllowAppCache( 189 bool ChromeContentBrowserClient::AllowAppCache(
186 const GURL& manifest_url, const content::ResourceContext* context) { 190 const GURL& manifest_url, const content::ResourceContext& context) {
187 ContentSetting setting = context->host_content_settings_map()-> 191 ContentSetting setting = context.host_content_settings_map()->
188 GetContentSetting(manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); 192 GetContentSetting(manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, "");
189 DCHECK(setting != CONTENT_SETTING_DEFAULT); 193 DCHECK(setting != CONTENT_SETTING_DEFAULT);
190 return setting != CONTENT_SETTING_BLOCK; 194 return setting != CONTENT_SETTING_BLOCK;
191 } 195 }
192 196
197 bool ChromeContentBrowserClient::AllowGetCookie(
198 const GURL& url,
199 const GURL& first_party,
200 const net::CookieList& cookie_list,
201 const content::ResourceContext& context,
202 int render_process_id,
203 int render_view_id) {
204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
205 bool allow = true;
206 if (context.host_content_settings_map()->BlockThirdPartyCookies()) {
207 bool strict = CommandLine::ForCurrentProcess()->HasSwitch(
208 switches::kBlockReadingThirdPartyCookies);
209 net::StaticCookiePolicy policy(strict ?
210 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES :
211 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
212 int rv = policy.CanGetCookies(url, first_party);
213 DCHECK_NE(net::ERR_IO_PENDING, rv);
214 if (rv != net::OK)
215 allow = false;
216 }
217
218 if (allow) {
219 ContentSetting setting = context.host_content_settings_map()->
220 GetContentSetting(url, CONTENT_SETTINGS_TYPE_COOKIES, "");
221 allow = setting == CONTENT_SETTING_ALLOW ||
222 setting == CONTENT_SETTING_SESSION_ONLY;
223 }
224
225 CallRenderViewHostContentSettingsDelegate(
226 render_process_id, render_view_id,
227 &RenderViewHostDelegate::ContentSettings::OnCookiesRead,
228 url, cookie_list, !allow);
229 return allow;
230 }
231
232 bool ChromeContentBrowserClient::AllowSetCookie(
233 const GURL& url,
234 const GURL& first_party,
235 const std::string& cookie_line,
236 const content::ResourceContext& context,
237 int render_process_id,
238 int render_view_id,
239 net::CookieOptions* options) {
240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
241 bool allow = true;
242 if (context.host_content_settings_map()->BlockThirdPartyCookies()) {
243 bool strict = CommandLine::ForCurrentProcess()->HasSwitch(
244 switches::kBlockReadingThirdPartyCookies);
245 net::StaticCookiePolicy policy(strict ?
246 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES :
247 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
248 int rv = policy.CanSetCookie(url, first_party, cookie_line);
249 if (rv != net::OK)
250 allow = false;
251 }
252
253 if (allow) {
254 ContentSetting setting = context.host_content_settings_map()->
255 GetContentSetting(url, CONTENT_SETTINGS_TYPE_COOKIES, "");
256
257 if (setting == CONTENT_SETTING_SESSION_ONLY)
258 options->set_force_session();
259
260 allow = setting == CONTENT_SETTING_ALLOW ||
261 setting == CONTENT_SETTING_SESSION_ONLY;
262 }
263
264 CallRenderViewHostContentSettingsDelegate(
265 render_process_id, render_view_id,
266 &RenderViewHostDelegate::ContentSettings::OnCookieChanged,
267 url, cookie_line, *options, !allow);
268 return allow;
269 }
270
193 #if defined(OS_LINUX) 271 #if defined(OS_LINUX)
194 int ChromeContentBrowserClient::GetCrashSignalFD( 272 int ChromeContentBrowserClient::GetCrashSignalFD(
195 const std::string& process_type) { 273 const std::string& process_type) {
196 if (process_type == switches::kRendererProcess) 274 if (process_type == switches::kRendererProcess)
197 return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); 275 return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
198 276
199 if (process_type == switches::kPluginProcess) 277 if (process_type == switches::kPluginProcess)
200 return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); 278 return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
201 279
202 if (process_type == switches::kPpapiPluginProcess) 280 if (process_type == switches::kPpapiPluginProcess)
203 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); 281 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
204 282
205 if (process_type == switches::kGpuProcess) 283 if (process_type == switches::kGpuProcess)
206 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); 284 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
207 285
208 return -1; 286 return -1;
209 } 287 }
210 #endif 288 #endif
211 289
212 } // namespace chrome 290 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | chrome/browser/download/download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698