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

Side by Side Diff: chrome/renderer/chrome_render_thread_observer.cc

Issue 2048503002: Convert visitedlink to use mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@message-mojom-magic
Patch Set: clang format Created 4 years, 3 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
« no previous file with comments | « chrome/renderer/chrome_render_thread_observer.h ('k') | components/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/chrome_render_thread_observer.h" 5 #include "chrome/renderer/chrome_render_thread_observer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <memory> 10 #include <memory>
(...skipping 19 matching lines...) Expand all
30 #include "chrome/common/child_process_logging.h" 30 #include "chrome/common/child_process_logging.h"
31 #include "chrome/common/chrome_paths.h" 31 #include "chrome/common/chrome_paths.h"
32 #include "chrome/common/media/media_resource_provider.h" 32 #include "chrome/common/media/media_resource_provider.h"
33 #include "chrome/common/net/net_resource_provider.h" 33 #include "chrome/common/net/net_resource_provider.h"
34 #include "chrome/common/render_messages.h" 34 #include "chrome/common/render_messages.h"
35 #include "chrome/common/resource_usage_reporter.mojom.h" 35 #include "chrome/common/resource_usage_reporter.mojom.h"
36 #include "chrome/common/resource_usage_reporter_type_converters.h" 36 #include "chrome/common/resource_usage_reporter_type_converters.h"
37 #include "chrome/common/url_constants.h" 37 #include "chrome/common/url_constants.h"
38 #include "chrome/renderer/content_settings_observer.h" 38 #include "chrome/renderer/content_settings_observer.h"
39 #include "chrome/renderer/security_filter_peer.h" 39 #include "chrome/renderer/security_filter_peer.h"
40 #include "components/visitedlink/renderer/visitedlink_slave.h"
40 #include "content/public/child/resource_dispatcher_delegate.h" 41 #include "content/public/child/resource_dispatcher_delegate.h"
41 #include "content/public/renderer/render_thread.h" 42 #include "content/public/renderer/render_thread.h"
42 #include "content/public/renderer/render_view.h" 43 #include "content/public/renderer/render_view.h"
43 #include "content/public/renderer/render_view_visitor.h" 44 #include "content/public/renderer/render_view_visitor.h"
44 #include "media/base/media_resources.h" 45 #include "media/base/media_resources.h"
45 #include "mojo/public/cpp/bindings/strong_binding.h" 46 #include "mojo/public/cpp/bindings/strong_binding.h"
46 #include "net/base/net_errors.h" 47 #include "net/base/net_errors.h"
47 #include "net/base/net_module.h" 48 #include "net/base/net_module.h"
48 #include "services/shell/public/cpp/interface_registry.h" 49 #include "services/shell/public/cpp/interface_registry.h"
49 #include "third_party/WebKit/public/web/WebCache.h" 50 #include "third_party/WebKit/public/web/WebCache.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 mojo::InterfaceRequest<mojom::ResourceUsageReporter> request) { 225 mojo::InterfaceRequest<mojom::ResourceUsageReporter> request) {
225 mojo::MakeStrongBinding(base::MakeUnique<ResourceUsageReporterImpl>(observer), 226 mojo::MakeStrongBinding(base::MakeUnique<ResourceUsageReporterImpl>(observer),
226 std::move(request)); 227 std::move(request));
227 } 228 }
228 229
229 } // namespace 230 } // namespace
230 231
231 bool ChromeRenderThreadObserver::is_incognito_process_ = false; 232 bool ChromeRenderThreadObserver::is_incognito_process_ = false;
232 233
233 ChromeRenderThreadObserver::ChromeRenderThreadObserver() 234 ChromeRenderThreadObserver::ChromeRenderThreadObserver()
234 : field_trial_syncer_(this), weak_factory_(this) { 235 : field_trial_syncer_(this),
236 visited_link_slave_(new visitedlink::VisitedLinkSlave),
237 weak_factory_(this) {
235 const base::CommandLine& command_line = 238 const base::CommandLine& command_line =
236 *base::CommandLine::ForCurrentProcess(); 239 *base::CommandLine::ForCurrentProcess();
237 240
238 RenderThread* thread = RenderThread::Get(); 241 RenderThread* thread = RenderThread::Get();
239 resource_delegate_.reset(new RendererResourceDelegate()); 242 resource_delegate_.reset(new RendererResourceDelegate());
240 thread->SetResourceDispatcherDelegate(resource_delegate_.get()); 243 thread->SetResourceDispatcherDelegate(resource_delegate_.get());
241 244
242 thread->GetInterfaceRegistry()->AddInterface( 245 thread->GetInterfaceRegistry()->AddInterface(
243 base::Bind(CreateResourceUsageReporter, weak_factory_.GetWeakPtr())); 246 base::Bind(CreateResourceUsageReporter, weak_factory_.GetWeakPtr()));
244 247
245 // Configure modules that need access to resources. 248 // Configure modules that need access to resources.
246 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); 249 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider);
247 media::SetLocalizedStringProvider( 250 media::SetLocalizedStringProvider(
248 chrome_common_media::LocalizedStringProvider); 251 chrome_common_media::LocalizedStringProvider);
249 252
250 field_trial_syncer_.InitFieldTrialObserving(command_line); 253 field_trial_syncer_.InitFieldTrialObserving(command_line);
251 254
252 // chrome-native: is a scheme used for placeholder navigations that allow 255 // chrome-native: is a scheme used for placeholder navigations that allow
253 // UIs to be drawn with platform native widgets instead of HTML. These pages 256 // UIs to be drawn with platform native widgets instead of HTML. These pages
254 // should not be accessible, and should also be treated as empty documents 257 // should not be accessible, and should also be treated as empty documents
255 // that can commit synchronously. No code should be runnable in these pages, 258 // that can commit synchronously. No code should be runnable in these pages,
256 // so it should not need to access anything nor should it allow javascript 259 // so it should not need to access anything nor should it allow javascript
257 // URLs since it should never be visible to the user. 260 // URLs since it should never be visible to the user.
258 WebString native_scheme(base::ASCIIToUTF16(chrome::kChromeNativeScheme)); 261 WebString native_scheme(base::ASCIIToUTF16(chrome::kChromeNativeScheme));
259 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(native_scheme); 262 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(native_scheme);
260 WebSecurityPolicy::registerURLSchemeAsEmptyDocument(native_scheme); 263 WebSecurityPolicy::registerURLSchemeAsEmptyDocument(native_scheme);
261 WebSecurityPolicy::registerURLSchemeAsNoAccess(native_scheme); 264 WebSecurityPolicy::registerURLSchemeAsNoAccess(native_scheme);
262 WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs( 265 WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs(
263 native_scheme); 266 native_scheme);
267
268 thread->GetInterfaceRegistry()->AddInterface(
269 visited_link_slave_->GetBindCallback());
264 } 270 }
265 271
266 ChromeRenderThreadObserver::~ChromeRenderThreadObserver() {} 272 ChromeRenderThreadObserver::~ChromeRenderThreadObserver() {}
267 273
268 bool ChromeRenderThreadObserver::OnControlMessageReceived( 274 bool ChromeRenderThreadObserver::OnControlMessageReceived(
269 const IPC::Message& message) { 275 const IPC::Message& message) {
270 bool handled = true; 276 bool handled = true;
271 IPC_BEGIN_MESSAGE_MAP(ChromeRenderThreadObserver, message) 277 IPC_BEGIN_MESSAGE_MAP(ChromeRenderThreadObserver, message)
272 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsIncognitoProcess, 278 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsIncognitoProcess,
273 OnSetIsIncognitoProcess) 279 OnSetIsIncognitoProcess)
274 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup) 280 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup)
275 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetContentSettingRules, 281 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetContentSettingRules,
276 OnSetContentSettingRules) 282 OnSetContentSettingRules)
277 IPC_MESSAGE_UNHANDLED(handled = false) 283 IPC_MESSAGE_UNHANDLED(handled = false)
278 IPC_END_MESSAGE_MAP() 284 IPC_END_MESSAGE_MAP()
279 return handled; 285 return handled;
280 } 286 }
281 287
288 void ChromeRenderThreadObserver::OnRenderProcessShutdown() {
289 visited_link_slave_.reset();
290 }
291
282 void ChromeRenderThreadObserver::OnFieldTrialGroupFinalized( 292 void ChromeRenderThreadObserver::OnFieldTrialGroupFinalized(
283 const std::string& trial_name, 293 const std::string& trial_name,
284 const std::string& group_name) { 294 const std::string& group_name) {
285 content::RenderThread::Get()->Send( 295 content::RenderThread::Get()->Send(
286 new ChromeViewHostMsg_FieldTrialActivated(trial_name)); 296 new ChromeViewHostMsg_FieldTrialActivated(trial_name));
287 } 297 }
288 298
289 void ChromeRenderThreadObserver::OnSetIsIncognitoProcess( 299 void ChromeRenderThreadObserver::OnSetIsIncognitoProcess(
290 bool is_incognito_process) { 300 bool is_incognito_process) {
291 is_incognito_process_ = is_incognito_process; 301 is_incognito_process_ = is_incognito_process;
292 } 302 }
293 303
294 void ChromeRenderThreadObserver::OnSetContentSettingRules( 304 void ChromeRenderThreadObserver::OnSetContentSettingRules(
295 const RendererContentSettingRules& rules) { 305 const RendererContentSettingRules& rules) {
296 content_setting_rules_ = rules; 306 content_setting_rules_ = rules;
297 } 307 }
298 308
299 void ChromeRenderThreadObserver::OnSetFieldTrialGroup( 309 void ChromeRenderThreadObserver::OnSetFieldTrialGroup(
300 const std::string& trial_name, 310 const std::string& trial_name,
301 const std::string& group_name) { 311 const std::string& group_name) {
302 field_trial_syncer_.OnSetFieldTrialGroup(trial_name, group_name); 312 field_trial_syncer_.OnSetFieldTrialGroup(trial_name, group_name);
303 } 313 }
304 314
305 const RendererContentSettingRules* 315 const RendererContentSettingRules*
306 ChromeRenderThreadObserver::content_setting_rules() const { 316 ChromeRenderThreadObserver::content_setting_rules() const {
307 return &content_setting_rules_; 317 return &content_setting_rules_;
308 } 318 }
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_thread_observer.h ('k') | components/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698