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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_RENDERER_CHROME_RENDER_PROCESS_OBSERVER_H_ 6 #define CHROME_RENDERER_CHROME_RENDER_PROCESS_OBSERVER_H_ 7 8 #include <string> 9 10 #include "base/compiler_specific.h" 11 #include "base/files/file_path.h" 12 #include "base/memory/scoped_ptr.h" 13 #include "chrome/common/content_settings.h" 14 #include "content/public/renderer/render_process_observer.h" 15 16 class GURL; 17 struct ContentSettings; 18 19 namespace chrome { 20 class ChromeContentRendererClient; 21 } 22 23 namespace content { 24 class ResourceDispatcherDelegate; 25 } 26 27 // This class filters the incoming control messages (i.e. ones not destined for 28 // a RenderView) for Chrome specific messages that the content layer doesn't 29 // happen. If a few messages are related, they should probably have their own 30 // observer. 31 class ChromeRenderProcessObserver : public content::RenderProcessObserver { 32 public: 33 explicit ChromeRenderProcessObserver( 34 chrome::ChromeContentRendererClient* client); 35 virtual ~ChromeRenderProcessObserver(); 36 37 static bool is_incognito_process() { return is_incognito_process_; } 38 39 static bool extension_activity_log_enabled() { 40 return extension_activity_log_enabled_; 41 } 42 43 // Needs to be called by RenderViews in case of navigations to execute 44 // any 'clear cache' commands that were delayed until the next navigation. 45 void ExecutePendingClearCache(); 46 47 // Returns a pointer to the content setting rules owned by 48 // |ChromeRenderProcessObserver|. 49 const RendererContentSettingRules* content_setting_rules() const; 50 51 private: 52 // RenderProcessObserver implementation. 53 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; 54 virtual void WebKitInitialized() OVERRIDE; 55 56 void OnSetIsIncognitoProcess(bool is_incognito_process); 57 void OnSetExtensionActivityLogEnabled(bool extension_activity_log_enabled); 58 void OnSetContentSettingsForCurrentURL( 59 const GURL& url, const ContentSettings& content_settings); 60 void OnSetContentSettingRules(const RendererContentSettingRules& rules); 61 void OnSetCacheCapacities(size_t min_dead_capacity, 62 size_t max_dead_capacity, 63 size_t capacity); 64 // If |on_navigation| is true, the clearing is delayed until the next 65 // navigation event. 66 void OnClearCache(bool on_navigation); 67 void OnGetCacheResourceStats(); 68 void OnSetFieldTrialGroup(const std::string& fiel_trial_name, 69 const std::string& group_name); 70 void OnGetV8HeapStats(); 71 void OnPurgeMemory(); 72 void OnToggleWebKitSharedTimer(bool suspend); 73 74 static bool is_incognito_process_; 75 static bool extension_activity_log_enabled_; 76 scoped_ptr<content::ResourceDispatcherDelegate> resource_delegate_; 77 chrome::ChromeContentRendererClient* client_; 78 // If true, the web cache shall be cleared before the next navigation event. 79 bool clear_cache_pending_; 80 RendererContentSettingRules content_setting_rules_; 81 82 DISALLOW_COPY_AND_ASSIGN(ChromeRenderProcessObserver); 83 }; 84 85 #endif // CHROME_RENDERER_CHROME_RENDER_PROCESS_OBSERVER_H_ 86