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 #include "chrome/renderer/chrome_render_view_observer.h" | 5 #include "chrome/renderer/chrome_render_view_observer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/icon_messages.h" | 16 #include "chrome/common/icon_messages.h" |
17 #include "chrome/common/prerender_messages.h" | 17 #include "chrome/common/prerender_messages.h" |
18 #include "chrome/common/render_messages.h" | 18 #include "chrome/common/render_messages.h" |
19 #include "chrome/common/thumbnail_score.h" | 19 #include "chrome/common/thumbnail_score.h" |
20 #include "chrome/common/thumbnail_support.h" | 20 #include "chrome/common/thumbnail_support.h" |
21 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
22 #include "chrome/renderer/chrome_render_process_observer.h" | 22 #include "chrome/renderer/chrome_render_process_observer.h" |
23 #include "chrome/renderer/content_settings_observer.h" | 23 #include "chrome/renderer/content_settings_observer.h" |
24 #include "chrome/renderer/extensions/dispatcher.h" | 24 #include "chrome/renderer/extensions/dispatcher.h" |
25 #include "chrome/renderer/external_host_bindings.h" | 25 #include "chrome/renderer/external_host_bindings.h" |
26 #include "chrome/renderer/frame_sniffer.h" | 26 #include "chrome/renderer/frame_sniffer.h" |
27 #include "chrome/renderer/prerender/prerender_helper.h" | 27 #include "chrome/renderer/prerender/prerender_helper.h" |
28 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 28 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
29 #include "chrome/renderer/translate_helper.h" | 29 #include "chrome/renderer/translate_helper.h" |
30 #include "chrome/renderer/webview_animating_overlay.h" | |
31 #include "chrome/renderer/webview_color_overlay.h" | 30 #include "chrome/renderer/webview_color_overlay.h" |
32 #include "content/public/common/bindings_policy.h" | 31 #include "content/public/common/bindings_policy.h" |
33 #include "content/public/renderer/render_view.h" | 32 #include "content/public/renderer/render_view.h" |
34 #include "content/public/renderer/content_renderer_client.h" | 33 #include "content/public/renderer/content_renderer_client.h" |
35 #include "net/base/data_url.h" | 34 #include "net/base/data_url.h" |
36 #include "skia/ext/image_operations.h" | 35 #include "skia/ext/image_operations.h" |
37 #include "skia/ext/platform_canvas.h" | 36 #include "skia/ext/platform_canvas.h" |
38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec
t.h" | 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec
t.h" |
39 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" | 38 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" |
40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 bool enable_phishing_detection) { | 374 bool enable_phishing_detection) { |
376 #if defined(ENABLE_SAFE_BROWSING) && !defined(OS_CHROMEOS) | 375 #if defined(ENABLE_SAFE_BROWSING) && !defined(OS_CHROMEOS) |
377 phishing_classifier_ = enable_phishing_detection ? | 376 phishing_classifier_ = enable_phishing_detection ? |
378 safe_browsing::PhishingClassifierDelegate::Create( | 377 safe_browsing::PhishingClassifierDelegate::Create( |
379 render_view(), NULL) : | 378 render_view(), NULL) : |
380 NULL; | 379 NULL; |
381 #endif | 380 #endif |
382 } | 381 } |
383 | 382 |
384 void ChromeRenderViewObserver::OnSetVisuallyDeemphasized(bool deemphasized) { | 383 void ChromeRenderViewObserver::OnSetVisuallyDeemphasized(bool deemphasized) { |
385 if (CommandLine::ForCurrentProcess()->HasSwitch( | 384 bool already_deemphasized = !!dimmed_color_overlay_.get(); |
386 switches::kEnableFramelessConstrainedDialogs)) { | 385 if (already_deemphasized == deemphasized) |
387 if (!dimmed_animating_overlay_.get()) { | 386 return; |
388 dimmed_animating_overlay_.reset( | 387 |
389 new WebViewAnimatingOverlay(render_view())); | 388 if (deemphasized) { |
390 } | 389 // 70% opaque grey. |
391 if (deemphasized) | 390 SkColor greyish = SkColorSetARGB(178, 0, 0, 0); |
392 dimmed_animating_overlay_->Show(); | 391 dimmed_color_overlay_.reset( |
393 else | 392 new WebViewColorOverlay(render_view(), greyish)); |
394 dimmed_animating_overlay_->Hide(); | |
395 } else { | 393 } else { |
396 bool already_deemphasized = !!dimmed_color_overlay_.get(); | 394 dimmed_color_overlay_.reset(); |
397 if (already_deemphasized == deemphasized) | |
398 return; | |
399 | |
400 if (deemphasized) { | |
401 // 70% opaque grey. | |
402 SkColor greyish = SkColorSetARGB(178, 0, 0, 0); | |
403 dimmed_color_overlay_.reset( | |
404 new WebViewColorOverlay(render_view(), greyish)); | |
405 } else { | |
406 dimmed_color_overlay_.reset(); | |
407 } | |
408 } | 395 } |
409 } | 396 } |
410 | 397 |
411 void ChromeRenderViewObserver::OnStartFrameSniffer(const string16& frame_name) { | 398 void ChromeRenderViewObserver::OnStartFrameSniffer(const string16& frame_name) { |
412 new FrameSniffer(render_view(), frame_name); | 399 new FrameSniffer(render_view(), frame_name); |
413 } | 400 } |
414 | 401 |
415 void ChromeRenderViewObserver::OnGetFPS() { | 402 void ChromeRenderViewObserver::OnGetFPS() { |
416 float fps = (render_view()->GetFilteredTimePerFrame() > 0.0f)? | 403 float fps = (render_view()->GetFilteredTimePerFrame() > 0.0f)? |
417 1.0f / render_view()->GetFilteredTimePerFrame() : 0.0f; | 404 1.0f / render_view()->GetFilteredTimePerFrame() : 0.0f; |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 reinterpret_cast<const unsigned char*>(&data[0]); | 1094 reinterpret_cast<const unsigned char*>(&data[0]); |
1108 | 1095 |
1109 return decoder.Decode(src_data, data.size()); | 1096 return decoder.Decode(src_data, data.size()); |
1110 } | 1097 } |
1111 return SkBitmap(); | 1098 return SkBitmap(); |
1112 } | 1099 } |
1113 | 1100 |
1114 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { | 1101 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { |
1115 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); | 1102 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); |
1116 } | 1103 } |
OLD | NEW |