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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
689 render_view()->GetContentStateImmediately() ? | 689 render_view()->GetContentStateImmediately() ? |
690 0 : kDelayForCaptureMs)); | 690 0 : kDelayForCaptureMs)); |
691 | 691 |
692 WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); | 692 WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); |
693 GURL osd_url = main_frame->document().openSearchDescriptionURL(); | 693 GURL osd_url = main_frame->document().openSearchDescriptionURL(); |
694 if (!osd_url.is_empty()) { | 694 if (!osd_url.is_empty()) { |
695 Send(new ChromeViewHostMsg_PageHasOSDD( | 695 Send(new ChromeViewHostMsg_PageHasOSDD( |
696 routing_id(), render_view()->GetPageId(), osd_url, | 696 routing_id(), render_view()->GetPageId(), osd_url, |
697 search_provider::AUTODETECTED_PROVIDER)); | 697 search_provider::AUTODETECTED_PROVIDER)); |
698 } | 698 } |
699 } | |
699 | 700 |
700 int icon_types = WebIconURL::TypeFavicon; | 701 void ChromeRenderViewObserver::CollectAndUpdateFaviconURLs( |
darin (slow to review)
2012/08/06 20:46:32
please list functions in the .cpp file in the same
aruslan
2012/08/06 20:52:27
Done.
| |
701 if (chrome::kEnableTouchIcon) | 702 WebKit::WebFrame* frame, int icon_types) { |
702 icon_types |= WebIconURL::TypeTouchPrecomposed | WebIconURL::TypeTouch; | 703 WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_types); |
703 | |
704 WebVector<WebIconURL> icon_urls = | |
705 render_view()->GetWebView()->mainFrame()->iconURLs(icon_types); | |
706 std::vector<FaviconURL> urls; | 704 std::vector<FaviconURL> urls; |
707 for (size_t i = 0; i < icon_urls.size(); i++) { | 705 for (size_t i = 0; i < icon_urls.size(); i++) { |
708 WebURL url = icon_urls[i].iconURL(); | 706 WebURL url = icon_urls[i].iconURL(); |
709 if (!url.isEmpty()) | 707 if (!url.isEmpty()) |
710 urls.push_back(FaviconURL(url, ToFaviconType(icon_urls[i].iconType()))); | 708 urls.push_back(FaviconURL(url, ToFaviconType(icon_urls[i].iconType()))); |
711 } | 709 } |
712 if (!urls.empty()) { | 710 if (!urls.empty()) { |
713 Send(new IconHostMsg_UpdateFaviconURL( | 711 Send(new IconHostMsg_UpdateFaviconURL( |
714 routing_id(), render_view()->GetPageId(), urls)); | 712 routing_id(), render_view()->GetPageId(), urls)); |
715 } | 713 } |
716 } | 714 } |
717 | 715 |
716 void ChromeRenderViewObserver::DidFinishLoad(WebKit::WebFrame* frame) { | |
717 if (frame->parent()) | |
718 return; | |
719 | |
720 // Please note that we are updating favicons only for the _main_ frame. | |
721 // Updating Favicon URLs at DidFinishLoad ensures that icon loads always get | |
722 // initiated after all of the other page resources have been fetched, so icon | |
723 // loads should not compete with page resources for network bandwidth. | |
724 int icon_types = WebIconURL::TypeFavicon; | |
725 if (chrome::kEnableTouchIcon) | |
726 icon_types |= WebIconURL::TypeTouchPrecomposed | WebIconURL::TypeTouch; | |
727 | |
728 CollectAndUpdateFaviconURLs(frame, icon_types); | |
729 } | |
730 | |
718 void ChromeRenderViewObserver::DidChangeIcon(WebFrame* frame, | 731 void ChromeRenderViewObserver::DidChangeIcon(WebFrame* frame, |
719 WebIconURL::Type icon_type) { | 732 WebIconURL::Type icon_type) { |
720 if (frame->parent()) | 733 if (frame->parent()) |
721 return; | 734 return; |
722 | 735 |
723 if (!chrome::kEnableTouchIcon && | 736 if (!chrome::kEnableTouchIcon && |
724 icon_type != WebIconURL::TypeFavicon) | 737 icon_type != WebIconURL::TypeFavicon) |
725 return; | 738 return; |
726 | 739 |
727 WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type); | 740 CollectAndUpdateFaviconURLs(frame, icon_type); |
728 std::vector<FaviconURL> urls; | |
729 for (size_t i = 0; i < icon_urls.size(); i++) { | |
730 urls.push_back(FaviconURL(icon_urls[i].iconURL(), | |
731 ToFaviconType(icon_urls[i].iconType()))); | |
732 } | |
733 Send(new IconHostMsg_UpdateFaviconURL( | |
734 routing_id(), render_view()->GetPageId(), urls)); | |
735 } | 741 } |
736 | 742 |
737 void ChromeRenderViewObserver::DidCommitProvisionalLoad( | 743 void ChromeRenderViewObserver::DidCommitProvisionalLoad( |
738 WebFrame* frame, bool is_new_navigation) { | 744 WebFrame* frame, bool is_new_navigation) { |
739 if (!is_new_navigation) | 745 if (!is_new_navigation) |
740 return; | 746 return; |
741 | 747 |
742 CapturePageInfoLater( | 748 CapturePageInfoLater( |
743 true, // preliminary_capture | 749 true, // preliminary_capture |
744 base::TimeDelta::FromMilliseconds(kDelayForForcedCaptureMs)); | 750 base::TimeDelta::FromMilliseconds(kDelayForForcedCaptureMs)); |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1089 reinterpret_cast<const unsigned char*>(&data[0]); | 1095 reinterpret_cast<const unsigned char*>(&data[0]); |
1090 | 1096 |
1091 return decoder.Decode(src_data, data.size()); | 1097 return decoder.Decode(src_data, data.size()); |
1092 } | 1098 } |
1093 return SkBitmap(); | 1099 return SkBitmap(); |
1094 } | 1100 } |
1095 | 1101 |
1096 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { | 1102 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { |
1097 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); | 1103 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); |
1098 } | 1104 } |
OLD | NEW |