Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: chrome/renderer/chrome_render_view_observer.h

Issue 11232068: Extract renderer-side favicon downloading code into separate helper class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 20 matching lines...) Expand all
31 } 31 }
32 32
33 namespace WebKit { 33 namespace WebKit {
34 class WebView; 34 class WebView;
35 } 35 }
36 36
37 namespace safe_browsing { 37 namespace safe_browsing {
38 class PhishingClassifierDelegate; 38 class PhishingClassifierDelegate;
39 } 39 }
40 40
41 namespace webkit_glue {
42 class MultiResolutionImageResourceFetcher;
43 }
44
45 // This class holds the Chrome specific parts of RenderView, and has the same 41 // This class holds the Chrome specific parts of RenderView, and has the same
46 // lifetime. 42 // lifetime.
47 class ChromeRenderViewObserver : public content::RenderViewObserver, 43 class ChromeRenderViewObserver : public content::RenderViewObserver,
48 public WebKit::WebPermissionClient { 44 public WebKit::WebPermissionClient {
49 public: 45 public:
50 // translate_helper can be NULL. 46 // translate_helper can be NULL.
51 ChromeRenderViewObserver( 47 ChromeRenderViewObserver(
52 content::RenderView* render_view, 48 content::RenderView* render_view,
53 ContentSettingsObserver* content_settings, 49 ContentSettingsObserver* content_settings,
54 ChromeRenderProcessObserver* chrome_render_process_observer, 50 ChromeRenderProcessObserver* chrome_render_process_observer,
55 extensions::Dispatcher* extension_dispatcher, 51 extensions::Dispatcher* extension_dispatcher,
56 TranslateHelper* translate_helper); 52 TranslateHelper* translate_helper);
57 virtual ~ChromeRenderViewObserver(); 53 virtual ~ChromeRenderViewObserver();
58 54
59 private: 55 private:
60 // Holds the information received in OnWebUIJavaScript for later use 56 // Holds the information received in OnWebUIJavaScript for later use
61 // to call EvaluateScript() to preload javascript for WebUI tests. 57 // to call EvaluateScript() to preload javascript for WebUI tests.
62 struct WebUIJavaScript { 58 struct WebUIJavaScript {
63 string16 frame_xpath; 59 string16 frame_xpath;
64 string16 jscript; 60 string16 jscript;
65 int id; 61 int id;
66 bool notify_result; 62 bool notify_result;
67 }; 63 };
68 64
69 // RenderViewObserver implementation. 65 // RenderViewObserver implementation.
70 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 66 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
71 virtual void DidStartLoading() OVERRIDE; 67 virtual void DidStartLoading() OVERRIDE;
72 virtual void DidStopLoading() OVERRIDE; 68 virtual void DidStopLoading() OVERRIDE;
73 virtual void DidChangeIcon(WebKit::WebFrame* frame,
74 WebKit::WebIconURL::Type icon_type) OVERRIDE;
75 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame, 69 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame,
76 bool is_new_navigation) OVERRIDE; 70 bool is_new_navigation) OVERRIDE;
77 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; 71 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE;
78 virtual void DidHandleTouchEvent(const WebKit::WebTouchEvent& event) OVERRIDE; 72 virtual void DidHandleTouchEvent(const WebKit::WebTouchEvent& event) OVERRIDE;
79 73
80 // WebKit::WebPermissionClient implementation. 74 // WebKit::WebPermissionClient implementation.
81 virtual bool allowDatabase(WebKit::WebFrame* frame, 75 virtual bool allowDatabase(WebKit::WebFrame* frame,
82 const WebKit::WebString& name, 76 const WebKit::WebString& name,
83 const WebKit::WebString& display_name, 77 const WebKit::WebString& display_name,
84 unsigned long estimated_size) OVERRIDE; 78 unsigned long estimated_size) OVERRIDE;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 124
131 void OnWebUIJavaScript(const string16& frame_xpath, 125 void OnWebUIJavaScript(const string16& frame_xpath,
132 const string16& jscript, 126 const string16& jscript,
133 int id, 127 int id,
134 bool notify_result); 128 bool notify_result);
135 void OnCaptureSnapshot(); 129 void OnCaptureSnapshot();
136 void OnHandleMessageFromExternalHost(const std::string& message, 130 void OnHandleMessageFromExternalHost(const std::string& message,
137 const std::string& origin, 131 const std::string& origin,
138 const std::string& target); 132 const std::string& target);
139 void OnJavaScriptStressTestControl(int cmd, int param); 133 void OnJavaScriptStressTestControl(int cmd, int param);
140 void OnDownloadFavicon(int id, const GURL& image_url, int image_size);
141 void OnSetIsPrerendering(bool is_prerendering); 134 void OnSetIsPrerendering(bool is_prerendering);
142 void OnSetAllowDisplayingInsecureContent(bool allow); 135 void OnSetAllowDisplayingInsecureContent(bool allow);
143 void OnSetAllowRunningInsecureContent(bool allow); 136 void OnSetAllowRunningInsecureContent(bool allow);
144 void OnSetClientSidePhishingDetection(bool enable_phishing_detection); 137 void OnSetClientSidePhishingDetection(bool enable_phishing_detection);
145 void OnSetVisuallyDeemphasized(bool deemphasized); 138 void OnSetVisuallyDeemphasized(bool deemphasized);
146 void OnStartFrameSniffer(const string16& frame_name); 139 void OnStartFrameSniffer(const string16& frame_name);
147 void OnGetFPS(); 140 void OnGetFPS();
148 void OnAddStrictSecurityHost(const std::string& host); 141 void OnAddStrictSecurityHost(const std::string& host);
149 142
150 void CapturePageInfoLater(bool preliminary_capture, base::TimeDelta delay); 143 void CapturePageInfoLater(bool preliminary_capture, base::TimeDelta delay);
151 144
152 // Captures the thumbnail and text contents for indexing for the given load 145 // Captures the thumbnail and text contents for indexing for the given load
153 // ID. Kicks off analysis of the captured text. 146 // ID. Kicks off analysis of the captured text.
154 void CapturePageInfo(bool preliminary_capture); 147 void CapturePageInfo(bool preliminary_capture);
155 148
156 // Retrieves the text from the given frame contents, the page text up to the 149 // Retrieves the text from the given frame contents, the page text up to the
157 // maximum amount kMaxIndexChars will be placed into the given buffer. 150 // maximum amount kMaxIndexChars will be placed into the given buffer.
158 void CaptureText(WebKit::WebFrame* frame, string16* contents); 151 void CaptureText(WebKit::WebFrame* frame, string16* contents);
159 152
160 // Capture a snapshot of a view. This is used to allow an extension 153 // Capture a snapshot of a view. This is used to allow an extension
161 // to get a snapshot of a tab using chrome.tabs.captureVisibleTab(). 154 // to get a snapshot of a tab using chrome.tabs.captureVisibleTab().
162 bool CaptureSnapshot(WebKit::WebView* view, SkBitmap* snapshot); 155 bool CaptureSnapshot(WebKit::WebView* view, SkBitmap* snapshot);
163 156
164 ExternalHostBindings* GetExternalHostBindings(); 157 ExternalHostBindings* GetExternalHostBindings();
165 158
166 // This callback is triggered when DownloadFavicon completes, either
167 // succesfully or with a failure. See DownloadFavicon for more
168 // details.
169 void DidDownloadFavicon(
170 int requested_size,
171 webkit_glue::MultiResolutionImageResourceFetcher* fetcher,
172 const std::vector<SkBitmap>& images);
173
174 // Requests to download a favicon image. When done, the RenderView
175 // is notified by way of DidDownloadFavicon. Returns true if the
176 // request was successfully started, false otherwise. id is used to
177 // uniquely identify the request and passed back to the
178 // DidDownloadFavicon method. If the image has multiple frames, the
179 // frame whose size is image_size is returned. If the image doesn't
180 // have a frame at the specified size, the first is returned.
181 bool DownloadFavicon(int id, const GURL& image_url, int image_size);
182
183 // Decodes a data: URL image or returns an empty image in case of failure.
184 SkBitmap ImageFromDataUrl(const GURL&) const;
185
186 // Determines if a host is in the strict security host set. 159 // Determines if a host is in the strict security host set.
187 bool IsStrictSecurityHost(const std::string& host); 160 bool IsStrictSecurityHost(const std::string& host);
188 161
189 // If |origin| corresponds to an installed extension, returns that extension. 162 // If |origin| corresponds to an installed extension, returns that extension.
190 // Otherwise returns NULL. 163 // Otherwise returns NULL.
191 const extensions::Extension* GetExtension( 164 const extensions::Extension* GetExtension(
192 const WebKit::WebSecurityOrigin& origin) const; 165 const WebKit::WebSecurityOrigin& origin) const;
193 166
194 // Save the JavaScript to preload if a ViewMsg_WebUIJavaScript is received. 167 // Save the JavaScript to preload if a ViewMsg_WebUIJavaScript is received.
195 scoped_ptr<WebUIJavaScript> webui_javascript_; 168 scoped_ptr<WebUIJavaScript> webui_javascript_;
(...skipping 16 matching lines...) Expand all
212 GURL last_indexed_url_; 185 GURL last_indexed_url_;
213 186
214 // Insecure content may be permitted for the duration of this render view. 187 // Insecure content may be permitted for the duration of this render view.
215 bool allow_displaying_insecure_content_; 188 bool allow_displaying_insecure_content_;
216 bool allow_running_insecure_content_; 189 bool allow_running_insecure_content_;
217 std::set<std::string> strict_security_hosts_; 190 std::set<std::string> strict_security_hosts_;
218 191
219 // External host exposed through automation controller. 192 // External host exposed through automation controller.
220 scoped_ptr<ExternalHostBindings> external_host_bindings_; 193 scoped_ptr<ExternalHostBindings> external_host_bindings_;
221 194
222 typedef std::vector<
223 linked_ptr<webkit_glue::MultiResolutionImageResourceFetcher> >
224 ImageResourceFetcherList;
225
226 // ImageResourceFetchers schedule via DownloadImage.
227 ImageResourceFetcherList image_fetchers_;
228
229 // A color page overlay when visually de-emaphasized. 195 // A color page overlay when visually de-emaphasized.
230 scoped_ptr<WebViewColorOverlay> dimmed_color_overlay_; 196 scoped_ptr<WebViewColorOverlay> dimmed_color_overlay_;
231 197
232 // Used to delay calling CapturePageInfo. 198 // Used to delay calling CapturePageInfo.
233 base::Timer capture_timer_; 199 base::Timer capture_timer_;
234 200
235 DISALLOW_COPY_AND_ASSIGN(ChromeRenderViewObserver); 201 DISALLOW_COPY_AND_ASSIGN(ChromeRenderViewObserver);
236 }; 202 };
237 203
238 #endif // CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_ 204 #endif // CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698