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

Side by Side Diff: chrome/browser/renderer_host/browser_render_process_host.cc

Issue 6773006: Add enableReferrers and enableHyperlinkAuditing to contentSettings.misc API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 9 years, 8 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 // Represents the browser side of the browser <--> renderer communication 5 // Represents the browser side of the browser <--> renderer communication
6 // channel. There will be one RenderProcessHost per renderer process. 6 // channel. There will be one RenderProcessHost per renderer process.
7 7
8 #include "chrome/browser/renderer_host/browser_render_process_host.h" 8 #include "chrome/browser/renderer_host/browser_render_process_host.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 278
279 BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile) 279 BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile)
280 : RenderProcessHost(profile), 280 : RenderProcessHost(profile),
281 visible_widgets_(0), 281 visible_widgets_(0),
282 backgrounded_(true), 282 backgrounded_(true),
283 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( 283 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_(
284 base::TimeDelta::FromSeconds(5), 284 base::TimeDelta::FromSeconds(5),
285 this, &BrowserRenderProcessHost::ClearTransportDIBCache)), 285 this, &BrowserRenderProcessHost::ClearTransportDIBCache)),
286 accessibility_enabled_(false), 286 accessibility_enabled_(false),
287 extension_process_(false), 287 extension_process_(false),
288 resource_message_filter_(NULL),
288 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 289 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
289 widget_helper_ = new RenderWidgetHelper(); 290 widget_helper_ = new RenderWidgetHelper();
290 291
291 registrar_.Add(this, NotificationType::USER_SCRIPTS_UPDATED, 292 registrar_.Add(this, NotificationType::USER_SCRIPTS_UPDATED,
292 Source<Profile>(profile->GetOriginalProfile())); 293 Source<Profile>(profile->GetOriginalProfile()));
293 registrar_.Add(this, NotificationType::EXTENSION_LOADED, 294 registrar_.Add(this, NotificationType::EXTENSION_LOADED,
294 Source<Profile>(profile->GetOriginalProfile())); 295 Source<Profile>(profile->GetOriginalProfile()));
295 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, 296 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
296 Source<Profile>(profile->GetOriginalProfile())); 297 Source<Profile>(profile->GetOriginalProfile()));
297 registrar_.Add(this, NotificationType::SPELLCHECK_HOST_REINITIALIZED, 298 registrar_.Add(this, NotificationType::SPELLCHECK_HOST_REINITIALIZED,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // for the view host which may not be sure in some cases 354 // for the view host which may not be sure in some cases
354 if (channel_.get()) 355 if (channel_.get())
355 return true; 356 return true;
356 357
357 accessibility_enabled_ = is_accessibility_enabled; 358 accessibility_enabled_ = is_accessibility_enabled;
358 359
359 // It is possible for an extension process to be reused for non-extension 360 // It is possible for an extension process to be reused for non-extension
360 // content, e.g. if an extension calls window.open. 361 // content, e.g. if an extension calls window.open.
361 extension_process_ = extension_process_ || is_extensions_process; 362 extension_process_ = extension_process_ || is_extensions_process;
362 363
364 pref_change_registrar_.Init(profile()->GetPrefs());
365
363 // run the IPC channel on the shared IO thread. 366 // run the IPC channel on the shared IO thread.
364 base::Thread* io_thread = g_browser_process->io_thread(); 367 base::Thread* io_thread = g_browser_process->io_thread();
365 368
366 CommandLine::StringType renderer_prefix; 369 CommandLine::StringType renderer_prefix;
367 #if defined(OS_POSIX) 370 #if defined(OS_POSIX)
368 // A command prefix is something prepended to the command line of the spawned 371 // A command prefix is something prepended to the command line of the spawned
369 // process. It is supported only on POSIX systems. 372 // process. It is supported only on POSIX systems.
370 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 373 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
371 renderer_prefix = 374 renderer_prefix =
372 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); 375 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 channel_->AddFilter(render_message_filter); 457 channel_->AddFilter(render_message_filter);
455 458
456 channel_->AddFilter(new ChromeRenderMessageFilter( 459 channel_->AddFilter(new ChromeRenderMessageFilter(
457 id(), 460 id(),
458 profile(), 461 profile(),
459 profile()->GetRequestContextForPossibleApp(installed_app_))); 462 profile()->GetRequestContextForPossibleApp(installed_app_)));
460 463
461 scoped_refptr<RendererURLRequestContextOverride> url_request_context_override( 464 scoped_refptr<RendererURLRequestContextOverride> url_request_context_override(
462 new RendererURLRequestContextOverride(profile(), installed_app_)); 465 new RendererURLRequestContextOverride(profile(), installed_app_));
463 466
464 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( 467 resource_message_filter_ = new ResourceMessageFilter(
465 id(), ChildProcessInfo::RENDER_PROCESS, 468 id(), ChildProcessInfo::RENDER_PROCESS,
466 g_browser_process->resource_dispatcher_host()); 469 g_browser_process->resource_dispatcher_host());
467 resource_message_filter->set_url_request_context_override( 470 resource_message_filter_->set_url_request_context_override(
468 url_request_context_override); 471 url_request_context_override);
469 channel_->AddFilter(resource_message_filter); 472 pref_change_registrar_.Add(prefs::kEnableReferrers, this);
470 473 UpdateReferrersEnabled();
474 channel_->AddFilter(resource_message_filter_);
471 channel_->AddFilter(new AudioRendererHost()); 475 channel_->AddFilter(new AudioRendererHost());
472 channel_->AddFilter( 476 channel_->AddFilter(
473 new AppCacheDispatcherHost(profile()->GetRequestContext(), id())); 477 new AppCacheDispatcherHost(profile()->GetRequestContext(), id()));
474 channel_->AddFilter(new ClipboardMessageFilter()); 478 channel_->AddFilter(new ClipboardMessageFilter());
475 channel_->AddFilter(new DOMStorageMessageFilter(id(), profile())); 479 channel_->AddFilter(new DOMStorageMessageFilter(id(), profile()));
476 channel_->AddFilter(new IndexedDBDispatcherHost(id(), profile())); 480 channel_->AddFilter(new IndexedDBDispatcherHost(id(), profile()));
477 channel_->AddFilter( 481 channel_->AddFilter(
478 GeolocationDispatcherHost::New( 482 GeolocationDispatcherHost::New(
479 id(), profile()->GetGeolocationPermissionContext())); 483 id(), profile()->GetGeolocationPermissionContext()));
480 channel_->AddFilter(new GpuMessageFilter(id())); 484 channel_->AddFilter(new GpuMessageFilter(id()));
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 while (!iter.IsAtEnd()) { 1093 while (!iter.IsAtEnd()) {
1090 iter.GetCurrentValue()->OnMessageReceived( 1094 iter.GetCurrentValue()->OnMessageReceived(
1091 ViewHostMsg_RenderViewGone(iter.GetCurrentKey(), 1095 ViewHostMsg_RenderViewGone(iter.GetCurrentKey(),
1092 static_cast<int>(status), 1096 static_cast<int>(status),
1093 exit_code)); 1097 exit_code));
1094 iter.Advance(); 1098 iter.Advance();
1095 } 1099 }
1096 1100
1097 ClearTransportDIBCache(); 1101 ClearTransportDIBCache();
1098 1102
1103 pref_change_registrar_.RemoveAll();
1104
1099 // this object is not deleted at this point and may be reused later. 1105 // this object is not deleted at this point and may be reused later.
1100 // TODO(darin): clean this up 1106 // TODO(darin): clean this up
1101 } 1107 }
1102 1108
1103 void BrowserRenderProcessHost::OnUpdatedCacheStats( 1109 void BrowserRenderProcessHost::OnUpdatedCacheStats(
1104 const WebCache::UsageStats& stats) { 1110 const WebCache::UsageStats& stats) {
1105 WebCacheManager::GetInstance()->ObserveStats(id(), stats); 1111 WebCacheManager::GetInstance()->ObserveStats(id(), stats);
1106 } 1112 }
1107 1113
1108 void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) { 1114 void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 reinterpret_cast<const Source<SpellCheckHost>*>(&source)-> 1168 reinterpret_cast<const Source<SpellCheckHost>*>(&source)->
1163 ptr()->GetLastAddedFile()); 1169 ptr()->GetLastAddedFile());
1164 break; 1170 break;
1165 } 1171 }
1166 case NotificationType::SPELLCHECK_AUTOSPELL_TOGGLED: { 1172 case NotificationType::SPELLCHECK_AUTOSPELL_TOGGLED: {
1167 PrefService* prefs = profile()->GetPrefs(); 1173 PrefService* prefs = profile()->GetPrefs();
1168 EnableAutoSpellCorrect( 1174 EnableAutoSpellCorrect(
1169 prefs->GetBoolean(prefs::kEnableAutoSpellCorrect)); 1175 prefs->GetBoolean(prefs::kEnableAutoSpellCorrect));
1170 break; 1176 break;
1171 } 1177 }
1178 case NotificationType::PREF_CHANGED: {
1179 std::string* pref = Details<std::string>(details).ptr();
1180 if (*pref == prefs::kEnableReferrers) {
1181 UpdateReferrersEnabled();
1182 } else {
1183 NOTREACHED();
1184 }
1185 break;
1186 }
1172 default: { 1187 default: {
1173 NOTREACHED(); 1188 NOTREACHED();
1174 break; 1189 break;
1175 } 1190 }
1176 } 1191 }
1177 } 1192 }
1178 1193
1179 void BrowserRenderProcessHost::OnProcessLaunched() { 1194 void BrowserRenderProcessHost::OnProcessLaunched() {
1180 if (child_process_.get()) 1195 if (child_process_.get())
1181 child_process_->SetProcessBackgrounded(backgrounded_); 1196 child_process_->SetProcessBackgrounded(backgrounded_);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 IPC::PlatformFileForTransit file; 1326 IPC::PlatformFileForTransit file;
1312 #if defined(OS_POSIX) 1327 #if defined(OS_POSIX)
1313 file = base::FileDescriptor(model_file, false); 1328 file = base::FileDescriptor(model_file, false);
1314 #elif defined(OS_WIN) 1329 #elif defined(OS_WIN)
1315 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, 1330 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0,
1316 false, DUPLICATE_SAME_ACCESS); 1331 false, DUPLICATE_SAME_ACCESS);
1317 #endif 1332 #endif
1318 Send(new SafeBrowsingMsg_SetPhishingModel(file)); 1333 Send(new SafeBrowsingMsg_SetPhishingModel(file));
1319 } 1334 }
1320 } 1335 }
1336
1337 void BrowserRenderProcessHost::UpdateReferrersEnabled() {
1338 DCHECK(resource_message_filter_);
1339 resource_message_filter_->set_referrers_enabled(
1340 profile()->GetPrefs()->GetBoolean(prefs::kEnableReferrers));
1341 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698