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 #ifndef CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_ | 5 #ifndef CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_ |
6 #define CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_ | 6 #define CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/metrics/field_trial.h" | |
15 #include "chrome/common/renderer_configuration.mojom.h" | 14 #include "chrome/common/renderer_configuration.mojom.h" |
16 #include "components/content_settings/core/common/content_settings.h" | 15 #include "components/content_settings/core/common/content_settings.h" |
17 #include "components/variations/child_process_field_trial_syncer.h" | |
18 #include "content/public/renderer/render_thread_observer.h" | 16 #include "content/public/renderer/render_thread_observer.h" |
19 #include "mojo/public/cpp/bindings/associated_binding_set.h" | 17 #include "mojo/public/cpp/bindings/associated_binding_set.h" |
20 | 18 |
21 namespace content { | 19 namespace content { |
22 class ResourceDispatcherDelegate; | 20 class ResourceDispatcherDelegate; |
23 } | 21 } |
24 | 22 |
25 namespace visitedlink { | 23 namespace visitedlink { |
26 class VisitedLinkSlave; | 24 class VisitedLinkSlave; |
27 } | 25 } |
28 | 26 |
29 // This class filters the incoming control messages (i.e. ones not destined for | 27 // This class filters the incoming control messages (i.e. ones not destined for |
30 // a RenderView) for Chrome specific messages that the content layer doesn't | 28 // a RenderView) for Chrome specific messages that the content layer doesn't |
31 // happen. If a few messages are related, they should probably have their own | 29 // happen. If a few messages are related, they should probably have their own |
32 // observer. | 30 // observer. |
33 class ChromeRenderThreadObserver : public content::RenderThreadObserver, | 31 class ChromeRenderThreadObserver : public content::RenderThreadObserver, |
34 public base::FieldTrialList::Observer, | |
35 public chrome::mojom::RendererConfiguration { | 32 public chrome::mojom::RendererConfiguration { |
36 public: | 33 public: |
37 ChromeRenderThreadObserver(); | 34 ChromeRenderThreadObserver(); |
38 ~ChromeRenderThreadObserver() override; | 35 ~ChromeRenderThreadObserver() override; |
39 | 36 |
40 static bool is_incognito_process() { return is_incognito_process_; } | 37 static bool is_incognito_process() { return is_incognito_process_; } |
41 | 38 |
42 // Returns a pointer to the content setting rules owned by | 39 // Returns a pointer to the content setting rules owned by |
43 // |ChromeRenderThreadObserver|. | 40 // |ChromeRenderThreadObserver|. |
44 const RendererContentSettingRules* content_setting_rules() const; | 41 const RendererContentSettingRules* content_setting_rules() const; |
45 | 42 |
46 visitedlink::VisitedLinkSlave* visited_link_slave() { | 43 visitedlink::VisitedLinkSlave* visited_link_slave() { |
47 return visited_link_slave_.get(); | 44 return visited_link_slave_.get(); |
48 } | 45 } |
49 | 46 |
50 private: | 47 private: |
51 // content::RenderThreadObserver: | 48 // content::RenderThreadObserver: |
52 void RegisterMojoInterfaces( | 49 void RegisterMojoInterfaces( |
53 content::AssociatedInterfaceRegistry* associated_interfaces) override; | 50 content::AssociatedInterfaceRegistry* associated_interfaces) override; |
54 void UnregisterMojoInterfaces( | 51 void UnregisterMojoInterfaces( |
55 content::AssociatedInterfaceRegistry* associated_interfaces) override; | 52 content::AssociatedInterfaceRegistry* associated_interfaces) override; |
56 void OnRenderProcessShutdown() override; | 53 void OnRenderProcessShutdown() override; |
57 | 54 |
58 // base::FieldTrialList::Observer: | |
59 void OnFieldTrialGroupFinalized(const std::string& trial_name, | |
60 const std::string& group_name) override; | |
61 | |
62 // chrome::mojom::RendererConfiguration: | 55 // chrome::mojom::RendererConfiguration: |
63 void SetInitialConfiguration(bool is_incognito_process) override; | 56 void SetInitialConfiguration(bool is_incognito_process) override; |
64 void SetContentSettingRules( | 57 void SetContentSettingRules( |
65 const RendererContentSettingRules& rules) override; | 58 const RendererContentSettingRules& rules) override; |
66 void SetFieldTrialGroup(const std::string& trial_name, | 59 void SetFieldTrialGroup(const std::string& trial_name, |
67 const std::string& group_name) override; | 60 const std::string& group_name) override; |
68 | 61 |
69 void OnRendererConfigurationAssociatedRequest( | 62 void OnRendererConfigurationAssociatedRequest( |
70 chrome::mojom::RendererConfigurationAssociatedRequest request); | 63 chrome::mojom::RendererConfigurationAssociatedRequest request); |
71 | 64 |
72 static bool is_incognito_process_; | 65 static bool is_incognito_process_; |
73 std::unique_ptr<content::ResourceDispatcherDelegate> resource_delegate_; | 66 std::unique_ptr<content::ResourceDispatcherDelegate> resource_delegate_; |
74 RendererContentSettingRules content_setting_rules_; | 67 RendererContentSettingRules content_setting_rules_; |
75 variations::ChildProcessFieldTrialSyncer field_trial_syncer_; | |
76 | 68 |
77 std::unique_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_; | 69 std::unique_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_; |
78 | 70 |
79 mojo::AssociatedBindingSet<chrome::mojom::RendererConfiguration> | 71 mojo::AssociatedBindingSet<chrome::mojom::RendererConfiguration> |
80 renderer_configuration_bindings_; | 72 renderer_configuration_bindings_; |
81 | 73 |
82 base::WeakPtrFactory<ChromeRenderThreadObserver> weak_factory_; | 74 base::WeakPtrFactory<ChromeRenderThreadObserver> weak_factory_; |
83 | 75 |
84 DISALLOW_COPY_AND_ASSIGN(ChromeRenderThreadObserver); | 76 DISALLOW_COPY_AND_ASSIGN(ChromeRenderThreadObserver); |
85 }; | 77 }; |
86 | 78 |
87 #endif // CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_ | 79 #endif // CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_ |
OLD | NEW |