| 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_VIEW_OBSERVER_H_ | 5 #ifndef CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_ |
| 6 #define CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_ | 6 #define CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class SkBitmap; | 26 class SkBitmap; |
| 27 class TranslateHelper; | 27 class TranslateHelper; |
| 28 class WebViewColorOverlay; | 28 class WebViewColorOverlay; |
| 29 class WebViewAnimatingOverlay; | 29 class WebViewAnimatingOverlay; |
| 30 | 30 |
| 31 namespace extensions { | 31 namespace extensions { |
| 32 class Dispatcher; | 32 class Dispatcher; |
| 33 class Extension; | 33 class Extension; |
| 34 } | 34 } |
| 35 | 35 |
| 36 namespace WebKit { | 36 namespace blink { |
| 37 class WebView; | 37 class WebView; |
| 38 struct WebWindowFeatures; | 38 struct WebWindowFeatures; |
| 39 } | 39 } |
| 40 | 40 |
| 41 namespace safe_browsing { | 41 namespace safe_browsing { |
| 42 class PhishingClassifierDelegate; | 42 class PhishingClassifierDelegate; |
| 43 } | 43 } |
| 44 | 44 |
| 45 // This class holds the Chrome specific parts of RenderView, and has the same | 45 // This class holds the Chrome specific parts of RenderView, and has the same |
| 46 // lifetime. | 46 // lifetime. |
| 47 class ChromeRenderViewObserver : public content::RenderViewObserver, | 47 class ChromeRenderViewObserver : public content::RenderViewObserver, |
| 48 public WebKit::WebPermissionClient { | 48 public blink::WebPermissionClient { |
| 49 public: | 49 public: |
| 50 // translate_helper can be NULL. | 50 // translate_helper can be NULL. |
| 51 ChromeRenderViewObserver( | 51 ChromeRenderViewObserver( |
| 52 content::RenderView* render_view, | 52 content::RenderView* render_view, |
| 53 ContentSettingsObserver* content_settings, | 53 ContentSettingsObserver* content_settings, |
| 54 ChromeRenderProcessObserver* chrome_render_process_observer, | 54 ChromeRenderProcessObserver* chrome_render_process_observer, |
| 55 extensions::Dispatcher* extension_dispatcher); | 55 extensions::Dispatcher* extension_dispatcher); |
| 56 virtual ~ChromeRenderViewObserver(); | 56 virtual ~ChromeRenderViewObserver(); |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 // Holds the information received in OnWebUIJavaScript for later use | 59 // Holds the information received in OnWebUIJavaScript for later use |
| 60 // to call EvaluateScript() to preload javascript for WebUI tests. | 60 // to call EvaluateScript() to preload javascript for WebUI tests. |
| 61 struct WebUIJavaScript { | 61 struct WebUIJavaScript { |
| 62 string16 frame_xpath; | 62 string16 frame_xpath; |
| 63 string16 jscript; | 63 string16 jscript; |
| 64 int id; | 64 int id; |
| 65 bool notify_result; | 65 bool notify_result; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 // RenderViewObserver implementation. | 68 // RenderViewObserver implementation. |
| 69 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 69 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 70 virtual void DidStartLoading() OVERRIDE; | 70 virtual void DidStartLoading() OVERRIDE; |
| 71 virtual void DidStopLoading() OVERRIDE; | 71 virtual void DidStopLoading() OVERRIDE; |
| 72 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame, | 72 virtual void DidCommitProvisionalLoad(blink::WebFrame* frame, |
| 73 bool is_new_navigation) OVERRIDE; | 73 bool is_new_navigation) OVERRIDE; |
| 74 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; | 74 virtual void DidClearWindowObject(blink::WebFrame* frame) OVERRIDE; |
| 75 virtual void DidHandleGestureEvent( | 75 virtual void DidHandleGestureEvent( |
| 76 const WebKit::WebGestureEvent& event) OVERRIDE; | 76 const blink::WebGestureEvent& event) OVERRIDE; |
| 77 virtual void DetailedConsoleMessageAdded(const base::string16& message, | 77 virtual void DetailedConsoleMessageAdded(const base::string16& message, |
| 78 const base::string16& source, | 78 const base::string16& source, |
| 79 const base::string16& stack_trace, | 79 const base::string16& stack_trace, |
| 80 int32 line_number, | 80 int32 line_number, |
| 81 int32 severity_level) OVERRIDE; | 81 int32 severity_level) OVERRIDE; |
| 82 | 82 |
| 83 // WebKit::WebPermissionClient implementation. | 83 // blink::WebPermissionClient implementation. |
| 84 virtual bool allowDatabase(WebKit::WebFrame* frame, | 84 virtual bool allowDatabase(blink::WebFrame* frame, |
| 85 const WebKit::WebString& name, | 85 const blink::WebString& name, |
| 86 const WebKit::WebString& display_name, | 86 const blink::WebString& display_name, |
| 87 unsigned long estimated_size); | 87 unsigned long estimated_size); |
| 88 virtual bool allowFileSystem(WebKit::WebFrame* frame); | 88 virtual bool allowFileSystem(blink::WebFrame* frame); |
| 89 virtual bool allowImage(WebKit::WebFrame* frame, | 89 virtual bool allowImage(blink::WebFrame* frame, |
| 90 bool enabled_per_settings, | 90 bool enabled_per_settings, |
| 91 const WebKit::WebURL& image_url); | 91 const blink::WebURL& image_url); |
| 92 virtual bool allowIndexedDB(WebKit::WebFrame* frame, | 92 virtual bool allowIndexedDB(blink::WebFrame* frame, |
| 93 const WebKit::WebString& name, | 93 const blink::WebString& name, |
| 94 const WebKit::WebSecurityOrigin& origin); | 94 const blink::WebSecurityOrigin& origin); |
| 95 virtual bool allowPlugins(WebKit::WebFrame* frame, | 95 virtual bool allowPlugins(blink::WebFrame* frame, |
| 96 bool enabled_per_settings); | 96 bool enabled_per_settings); |
| 97 virtual bool allowScript(WebKit::WebFrame* frame, | 97 virtual bool allowScript(blink::WebFrame* frame, |
| 98 bool enabled_per_settings); | 98 bool enabled_per_settings); |
| 99 virtual bool allowScriptFromSource(WebKit::WebFrame* frame, | 99 virtual bool allowScriptFromSource(blink::WebFrame* frame, |
| 100 bool enabled_per_settings, | 100 bool enabled_per_settings, |
| 101 const WebKit::WebURL& script_url); | 101 const blink::WebURL& script_url); |
| 102 virtual bool allowStorage(WebKit::WebFrame* frame, bool local); | 102 virtual bool allowStorage(blink::WebFrame* frame, bool local); |
| 103 virtual bool allowReadFromClipboard(WebKit::WebFrame* frame, | 103 virtual bool allowReadFromClipboard(blink::WebFrame* frame, |
| 104 bool default_value); | 104 bool default_value); |
| 105 virtual bool allowWriteToClipboard(WebKit::WebFrame* frame, | 105 virtual bool allowWriteToClipboard(blink::WebFrame* frame, |
| 106 bool default_value); | 106 bool default_value); |
| 107 virtual bool allowWebComponents(const WebKit::WebDocument&, bool); | 107 virtual bool allowWebComponents(const blink::WebDocument&, bool); |
| 108 virtual bool allowHTMLNotifications( | 108 virtual bool allowHTMLNotifications( |
| 109 const WebKit::WebDocument& document); | 109 const blink::WebDocument& document); |
| 110 virtual bool allowMutationEvents(const WebKit::WebDocument&, | 110 virtual bool allowMutationEvents(const blink::WebDocument&, |
| 111 bool default_value); | 111 bool default_value); |
| 112 virtual bool allowPushState(const WebKit::WebDocument&); | 112 virtual bool allowPushState(const blink::WebDocument&); |
| 113 virtual bool allowWebGLDebugRendererInfo(WebKit::WebFrame* frame); | 113 virtual bool allowWebGLDebugRendererInfo(blink::WebFrame* frame); |
| 114 virtual void didNotAllowPlugins(WebKit::WebFrame* frame); | 114 virtual void didNotAllowPlugins(blink::WebFrame* frame); |
| 115 virtual void didNotAllowScript(WebKit::WebFrame* frame); | 115 virtual void didNotAllowScript(blink::WebFrame* frame); |
| 116 virtual bool allowDisplayingInsecureContent( | 116 virtual bool allowDisplayingInsecureContent( |
| 117 WebKit::WebFrame* frame, | 117 blink::WebFrame* frame, |
| 118 bool allowed_per_settings, | 118 bool allowed_per_settings, |
| 119 const WebKit::WebSecurityOrigin& context, | 119 const blink::WebSecurityOrigin& context, |
| 120 const WebKit::WebURL& url); | 120 const blink::WebURL& url); |
| 121 virtual bool allowRunningInsecureContent( | 121 virtual bool allowRunningInsecureContent( |
| 122 WebKit::WebFrame* frame, | 122 blink::WebFrame* frame, |
| 123 bool allowed_per_settings, | 123 bool allowed_per_settings, |
| 124 const WebKit::WebSecurityOrigin& context, | 124 const blink::WebSecurityOrigin& context, |
| 125 const WebKit::WebURL& url); | 125 const blink::WebURL& url); |
| 126 virtual void Navigate(const GURL& url) OVERRIDE; | 126 virtual void Navigate(const GURL& url) OVERRIDE; |
| 127 | 127 |
| 128 void OnWebUIJavaScript(const string16& frame_xpath, | 128 void OnWebUIJavaScript(const string16& frame_xpath, |
| 129 const string16& jscript, | 129 const string16& jscript, |
| 130 int id, | 130 int id, |
| 131 bool notify_result); | 131 bool notify_result); |
| 132 void OnHandleMessageFromExternalHost(const std::string& message, | 132 void OnHandleMessageFromExternalHost(const std::string& message, |
| 133 const std::string& origin, | 133 const std::string& origin, |
| 134 const std::string& target); | 134 const std::string& target); |
| 135 void OnJavaScriptStressTestControl(int cmd, int param); | 135 void OnJavaScriptStressTestControl(int cmd, int param); |
| 136 void OnSetIsPrerendering(bool is_prerendering); | 136 void OnSetIsPrerendering(bool is_prerendering); |
| 137 void OnSetAllowDisplayingInsecureContent(bool allow); | 137 void OnSetAllowDisplayingInsecureContent(bool allow); |
| 138 void OnSetAllowRunningInsecureContent(bool allow); | 138 void OnSetAllowRunningInsecureContent(bool allow); |
| 139 void OnSetClientSidePhishingDetection(bool enable_phishing_detection); | 139 void OnSetClientSidePhishingDetection(bool enable_phishing_detection); |
| 140 void OnSetVisuallyDeemphasized(bool deemphasized); | 140 void OnSetVisuallyDeemphasized(bool deemphasized); |
| 141 void OnRequestThumbnailForContextNode(int thumbnail_min_area_pixels, | 141 void OnRequestThumbnailForContextNode(int thumbnail_min_area_pixels, |
| 142 gfx::Size thumbnail_max_size_pixels); | 142 gfx::Size thumbnail_max_size_pixels); |
| 143 void OnGetFPS(); | 143 void OnGetFPS(); |
| 144 void OnAddStrictSecurityHost(const std::string& host); | 144 void OnAddStrictSecurityHost(const std::string& host); |
| 145 void OnNPAPINotSupported(); | 145 void OnNPAPINotSupported(); |
| 146 #if defined(OS_ANDROID) | 146 #if defined(OS_ANDROID) |
| 147 void OnUpdateTopControlsState(content::TopControlsState constraints, | 147 void OnUpdateTopControlsState(content::TopControlsState constraints, |
| 148 content::TopControlsState current, | 148 content::TopControlsState current, |
| 149 bool animate); | 149 bool animate); |
| 150 void OnRetrieveWebappInformation(const GURL& expected_url); | 150 void OnRetrieveWebappInformation(const GURL& expected_url); |
| 151 #endif | 151 #endif |
| 152 void OnSetWindowFeatures(const WebKit::WebWindowFeatures& window_features); | 152 void OnSetWindowFeatures(const blink::WebWindowFeatures& window_features); |
| 153 | 153 |
| 154 void CapturePageInfoLater(int page_id, | 154 void CapturePageInfoLater(int page_id, |
| 155 bool preliminary_capture, | 155 bool preliminary_capture, |
| 156 base::TimeDelta delay); | 156 base::TimeDelta delay); |
| 157 | 157 |
| 158 // Captures the thumbnail and text contents for indexing for the given load | 158 // Captures the thumbnail and text contents for indexing for the given load |
| 159 // ID. Kicks off analysis of the captured text. | 159 // ID. Kicks off analysis of the captured text. |
| 160 void CapturePageInfo(int page_id, bool preliminary_capture); | 160 void CapturePageInfo(int page_id, bool preliminary_capture); |
| 161 | 161 |
| 162 // Retrieves the text from the given frame contents, the page text up to the | 162 // Retrieves the text from the given frame contents, the page text up to the |
| 163 // maximum amount kMaxIndexChars will be placed into the given buffer. | 163 // maximum amount kMaxIndexChars will be placed into the given buffer. |
| 164 void CaptureText(WebKit::WebFrame* frame, string16* contents); | 164 void CaptureText(blink::WebFrame* frame, string16* contents); |
| 165 | 165 |
| 166 ExternalHostBindings* GetExternalHostBindings(); | 166 ExternalHostBindings* GetExternalHostBindings(); |
| 167 | 167 |
| 168 // Determines if a host is in the strict security host set. | 168 // Determines if a host is in the strict security host set. |
| 169 bool IsStrictSecurityHost(const std::string& host); | 169 bool IsStrictSecurityHost(const std::string& host); |
| 170 | 170 |
| 171 // If |origin| corresponds to an installed extension, returns that extension. | 171 // If |origin| corresponds to an installed extension, returns that extension. |
| 172 // Otherwise returns NULL. | 172 // Otherwise returns NULL. |
| 173 const extensions::Extension* GetExtension( | 173 const extensions::Extension* GetExtension( |
| 174 const WebKit::WebSecurityOrigin& origin) const; | 174 const blink::WebSecurityOrigin& origin) const; |
| 175 | 175 |
| 176 // Checks if a page contains <meta http-equiv="refresh" ...> tag. | 176 // Checks if a page contains <meta http-equiv="refresh" ...> tag. |
| 177 bool HasRefreshMetaTag(WebKit::WebFrame* frame); | 177 bool HasRefreshMetaTag(blink::WebFrame* frame); |
| 178 | 178 |
| 179 // Save the JavaScript to preload if a ViewMsg_WebUIJavaScript is received. | 179 // Save the JavaScript to preload if a ViewMsg_WebUIJavaScript is received. |
| 180 scoped_ptr<WebUIJavaScript> webui_javascript_; | 180 scoped_ptr<WebUIJavaScript> webui_javascript_; |
| 181 | 181 |
| 182 // Owned by ChromeContentRendererClient and outlive us. | 182 // Owned by ChromeContentRendererClient and outlive us. |
| 183 ChromeRenderProcessObserver* chrome_render_process_observer_; | 183 ChromeRenderProcessObserver* chrome_render_process_observer_; |
| 184 extensions::Dispatcher* extension_dispatcher_; | 184 extensions::Dispatcher* extension_dispatcher_; |
| 185 | 185 |
| 186 // Have the same lifetime as us. | 186 // Have the same lifetime as us. |
| 187 ContentSettingsObserver* content_settings_; | 187 ContentSettingsObserver* content_settings_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 207 // A color page overlay when visually de-emaphasized. | 207 // A color page overlay when visually de-emaphasized. |
| 208 scoped_ptr<WebViewColorOverlay> dimmed_color_overlay_; | 208 scoped_ptr<WebViewColorOverlay> dimmed_color_overlay_; |
| 209 | 209 |
| 210 // Used to delay calling CapturePageInfo. | 210 // Used to delay calling CapturePageInfo. |
| 211 base::Timer capture_timer_; | 211 base::Timer capture_timer_; |
| 212 | 212 |
| 213 DISALLOW_COPY_AND_ASSIGN(ChromeRenderViewObserver); | 213 DISALLOW_COPY_AND_ASSIGN(ChromeRenderViewObserver); |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 #endif // CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_ | 216 #endif // CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_ |
| OLD | NEW |