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" |
11 #include "chrome/common/chrome_constants.h" | 11 #include "chrome/common/chrome_constants.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/icon_messages.h" | 13 #include "chrome/common/icon_messages.h" |
14 #include "chrome/common/render_messages.h" | 14 #include "chrome/common/render_messages.h" |
15 #include "chrome/common/thumbnail_score.h" | 15 #include "chrome/common/thumbnail_score.h" |
16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
17 #include "chrome/renderer/about_handler.h" | 17 #include "chrome/renderer/about_handler.h" |
| 18 #include "chrome/renderer/automation/dom_automation_controller.h" |
18 #include "chrome/renderer/content_settings_observer.h" | 19 #include "chrome/renderer/content_settings_observer.h" |
19 #include "chrome/renderer/automation/dom_automation_controller.h" | |
20 #include "chrome/renderer/extensions/extension_dispatcher.h" | 20 #include "chrome/renderer/extensions/extension_dispatcher.h" |
21 #include "chrome/renderer/external_host_bindings.h" | 21 #include "chrome/renderer/external_host_bindings.h" |
| 22 #include "chrome/renderer/frame_sniffer.h" |
22 #include "chrome/renderer/prerender/prerender_helper.h" | 23 #include "chrome/renderer/prerender/prerender_helper.h" |
23 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 24 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
24 #include "chrome/renderer/translate_helper.h" | 25 #include "chrome/renderer/translate_helper.h" |
25 #include "content/common/bindings_policy.h" | 26 #include "content/common/bindings_policy.h" |
26 #include "content/common/view_messages.h" | 27 #include "content/common/view_messages.h" |
27 #include "content/renderer/content_renderer_client.h" | 28 #include "content/renderer/content_renderer_client.h" |
28 #include "googleurl/src/gurl.h" | 29 #include "googleurl/src/gurl.h" |
29 #include "net/base/data_url.h" | 30 #include "net/base/data_url.h" |
30 #include "skia/ext/image_operations.h" | 31 #include "skia/ext/image_operations.h" |
31 #include "skia/ext/platform_canvas.h" | 32 #include "skia/ext/platform_canvas.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 OnHandleMessageFromExternalHost) | 225 OnHandleMessageFromExternalHost) |
225 IPC_MESSAGE_HANDLER(ChromeViewMsg_JavaScriptStressTestControl, | 226 IPC_MESSAGE_HANDLER(ChromeViewMsg_JavaScriptStressTestControl, |
226 OnJavaScriptStressTestControl) | 227 OnJavaScriptStressTestControl) |
227 IPC_MESSAGE_HANDLER(IconMsg_DownloadFavicon, OnDownloadFavicon) | 228 IPC_MESSAGE_HANDLER(IconMsg_DownloadFavicon, OnDownloadFavicon) |
228 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowDisplayingInsecureContent, | 229 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowDisplayingInsecureContent, |
229 OnSetAllowDisplayingInsecureContent) | 230 OnSetAllowDisplayingInsecureContent) |
230 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowRunningInsecureContent, | 231 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowRunningInsecureContent, |
231 OnSetAllowRunningInsecureContent) | 232 OnSetAllowRunningInsecureContent) |
232 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection, | 233 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection, |
233 OnSetClientSidePhishingDetection) | 234 OnSetClientSidePhishingDetection) |
| 235 IPC_MESSAGE_HANDLER(ViewMsg_StartFrameSniffer, OnStartFrameSniffer) |
234 IPC_MESSAGE_UNHANDLED(handled = false) | 236 IPC_MESSAGE_UNHANDLED(handled = false) |
235 IPC_END_MESSAGE_MAP() | 237 IPC_END_MESSAGE_MAP() |
236 | 238 |
237 // Filter only. | 239 // Filter only. |
238 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message) | 240 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message) |
239 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) | 241 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) |
240 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsPrerendering, OnSetIsPrerendering); | 242 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsPrerendering, OnSetIsPrerendering); |
241 IPC_END_MESSAGE_MAP() | 243 IPC_END_MESSAGE_MAP() |
242 | 244 |
243 return handled; | 245 return handled; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 void ChromeRenderViewObserver::OnSetClientSidePhishingDetection( | 329 void ChromeRenderViewObserver::OnSetClientSidePhishingDetection( |
328 bool enable_phishing_detection) { | 330 bool enable_phishing_detection) { |
329 #if defined(ENABLE_SAFE_BROWSING) && !defined(OS_CHROMEOS) | 331 #if defined(ENABLE_SAFE_BROWSING) && !defined(OS_CHROMEOS) |
330 phishing_classifier_ = enable_phishing_detection ? | 332 phishing_classifier_ = enable_phishing_detection ? |
331 safe_browsing::PhishingClassifierDelegate::Create( | 333 safe_browsing::PhishingClassifierDelegate::Create( |
332 render_view(), NULL) : | 334 render_view(), NULL) : |
333 NULL; | 335 NULL; |
334 #endif | 336 #endif |
335 } | 337 } |
336 | 338 |
| 339 void ChromeRenderViewObserver::OnStartFrameSniffer(const string16& frame_name) { |
| 340 new FrameSniffer(render_view(), frame_name); |
| 341 } |
| 342 |
337 bool ChromeRenderViewObserver::allowDatabase( | 343 bool ChromeRenderViewObserver::allowDatabase( |
338 WebFrame* frame, | 344 WebFrame* frame, |
339 const WebString& name, | 345 const WebString& name, |
340 const WebString& display_name, | 346 const WebString& display_name, |
341 unsigned long estimated_size) { | 347 unsigned long estimated_size) { |
342 return content_settings_->AllowDatabase( | 348 return content_settings_->AllowDatabase( |
343 frame, name, display_name, estimated_size); | 349 frame, name, display_name, estimated_size); |
344 } | 350 } |
345 | 351 |
346 bool ChromeRenderViewObserver::allowFileSystem(WebFrame* frame) { | 352 bool ChromeRenderViewObserver::allowFileSystem(WebFrame* frame) { |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 if (net::DataURL::Parse(url, &mime_type, &char_set, &data) && !data.empty()) { | 960 if (net::DataURL::Parse(url, &mime_type, &char_set, &data) && !data.empty()) { |
955 // Decode the favicon using WebKit's image decoder. | 961 // Decode the favicon using WebKit's image decoder. |
956 webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize)); | 962 webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize)); |
957 const unsigned char* src_data = | 963 const unsigned char* src_data = |
958 reinterpret_cast<const unsigned char*>(&data[0]); | 964 reinterpret_cast<const unsigned char*>(&data[0]); |
959 | 965 |
960 return decoder.Decode(src_data, data.size()); | 966 return decoder.Decode(src_data, data.size()); |
961 } | 967 } |
962 return SkBitmap(); | 968 return SkBitmap(); |
963 } | 969 } |
OLD | NEW |