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" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "ui/base/ui_base_switches_util.h" | 52 #include "ui/base/ui_base_switches_util.h" |
53 #include "ui/gfx/favicon_size.h" | 53 #include "ui/gfx/favicon_size.h" |
54 #include "ui/gfx/size.h" | 54 #include "ui/gfx/size.h" |
55 #include "ui/gfx/size_f.h" | 55 #include "ui/gfx/size_f.h" |
56 #include "ui/gfx/skbitmap_operations.h" | 56 #include "ui/gfx/skbitmap_operations.h" |
57 #include "v8/include/v8-testing.h" | 57 #include "v8/include/v8-testing.h" |
58 #include "webkit/glue/webkit_glue.h" | 58 #include "webkit/glue/webkit_glue.h" |
59 | 59 |
60 using base::string16; | 60 using base::string16; |
61 using extensions::APIPermission; | 61 using extensions::APIPermission; |
62 using WebKit::WebAXObject; | 62 using blink::WebAXObject; |
63 using WebKit::WebCString; | 63 using blink::WebCString; |
64 using WebKit::WebDataSource; | 64 using blink::WebDataSource; |
65 using WebKit::WebDocument; | 65 using blink::WebDocument; |
66 using WebKit::WebElement; | 66 using blink::WebElement; |
67 using WebKit::WebFrame; | 67 using blink::WebFrame; |
68 using WebKit::WebGestureEvent; | 68 using blink::WebGestureEvent; |
69 using WebKit::WebIconURL; | 69 using blink::WebIconURL; |
70 using WebKit::WebNode; | 70 using blink::WebNode; |
71 using WebKit::WebNodeList; | 71 using blink::WebNodeList; |
72 using WebKit::WebRect; | 72 using blink::WebRect; |
73 using WebKit::WebSecurityOrigin; | 73 using blink::WebSecurityOrigin; |
74 using WebKit::WebSize; | 74 using blink::WebSize; |
75 using WebKit::WebString; | 75 using blink::WebString; |
76 using WebKit::WebTouchEvent; | 76 using blink::WebTouchEvent; |
77 using WebKit::WebURL; | 77 using blink::WebURL; |
78 using WebKit::WebURLRequest; | 78 using blink::WebURLRequest; |
79 using WebKit::WebView; | 79 using blink::WebView; |
80 using WebKit::WebVector; | 80 using blink::WebVector; |
81 using WebKit::WebWindowFeatures; | 81 using blink::WebWindowFeatures; |
82 | 82 |
83 // Delay in milliseconds that we'll wait before capturing the page contents | 83 // Delay in milliseconds that we'll wait before capturing the page contents |
84 // and thumbnail. | 84 // and thumbnail. |
85 static const int kDelayForCaptureMs = 500; | 85 static const int kDelayForCaptureMs = 500; |
86 | 86 |
87 // Typically, we capture the page data once the page is loaded. | 87 // Typically, we capture the page data once the page is loaded. |
88 // Sometimes, the page never finishes to load, preventing the page capture | 88 // Sometimes, the page never finishes to load, preventing the page capture |
89 // To workaround this problem, we always perform a capture after the following | 89 // To workaround this problem, we always perform a capture after the following |
90 // delay. | 90 // delay. |
91 static const int kDelayForForcedCaptureMs = 6000; | 91 static const int kDelayForForcedCaptureMs = 6000; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 GURL StripRef(const GURL& url) { | 173 GURL StripRef(const GURL& url) { |
174 GURL::Replacements replacements; | 174 GURL::Replacements replacements; |
175 replacements.ClearRef(); | 175 replacements.ClearRef(); |
176 return url.ReplaceComponents(replacements); | 176 return url.ReplaceComponents(replacements); |
177 } | 177 } |
178 | 178 |
179 // If the source image is null or occupies less area than | 179 // If the source image is null or occupies less area than |
180 // |thumbnail_min_area_pixels|, we return the image unmodified. Otherwise, we | 180 // |thumbnail_min_area_pixels|, we return the image unmodified. Otherwise, we |
181 // scale down the image so that the width and height do not exceed | 181 // scale down the image so that the width and height do not exceed |
182 // |thumbnail_max_size_pixels|, preserving the original aspect ratio. | 182 // |thumbnail_max_size_pixels|, preserving the original aspect ratio. |
183 SkBitmap Downscale(WebKit::WebImage image, | 183 SkBitmap Downscale(blink::WebImage image, |
184 int thumbnail_min_area_pixels, | 184 int thumbnail_min_area_pixels, |
185 gfx::Size thumbnail_max_size_pixels) { | 185 gfx::Size thumbnail_max_size_pixels) { |
186 if (image.isNull()) | 186 if (image.isNull()) |
187 return SkBitmap(); | 187 return SkBitmap(); |
188 | 188 |
189 gfx::Size image_size = image.size(); | 189 gfx::Size image_size = image.size(); |
190 | 190 |
191 if (image_size.GetArea() < thumbnail_min_area_pixels) | 191 if (image_size.GetArea() < thumbnail_min_area_pixels) |
192 return image.getSkBitmap(); | 192 return image.getSkBitmap(); |
193 | 193 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 } | 433 } |
434 } | 434 } |
435 } | 435 } |
436 } else { | 436 } else { |
437 success = false; | 437 success = false; |
438 } | 438 } |
439 | 439 |
440 bool is_only_apple_mobile_webapp_capable = | 440 bool is_only_apple_mobile_webapp_capable = |
441 is_apple_mobile_webapp_capable && !is_mobile_webapp_capable; | 441 is_apple_mobile_webapp_capable && !is_mobile_webapp_capable; |
442 if (main_frame && is_only_apple_mobile_webapp_capable) { | 442 if (main_frame && is_only_apple_mobile_webapp_capable) { |
443 WebKit::WebConsoleMessage message( | 443 blink::WebConsoleMessage message( |
444 WebKit::WebConsoleMessage::LevelWarning, | 444 blink::WebConsoleMessage::LevelWarning, |
445 "<meta name=\"apple-mobile-web-app-capable\" content=\"yes\"> is " | 445 "<meta name=\"apple-mobile-web-app-capable\" content=\"yes\"> is " |
446 "deprecated. Please include <meta name=\"mobile-web-app-capable\" " | 446 "deprecated. Please include <meta name=\"mobile-web-app-capable\" " |
447 "content=\"yes\"> - " | 447 "content=\"yes\"> - " |
448 "http://developers.google.com/chrome/mobile/docs/installtohomescreen"); | 448 "http://developers.google.com/chrome/mobile/docs/installtohomescreen"); |
449 main_frame->addMessageToConsole(message); | 449 main_frame->addMessageToConsole(message); |
450 } | 450 } |
451 | 451 |
452 Send(new ChromeViewHostMsg_DidRetrieveWebappInformation( | 452 Send(new ChromeViewHostMsg_DidRetrieveWebappInformation( |
453 routing_id(), | 453 routing_id(), |
454 success, | 454 success, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 dimmed_color_overlay_.reset(); | 494 dimmed_color_overlay_.reset(); |
495 } | 495 } |
496 } | 496 } |
497 | 497 |
498 void ChromeRenderViewObserver::OnRequestThumbnailForContextNode( | 498 void ChromeRenderViewObserver::OnRequestThumbnailForContextNode( |
499 int thumbnail_min_area_pixels, gfx::Size thumbnail_max_size_pixels) { | 499 int thumbnail_min_area_pixels, gfx::Size thumbnail_max_size_pixels) { |
500 WebNode context_node = render_view()->GetContextMenuNode(); | 500 WebNode context_node = render_view()->GetContextMenuNode(); |
501 SkBitmap thumbnail; | 501 SkBitmap thumbnail; |
502 gfx::Size original_size; | 502 gfx::Size original_size; |
503 if (!context_node.isNull() && context_node.isElementNode()) { | 503 if (!context_node.isNull() && context_node.isElementNode()) { |
504 WebKit::WebImage image = context_node.to<WebElement>().imageContents(); | 504 blink::WebImage image = context_node.to<WebElement>().imageContents(); |
505 original_size = image.size(); | 505 original_size = image.size(); |
506 thumbnail = Downscale(image, | 506 thumbnail = Downscale(image, |
507 thumbnail_min_area_pixels, | 507 thumbnail_min_area_pixels, |
508 thumbnail_max_size_pixels); | 508 thumbnail_max_size_pixels); |
509 } | 509 } |
510 Send(new ChromeViewHostMsg_RequestThumbnailForContextNode_ACK( | 510 Send(new ChromeViewHostMsg_RequestThumbnailForContextNode_ACK( |
511 routing_id(), thumbnail, original_size)); | 511 routing_id(), thumbnail, original_size)); |
512 } | 512 } |
513 | 513 |
514 void ChromeRenderViewObserver::OnGetFPS() { | 514 void ChromeRenderViewObserver::OnGetFPS() { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 const extensions::Extension* extension = GetExtension(origin); | 626 const extensions::Extension* extension = GetExtension(origin); |
627 return !extension || !extension->is_platform_app(); | 627 return !extension || !extension->is_platform_app(); |
628 } | 628 } |
629 | 629 |
630 static void SendInsecureContentSignal(int signal) { | 630 static void SendInsecureContentSignal(int signal) { |
631 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", signal, | 631 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", signal, |
632 INSECURE_CONTENT_NUM_EVENTS); | 632 INSECURE_CONTENT_NUM_EVENTS); |
633 } | 633 } |
634 | 634 |
635 bool ChromeRenderViewObserver::allowDisplayingInsecureContent( | 635 bool ChromeRenderViewObserver::allowDisplayingInsecureContent( |
636 WebKit::WebFrame* frame, | 636 blink::WebFrame* frame, |
637 bool allowed_per_settings, | 637 bool allowed_per_settings, |
638 const WebKit::WebSecurityOrigin& origin, | 638 const blink::WebSecurityOrigin& origin, |
639 const WebKit::WebURL& resource_url) { | 639 const blink::WebURL& resource_url) { |
640 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY); | 640 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY); |
641 | 641 |
642 std::string origin_host(origin.host().utf8()); | 642 std::string origin_host(origin.host().utf8()); |
643 GURL frame_gurl(frame->document().url()); | 643 GURL frame_gurl(frame->document().url()); |
644 if (isHostInDomain(origin_host, kGoogleDotCom)) { | 644 if (isHostInDomain(origin_host, kGoogleDotCom)) { |
645 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE); | 645 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE); |
646 if (StartsWithASCII(frame_gurl.path(), kGoogleSupportPathPrefix, false)) { | 646 if (StartsWithASCII(frame_gurl.path(), kGoogleSupportPathPrefix, false)) { |
647 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_SUPPORT); | 647 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_SUPPORT); |
648 } else if (StartsWithASCII(frame_gurl.path(), | 648 } else if (StartsWithASCII(frame_gurl.path(), |
649 kGoogleIntlPathPrefix, | 649 kGoogleIntlPathPrefix, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 | 682 |
683 if (allowed_per_settings || allow_displaying_insecure_content_) | 683 if (allowed_per_settings || allow_displaying_insecure_content_) |
684 return true; | 684 return true; |
685 | 685 |
686 Send(new ChromeViewHostMsg_DidBlockDisplayingInsecureContent(routing_id())); | 686 Send(new ChromeViewHostMsg_DidBlockDisplayingInsecureContent(routing_id())); |
687 | 687 |
688 return false; | 688 return false; |
689 } | 689 } |
690 | 690 |
691 bool ChromeRenderViewObserver::allowRunningInsecureContent( | 691 bool ChromeRenderViewObserver::allowRunningInsecureContent( |
692 WebKit::WebFrame* frame, | 692 blink::WebFrame* frame, |
693 bool allowed_per_settings, | 693 bool allowed_per_settings, |
694 const WebKit::WebSecurityOrigin& origin, | 694 const blink::WebSecurityOrigin& origin, |
695 const WebKit::WebURL& resource_url) { | 695 const blink::WebURL& resource_url) { |
696 std::string origin_host(origin.host().utf8()); | 696 std::string origin_host(origin.host().utf8()); |
697 GURL frame_gurl(frame->document().url()); | 697 GURL frame_gurl(frame->document().url()); |
698 DCHECK_EQ(frame_gurl.host(), origin_host); | 698 DCHECK_EQ(frame_gurl.host(), origin_host); |
699 | 699 |
700 bool is_google = isHostInDomain(origin_host, kGoogleDotCom); | 700 bool is_google = isHostInDomain(origin_host, kGoogleDotCom); |
701 if (is_google) { | 701 if (is_google) { |
702 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE); | 702 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE); |
703 if (StartsWithASCII(frame_gurl.path(), kGoogleSupportPathPrefix, false)) { | 703 if (StartsWithASCII(frame_gurl.path(), kGoogleSupportPathPrefix, false)) { |
704 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE_SUPPORT); | 704 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE_SUPPORT); |
705 } else if (StartsWithASCII(frame_gurl.path(), | 705 } else if (StartsWithASCII(frame_gurl.path(), |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 | 826 |
827 void ChromeRenderViewObserver::DidClearWindowObject(WebFrame* frame) { | 827 void ChromeRenderViewObserver::DidClearWindowObject(WebFrame* frame) { |
828 if (render_view()->GetEnabledBindings() & | 828 if (render_view()->GetEnabledBindings() & |
829 content::BINDINGS_POLICY_EXTERNAL_HOST) { | 829 content::BINDINGS_POLICY_EXTERNAL_HOST) { |
830 GetExternalHostBindings()->BindToJavascript(frame, "externalHost"); | 830 GetExternalHostBindings()->BindToJavascript(frame, "externalHost"); |
831 } | 831 } |
832 } | 832 } |
833 | 833 |
834 void ChromeRenderViewObserver::DidHandleGestureEvent( | 834 void ChromeRenderViewObserver::DidHandleGestureEvent( |
835 const WebGestureEvent& event) { | 835 const WebGestureEvent& event) { |
836 if (event.type != WebKit::WebGestureEvent::GestureTap) | 836 if (event.type != blink::WebGestureEvent::GestureTap) |
837 return; | 837 return; |
838 | 838 |
839 WebKit::WebTextInputType text_input_type = | 839 blink::WebTextInputType text_input_type = |
840 render_view()->GetWebView()->textInputInfo().type; | 840 render_view()->GetWebView()->textInputInfo().type; |
841 | 841 |
842 render_view()->Send(new ChromeViewHostMsg_FocusedNodeTouched( | 842 render_view()->Send(new ChromeViewHostMsg_FocusedNodeTouched( |
843 routing_id(), | 843 routing_id(), |
844 text_input_type != WebKit::WebTextInputTypeNone)); | 844 text_input_type != blink::WebTextInputTypeNone)); |
845 } | 845 } |
846 | 846 |
847 void ChromeRenderViewObserver::DetailedConsoleMessageAdded( | 847 void ChromeRenderViewObserver::DetailedConsoleMessageAdded( |
848 const base::string16& message, | 848 const base::string16& message, |
849 const base::string16& source, | 849 const base::string16& source, |
850 const base::string16& stack_trace_string, | 850 const base::string16& stack_trace_string, |
851 int32 line_number, | 851 int32 line_number, |
852 int32 severity_level) { | 852 int32 severity_level) { |
853 string16 trimmed_message = message; | 853 string16 trimmed_message = message; |
854 extensions::StackTrace stack_trace = GetStackTraceFromMessage( | 854 extensions::StackTrace stack_trace = GetStackTraceFromMessage( |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 WebElement element = node.to<WebElement>(); | 1032 WebElement element = node.to<WebElement>(); |
1033 if (!element.hasTagName(tag_name)) | 1033 if (!element.hasTagName(tag_name)) |
1034 continue; | 1034 continue; |
1035 WebString value = element.getAttribute(attribute_name); | 1035 WebString value = element.getAttribute(attribute_name); |
1036 if (value.isNull() || !LowerCaseEqualsASCII(value, "refresh")) | 1036 if (value.isNull() || !LowerCaseEqualsASCII(value, "refresh")) |
1037 continue; | 1037 continue; |
1038 return true; | 1038 return true; |
1039 } | 1039 } |
1040 return false; | 1040 return false; |
1041 } | 1041 } |
OLD | NEW |