| 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" |
| 14 #include "chrome/common/variations/child_process_field_trial_syncer.h" | 15 #include "chrome/common/variations/child_process_field_trial_syncer.h" |
| 15 #include "components/content_settings/core/common/content_settings.h" | 16 #include "components/content_settings/core/common/content_settings.h" |
| 16 #include "content/public/renderer/render_thread_observer.h" | 17 #include "content/public/renderer/render_thread_observer.h" |
| 17 | 18 |
| 18 class GURL; | 19 class GURL; |
| 19 struct ContentSettings; | 20 struct ContentSettings; |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 class CommandLine; | 23 class CommandLine; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 class ResourceDispatcherDelegate; | 27 class ResourceDispatcherDelegate; |
| 27 } | 28 } |
| 28 | 29 |
| 29 // This class filters the incoming control messages (i.e. ones not destined for | 30 // 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 | 31 // 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 | 32 // happen. If a few messages are related, they should probably have their own |
| 32 // observer. | 33 // observer. |
| 33 class ChromeRenderThreadObserver : public content::RenderThreadObserver { | 34 class ChromeRenderThreadObserver : public content::RenderThreadObserver, |
| 35 public base::FieldTrialList::Observer { |
| 34 public: | 36 public: |
| 35 ChromeRenderThreadObserver(); | 37 ChromeRenderThreadObserver(); |
| 36 ~ChromeRenderThreadObserver() override; | 38 ~ChromeRenderThreadObserver() override; |
| 37 | 39 |
| 38 static bool is_incognito_process() { return is_incognito_process_; } | 40 static bool is_incognito_process() { return is_incognito_process_; } |
| 39 | 41 |
| 40 // Returns a pointer to the content setting rules owned by | 42 // Returns a pointer to the content setting rules owned by |
| 41 // |ChromeRenderThreadObserver|. | 43 // |ChromeRenderThreadObserver|. |
| 42 const RendererContentSettingRules* content_setting_rules() const; | 44 const RendererContentSettingRules* content_setting_rules() const; |
| 43 | 45 |
| 44 private: | 46 private: |
| 45 // Initializes field trial state change observation and notifies the browser | 47 // Initializes field trial state change observation and notifies the browser |
| 46 // of any field trials that might have already been activated. | 48 // of any field trials that might have already been activated. |
| 47 void InitFieldTrialObserving(const base::CommandLine& command_line); | 49 void InitFieldTrialObserving(const base::CommandLine& command_line); |
| 48 | 50 |
| 49 // content::RenderThreadObserver: | 51 // content::RenderThreadObserver: |
| 50 bool OnControlMessageReceived(const IPC::Message& message) override; | 52 bool OnControlMessageReceived(const IPC::Message& message) override; |
| 51 | 53 |
| 54 // base::FieldTrialList::Observer: |
| 55 void OnFieldTrialGroupFinalized(const std::string& trial_name, |
| 56 const std::string& group_name) override; |
| 57 |
| 52 void OnSetIsIncognitoProcess(bool is_incognito_process); | 58 void OnSetIsIncognitoProcess(bool is_incognito_process); |
| 53 void OnSetContentSettingsForCurrentURL( | 59 void OnSetContentSettingsForCurrentURL( |
| 54 const GURL& url, const ContentSettings& content_settings); | 60 const GURL& url, const ContentSettings& content_settings); |
| 55 void OnSetContentSettingRules(const RendererContentSettingRules& rules); | 61 void OnSetContentSettingRules(const RendererContentSettingRules& rules); |
| 56 void OnGetCacheResourceStats(); | 62 void OnGetCacheResourceStats(); |
| 57 void OnSetFieldTrialGroup(const std::string& trial_name, | 63 void OnSetFieldTrialGroup(const std::string& trial_name, |
| 58 const std::string& group_name); | 64 const std::string& group_name); |
| 59 | 65 |
| 60 static bool is_incognito_process_; | 66 static bool is_incognito_process_; |
| 61 std::unique_ptr<content::ResourceDispatcherDelegate> resource_delegate_; | 67 std::unique_ptr<content::ResourceDispatcherDelegate> resource_delegate_; |
| 62 RendererContentSettingRules content_setting_rules_; | 68 RendererContentSettingRules content_setting_rules_; |
| 63 chrome_variations::ChildProcessFieldTrialSyncer field_trial_syncer_; | 69 chrome_variations::ChildProcessFieldTrialSyncer field_trial_syncer_; |
| 64 | 70 |
| 65 base::WeakPtrFactory<ChromeRenderThreadObserver> weak_factory_; | 71 base::WeakPtrFactory<ChromeRenderThreadObserver> weak_factory_; |
| 66 | 72 |
| 67 DISALLOW_COPY_AND_ASSIGN(ChromeRenderThreadObserver); | 73 DISALLOW_COPY_AND_ASSIGN(ChromeRenderThreadObserver); |
| 68 }; | 74 }; |
| 69 | 75 |
| 70 #endif // CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_ | 76 #endif // CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_ |
| OLD | NEW |