OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/renderer/chrome_render_view_observer.h" | 5 #include "chrome/renderer/chrome_render_view_observer.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 case WebIconURL::TypeInvalid: | 151 case WebIconURL::TypeInvalid: |
152 return FaviconURL::INVALID_ICON; | 152 return FaviconURL::INVALID_ICON; |
153 } | 153 } |
154 return FaviconURL::INVALID_ICON; | 154 return FaviconURL::INVALID_ICON; |
155 } | 155 } |
156 | 156 |
157 ChromeRenderViewObserver::ChromeRenderViewObserver( | 157 ChromeRenderViewObserver::ChromeRenderViewObserver( |
158 RenderView* render_view, | 158 RenderView* render_view, |
159 ContentSettingsObserver* content_settings, | 159 ContentSettingsObserver* content_settings, |
160 ExtensionDispatcher* extension_dispatcher, | 160 ExtensionDispatcher* extension_dispatcher, |
161 TranslateHelper* translate_helper, | 161 TranslateHelper* translate_helper) |
162 safe_browsing::PhishingClassifierDelegate* phishing_classifier) | |
163 : RenderViewObserver(render_view), | 162 : RenderViewObserver(render_view), |
164 content_settings_(content_settings), | 163 content_settings_(content_settings), |
165 extension_dispatcher_(extension_dispatcher), | 164 extension_dispatcher_(extension_dispatcher), |
166 translate_helper_(translate_helper), | 165 translate_helper_(translate_helper), |
167 phishing_classifier_(phishing_classifier), | 166 phishing_classifier_(NULL), |
168 last_indexed_page_id_(-1), | 167 last_indexed_page_id_(-1), |
169 allow_displaying_insecure_content_(false), | 168 allow_displaying_insecure_content_(false), |
170 allow_running_insecure_content_(false), | 169 allow_running_insecure_content_(false), |
171 ALLOW_THIS_IN_INITIALIZER_LIST(page_info_method_factory_(this)) { | 170 ALLOW_THIS_IN_INITIALIZER_LIST(page_info_method_factory_(this)) { |
172 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 171 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
173 if (command_line.HasSwitch(switches::kDomAutomationController)) { | 172 if (command_line.HasSwitch(switches::kDomAutomationController)) { |
174 int old_bindings = render_view->enabled_bindings(); | 173 int old_bindings = render_view->enabled_bindings(); |
175 render_view->set_enabled_bindings( | 174 render_view->set_enabled_bindings( |
176 old_bindings |= BindingsPolicy::DOM_AUTOMATION); | 175 old_bindings |= BindingsPolicy::DOM_AUTOMATION); |
177 } | 176 } |
178 render_view->webview()->setPermissionClient(this); | 177 render_view->webview()->setPermissionClient(this); |
178 OnSetClientSidePhishingDetection(true); | |
mattm
2011/07/12 21:41:58
Should be checking the switches::kDisableClientSid
Miranda Callahan
2011/07/13 18:13:51
Done.
| |
179 } | 179 } |
180 | 180 |
181 ChromeRenderViewObserver::~ChromeRenderViewObserver() { | 181 ChromeRenderViewObserver::~ChromeRenderViewObserver() { |
182 } | 182 } |
183 | 183 |
184 bool ChromeRenderViewObserver::OnMessageReceived(const IPC::Message& message) { | 184 bool ChromeRenderViewObserver::OnMessageReceived(const IPC::Message& message) { |
185 bool handled = true; | 185 bool handled = true; |
186 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message) | 186 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message) |
187 IPC_MESSAGE_HANDLER(ViewMsg_CaptureSnapshot, OnCaptureSnapshot) | 187 IPC_MESSAGE_HANDLER(ViewMsg_CaptureSnapshot, OnCaptureSnapshot) |
188 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost, | 188 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost, |
189 OnHandleMessageFromExternalHost) | 189 OnHandleMessageFromExternalHost) |
190 IPC_MESSAGE_HANDLER(ViewMsg_JavaScriptStressTestControl, | 190 IPC_MESSAGE_HANDLER(ViewMsg_JavaScriptStressTestControl, |
191 OnJavaScriptStressTestControl) | 191 OnJavaScriptStressTestControl) |
192 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, | 192 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, |
193 OnGetAllSavableResourceLinksForCurrentPage) | 193 OnGetAllSavableResourceLinksForCurrentPage) |
194 IPC_MESSAGE_HANDLER( | 194 IPC_MESSAGE_HANDLER( |
195 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 195 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
196 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 196 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
197 IPC_MESSAGE_HANDLER(IconMsg_DownloadFavicon, OnDownloadFavicon) | 197 IPC_MESSAGE_HANDLER(IconMsg_DownloadFavicon, OnDownloadFavicon) |
198 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 198 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
199 IPC_MESSAGE_HANDLER(ViewMsg_SetAllowDisplayingInsecureContent, | 199 IPC_MESSAGE_HANDLER(ViewMsg_SetAllowDisplayingInsecureContent, |
200 OnSetAllowDisplayingInsecureContent) | 200 OnSetAllowDisplayingInsecureContent) |
201 IPC_MESSAGE_HANDLER(ViewMsg_SetAllowRunningInsecureContent, | 201 IPC_MESSAGE_HANDLER(ViewMsg_SetAllowRunningInsecureContent, |
202 OnSetAllowRunningInsecureContent) | 202 OnSetAllowRunningInsecureContent) |
203 IPC_MESSAGE_HANDLER(ViewMsg_SetClientSidePhishingDetection, | |
204 OnSetClientSidePhishingDetection) | |
203 IPC_MESSAGE_UNHANDLED(handled = false) | 205 IPC_MESSAGE_UNHANDLED(handled = false) |
204 IPC_END_MESSAGE_MAP() | 206 IPC_END_MESSAGE_MAP() |
205 | 207 |
206 // Filter only. | 208 // Filter only. |
207 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message) | 209 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message) |
208 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) | 210 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) |
209 IPC_MESSAGE_HANDLER(ViewMsg_SetIsPrerendering, OnSetIsPrerendering); | 211 IPC_MESSAGE_HANDLER(ViewMsg_SetIsPrerendering, OnSetIsPrerendering); |
210 IPC_END_MESSAGE_MAP() | 212 IPC_END_MESSAGE_MAP() |
211 | 213 |
212 return handled; | 214 return handled; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 WebFrame* main_frame = render_view()->webview()->mainFrame(); | 334 WebFrame* main_frame = render_view()->webview()->mainFrame(); |
333 if (main_frame) | 335 if (main_frame) |
334 main_frame->reload(); | 336 main_frame->reload(); |
335 } | 337 } |
336 | 338 |
337 void ChromeRenderViewObserver::OnSetAllowRunningInsecureContent(bool allow) { | 339 void ChromeRenderViewObserver::OnSetAllowRunningInsecureContent(bool allow) { |
338 allow_running_insecure_content_ = allow; | 340 allow_running_insecure_content_ = allow; |
339 OnSetAllowDisplayingInsecureContent(allow); | 341 OnSetAllowDisplayingInsecureContent(allow); |
340 } | 342 } |
341 | 343 |
344 void ChromeRenderViewObserver::OnSetClientSidePhishingDetection( | |
345 bool enable_phishing_detection) { | |
346 #if !defined(OS_CHROMEOS) || !defined(ENABLE_SAFE_BROWSING) | |
347 phishing_classifier_ = enable_phishing_detection ? | |
348 safe_browsing::PhishingClassifierDelegate::Create( | |
349 render_view(), NULL) : | |
350 NULL; | |
351 #endif | |
352 } | |
353 | |
342 void ChromeRenderViewObserver::didSerializeDataForFrame( | 354 void ChromeRenderViewObserver::didSerializeDataForFrame( |
343 const WebURL& frame_url, | 355 const WebURL& frame_url, |
344 const WebCString& data, | 356 const WebCString& data, |
345 WebPageSerializerClient::PageSerializationStatus status) { | 357 WebPageSerializerClient::PageSerializationStatus status) { |
346 Send(new ViewHostMsg_SendSerializedHtmlData( | 358 Send(new ViewHostMsg_SendSerializedHtmlData( |
347 routing_id(), | 359 routing_id(), |
348 frame_url, | 360 frame_url, |
349 data.data(), | 361 data.data(), |
350 static_cast<int32>(status))); | 362 static_cast<int32>(status))); |
351 } | 363 } |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
842 if (net::DataURL::Parse(url, &mime_type, &char_set, &data) && !data.empty()) { | 854 if (net::DataURL::Parse(url, &mime_type, &char_set, &data) && !data.empty()) { |
843 // Decode the favicon using WebKit's image decoder. | 855 // Decode the favicon using WebKit's image decoder. |
844 webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize)); | 856 webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize)); |
845 const unsigned char* src_data = | 857 const unsigned char* src_data = |
846 reinterpret_cast<const unsigned char*>(&data[0]); | 858 reinterpret_cast<const unsigned char*>(&data[0]); |
847 | 859 |
848 return decoder.Decode(src_data, data.size()); | 860 return decoder.Decode(src_data, data.size()); |
849 } | 861 } |
850 return SkBitmap(); | 862 return SkBitmap(); |
851 } | 863 } |
OLD | NEW |