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