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/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 12 matching lines...) Expand all Loading... |
23 #include "base/metrics/histogram.h" | 23 #include "base/metrics/histogram.h" |
24 #include "base/metrics/statistics_recorder.h" | 24 #include "base/metrics/statistics_recorder.h" |
25 #include "base/path_service.h" | 25 #include "base/path_service.h" |
26 #include "base/single_thread_task_runner.h" | 26 #include "base/single_thread_task_runner.h" |
27 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
28 #include "base/threading/platform_thread.h" | 28 #include "base/threading/platform_thread.h" |
29 #include "base/threading/thread_task_runner_handle.h" | 29 #include "base/threading/thread_task_runner_handle.h" |
30 #include "build/build_config.h" | 30 #include "build/build_config.h" |
31 #include "chrome/common/child_process_logging.h" | 31 #include "chrome/common/child_process_logging.h" |
32 #include "chrome/common/chrome_paths.h" | 32 #include "chrome/common/chrome_paths.h" |
33 #include "chrome/common/field_trial_recorder.mojom.h" | 33 #include "chrome/common/field_trial.mojom.h" |
34 #include "chrome/common/media/media_resource_provider.h" | 34 #include "chrome/common/media/media_resource_provider.h" |
35 #include "chrome/common/net/net_resource_provider.h" | 35 #include "chrome/common/net/net_resource_provider.h" |
36 #include "chrome/common/render_messages.h" | 36 #include "chrome/common/render_messages.h" |
37 #include "chrome/common/resource_usage_reporter.mojom.h" | 37 #include "chrome/common/resource_usage_reporter.mojom.h" |
38 #include "chrome/common/resource_usage_reporter_type_converters.h" | 38 #include "chrome/common/resource_usage_reporter_type_converters.h" |
39 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
40 #include "chrome/renderer/content_settings_observer.h" | 40 #include "chrome/renderer/content_settings_observer.h" |
41 #include "chrome/renderer/security_filter_peer.h" | 41 #include "chrome/renderer/security_filter_peer.h" |
42 #include "components/visitedlink/renderer/visitedlink_slave.h" | 42 #include "components/visitedlink/renderer/visitedlink_slave.h" |
43 #include "content/public/child/resource_dispatcher_delegate.h" | 43 #include "content/public/child/resource_dispatcher_delegate.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 271 |
272 thread->GetInterfaceRegistry()->AddInterface( | 272 thread->GetInterfaceRegistry()->AddInterface( |
273 visited_link_slave_->GetBindCallback()); | 273 visited_link_slave_->GetBindCallback()); |
274 } | 274 } |
275 | 275 |
276 ChromeRenderThreadObserver::~ChromeRenderThreadObserver() {} | 276 ChromeRenderThreadObserver::~ChromeRenderThreadObserver() {} |
277 | 277 |
278 void ChromeRenderThreadObserver::RegisterMojoInterfaces( | 278 void ChromeRenderThreadObserver::RegisterMojoInterfaces( |
279 content::AssociatedInterfaceRegistry* associated_interfaces) { | 279 content::AssociatedInterfaceRegistry* associated_interfaces) { |
280 associated_interfaces->AddInterface(base::Bind( | 280 associated_interfaces->AddInterface(base::Bind( |
| 281 &ChromeRenderThreadObserver::OnFieldTrialGroupSetterAssociatedRequest, |
| 282 base::Unretained(this))); |
| 283 associated_interfaces->AddInterface(base::Bind( |
281 &ChromeRenderThreadObserver::OnRendererConfigurationAssociatedRequest, | 284 &ChromeRenderThreadObserver::OnRendererConfigurationAssociatedRequest, |
282 base::Unretained(this))); | 285 base::Unretained(this))); |
283 } | 286 } |
284 | 287 |
285 void ChromeRenderThreadObserver::UnregisterMojoInterfaces( | 288 void ChromeRenderThreadObserver::UnregisterMojoInterfaces( |
286 content::AssociatedInterfaceRegistry* associated_interfaces) { | 289 content::AssociatedInterfaceRegistry* associated_interfaces) { |
287 associated_interfaces->RemoveInterface( | 290 associated_interfaces->RemoveInterface( |
| 291 chrome::mojom::FieldTrialGroupSetter::Name_); |
| 292 associated_interfaces->RemoveInterface( |
288 chrome::mojom::RendererConfiguration::Name_); | 293 chrome::mojom::RendererConfiguration::Name_); |
289 } | 294 } |
290 | 295 |
291 bool ChromeRenderThreadObserver::OnControlMessageReceived( | |
292 const IPC::Message& message) { | |
293 bool handled = true; | |
294 IPC_BEGIN_MESSAGE_MAP(ChromeRenderThreadObserver, message) | |
295 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup) | |
296 IPC_MESSAGE_UNHANDLED(handled = false) | |
297 IPC_END_MESSAGE_MAP() | |
298 return handled; | |
299 } | |
300 | |
301 void ChromeRenderThreadObserver::OnRenderProcessShutdown() { | 296 void ChromeRenderThreadObserver::OnRenderProcessShutdown() { |
302 visited_link_slave_.reset(); | 297 visited_link_slave_.reset(); |
303 | 298 |
304 // Workaround for http://crbug.com/672646 | 299 // Workaround for http://crbug.com/672646 |
| 300 field_trial_group_setter_bindings_.CloseAllBindings(); |
305 renderer_configuration_bindings_.CloseAllBindings(); | 301 renderer_configuration_bindings_.CloseAllBindings(); |
306 } | 302 } |
307 | 303 |
308 void ChromeRenderThreadObserver::OnFieldTrialGroupFinalized( | 304 void ChromeRenderThreadObserver::OnFieldTrialGroupFinalized( |
309 const std::string& trial_name, | 305 const std::string& trial_name, |
310 const std::string& group_name) { | 306 const std::string& group_name) { |
311 chrome::mojom::FieldTrialRecorderPtr field_trial_recorder; | 307 chrome::mojom::FieldTrialRecorderPtr field_trial_recorder; |
312 content::RenderThread::Get()->GetRemoteInterfaces()->GetInterface( | 308 content::RenderThread::Get()->GetRemoteInterfaces()->GetInterface( |
313 &field_trial_recorder); | 309 &field_trial_recorder); |
314 field_trial_recorder->FieldTrialActivated(trial_name); | 310 field_trial_recorder->FieldTrialActivated(trial_name); |
315 } | 311 } |
316 | 312 |
| 313 void ChromeRenderThreadObserver::SetFieldTrialGroup( |
| 314 const std::string& trial_name, |
| 315 const std::string& group_name) { |
| 316 field_trial_syncer_.OnSetFieldTrialGroup(trial_name, group_name); |
| 317 } |
| 318 |
317 void ChromeRenderThreadObserver::SetInitialConfiguration( | 319 void ChromeRenderThreadObserver::SetInitialConfiguration( |
318 bool is_incognito_process) { | 320 bool is_incognito_process) { |
319 is_incognito_process_ = is_incognito_process; | 321 is_incognito_process_ = is_incognito_process; |
320 } | 322 } |
321 | 323 |
322 void ChromeRenderThreadObserver::SetContentSettingRules( | 324 void ChromeRenderThreadObserver::SetContentSettingRules( |
323 const RendererContentSettingRules& rules) { | 325 const RendererContentSettingRules& rules) { |
324 content_setting_rules_ = rules; | 326 content_setting_rules_ = rules; |
325 } | 327 } |
326 | 328 |
| 329 void ChromeRenderThreadObserver::OnFieldTrialGroupSetterAssociatedRequest( |
| 330 chrome::mojom::FieldTrialGroupSetterAssociatedRequest request) { |
| 331 field_trial_group_setter_bindings_.AddBinding(this, std::move(request)); |
| 332 } |
| 333 |
327 void ChromeRenderThreadObserver::OnRendererConfigurationAssociatedRequest( | 334 void ChromeRenderThreadObserver::OnRendererConfigurationAssociatedRequest( |
328 chrome::mojom::RendererConfigurationAssociatedRequest request) { | 335 chrome::mojom::RendererConfigurationAssociatedRequest request) { |
329 renderer_configuration_bindings_.AddBinding(this, std::move(request)); | 336 renderer_configuration_bindings_.AddBinding(this, std::move(request)); |
330 } | 337 } |
331 | 338 |
332 void ChromeRenderThreadObserver::OnSetFieldTrialGroup( | |
333 const std::string& trial_name, | |
334 const std::string& group_name) { | |
335 field_trial_syncer_.OnSetFieldTrialGroup(trial_name, group_name); | |
336 } | |
337 | |
338 const RendererContentSettingRules* | 339 const RendererContentSettingRules* |
339 ChromeRenderThreadObserver::content_setting_rules() const { | 340 ChromeRenderThreadObserver::content_setting_rules() const { |
340 return &content_setting_rules_; | 341 return &content_setting_rules_; |
341 } | 342 } |
OLD | NEW |