Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 2918903002: Move IconURLs method from WebFrame to WebLocalFrame (Closed)
Patch Set: s/kFavIcon/kFavicon/g (as suggested in CR feedback from pkotwicz@). Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | third_party/WebKit/Source/web/WebRemoteFrameImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "content/common/input_messages.h" 53 #include "content/common/input_messages.h"
54 #include "content/common/page_messages.h" 54 #include "content/common/page_messages.h"
55 #include "content/common/render_message_filter.mojom.h" 55 #include "content/common/render_message_filter.mojom.h"
56 #include "content/common/view_messages.h" 56 #include "content/common/view_messages.h"
57 #include "content/public/common/associated_interface_provider.h" 57 #include "content/public/common/associated_interface_provider.h"
58 #include "content/public/common/bindings_policy.h" 58 #include "content/public/common/bindings_policy.h"
59 #include "content/public/common/browser_side_navigation_policy.h" 59 #include "content/public/common/browser_side_navigation_policy.h"
60 #include "content/public/common/content_client.h" 60 #include "content/public/common/content_client.h"
61 #include "content/public/common/content_constants.h" 61 #include "content/public/common/content_constants.h"
62 #include "content/public/common/content_switches.h" 62 #include "content/public/common/content_switches.h"
63 #include "content/public/common/favicon_url.h"
64 #include "content/public/common/page_importance_signals.h" 63 #include "content/public/common/page_importance_signals.h"
65 #include "content/public/common/page_state.h" 64 #include "content/public/common/page_state.h"
66 #include "content/public/common/page_zoom.h" 65 #include "content/public/common/page_zoom.h"
67 #include "content/public/common/three_d_api_types.h" 66 #include "content/public/common/three_d_api_types.h"
68 #include "content/public/common/url_constants.h" 67 #include "content/public/common/url_constants.h"
69 #include "content/public/common/web_preferences.h" 68 #include "content/public/common/web_preferences.h"
70 #include "content/public/renderer/content_renderer_client.h" 69 #include "content/public/renderer/content_renderer_client.h"
71 #include "content/public/renderer/document_state.h" 70 #include "content/public/renderer/document_state.h"
72 #include "content/public/renderer/navigation_state.h" 71 #include "content/public/renderer/navigation_state.h"
73 #include "content/public/renderer/render_view_observer.h" 72 #include "content/public/renderer/render_view_observer.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 using blink::WebElement; 212 using blink::WebElement;
214 using blink::WebFileChooserCompletion; 213 using blink::WebFileChooserCompletion;
215 using blink::WebFormControlElement; 214 using blink::WebFormControlElement;
216 using blink::WebFormElement; 215 using blink::WebFormElement;
217 using blink::WebFrame; 216 using blink::WebFrame;
218 using blink::WebFrameContentDumper; 217 using blink::WebFrameContentDumper;
219 using blink::WebGestureEvent; 218 using blink::WebGestureEvent;
220 using blink::WebHistoryItem; 219 using blink::WebHistoryItem;
221 using blink::WebHTTPBody; 220 using blink::WebHTTPBody;
222 using blink::WebHitTestResult; 221 using blink::WebHitTestResult;
223 using blink::WebIconURL;
224 using blink::WebImage; 222 using blink::WebImage;
225 using blink::WebInputElement; 223 using blink::WebInputElement;
226 using blink::WebInputEvent; 224 using blink::WebInputEvent;
227 using blink::WebLocalFrame; 225 using blink::WebLocalFrame;
228 using blink::WebMediaPlayerAction; 226 using blink::WebMediaPlayerAction;
229 using blink::WebMouseEvent; 227 using blink::WebMouseEvent;
230 using blink::WebNavigationPolicy; 228 using blink::WebNavigationPolicy;
231 using blink::WebNavigationType; 229 using blink::WebNavigationType;
232 using blink::WebNode; 230 using blink::WebNode;
233 using blink::WebPluginAction; 231 using blink::WebPluginAction;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 *base::CommandLine::ForCurrentProcess(); 338 *base::CommandLine::ForCurrentProcess();
341 if (command_line.HasSwitch(switches::kDisablePreferCompositingToLCDText)) 339 if (command_line.HasSwitch(switches::kDisablePreferCompositingToLCDText))
342 return false; 340 return false;
343 if (command_line.HasSwitch(switches::kEnablePreferCompositingToLCDText)) 341 if (command_line.HasSwitch(switches::kEnablePreferCompositingToLCDText))
344 return true; 342 return true;
345 if (!compositor_deps->IsLcdTextEnabled()) 343 if (!compositor_deps->IsLcdTextEnabled())
346 return true; 344 return true;
347 return DeviceScaleEnsuresTextQuality(device_scale_factor); 345 return DeviceScaleEnsuresTextQuality(device_scale_factor);
348 } 346 }
349 347
350 static FaviconURL::IconType ToFaviconType(blink::WebIconURL::Type type) {
351 switch (type) {
352 case blink::WebIconURL::kTypeFavicon:
353 return FaviconURL::FAVICON;
354 case blink::WebIconURL::kTypeTouch:
355 return FaviconURL::TOUCH_ICON;
356 case blink::WebIconURL::kTypeTouchPrecomposed:
357 return FaviconURL::TOUCH_PRECOMPOSED_ICON;
358 case blink::WebIconURL::kTypeInvalid:
359 return FaviconURL::INVALID_ICON;
360 }
361 return FaviconURL::INVALID_ICON;
362 }
363
364 static void ConvertToFaviconSizes(
365 const blink::WebVector<blink::WebSize>& web_sizes,
366 std::vector<gfx::Size>* sizes) {
367 DCHECK(sizes->empty());
368 sizes->reserve(web_sizes.size());
369 for (size_t i = 0; i < web_sizes.size(); ++i)
370 sizes->push_back(gfx::Size(web_sizes[i]));
371 }
372
373 /////////////////////////////////////////////////////////////////////////////// 348 ///////////////////////////////////////////////////////////////////////////////
374 349
375 namespace { 350 namespace {
376 351
377 typedef void (*SetFontFamilyWrapper)(blink::WebSettings*, 352 typedef void (*SetFontFamilyWrapper)(blink::WebSettings*,
378 const base::string16&, 353 const base::string16&,
379 UScriptCode); 354 UScriptCode);
380 355
381 void SetStandardFontFamilyWrapper(WebSettings* settings, 356 void SetStandardFontFamilyWrapper(WebSettings* settings,
382 const base::string16& font, 357 const base::string16& font,
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 frames_in_progress_++; 1517 frames_in_progress_++;
1543 } 1518 }
1544 1519
1545 void RenderViewImpl::FrameDidStopLoading(WebFrame* frame) { 1520 void RenderViewImpl::FrameDidStopLoading(WebFrame* frame) {
1546 // TODO(japhet): This should be a DCHECK, but the pdf plugin sometimes 1521 // TODO(japhet): This should be a DCHECK, but the pdf plugin sometimes
1547 // calls DidStopLoading() without a matching DidStartLoading(). 1522 // calls DidStopLoading() without a matching DidStartLoading().
1548 if (frames_in_progress_ == 0) 1523 if (frames_in_progress_ == 0)
1549 return; 1524 return;
1550 frames_in_progress_--; 1525 frames_in_progress_--;
1551 if (frames_in_progress_ == 0) { 1526 if (frames_in_progress_ == 0) {
1552 DidStopLoadingIcons();
1553 for (auto& observer : observers_) 1527 for (auto& observer : observers_)
1554 observer.DidStopLoading(); 1528 observer.DidStopLoading();
1555 } 1529 }
1556 } 1530 }
1557 1531
1558 void RenderViewImpl::AttachWebFrameWidget(blink::WebFrameWidget* frame_widget) { 1532 void RenderViewImpl::AttachWebFrameWidget(blink::WebFrameWidget* frame_widget) {
1559 // The previous WebFrameWidget must already be detached by CloseForFrame(). 1533 // The previous WebFrameWidget must already be detached by CloseForFrame().
1560 DCHECK(!frame_widget_); 1534 DCHECK(!frame_widget_);
1561 frame_widget_ = frame_widget; 1535 frame_widget_ = frame_widget;
1562 } 1536 }
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 const blink::WebElement& element) { 1875 const blink::WebElement& element) {
1902 blink::WebRect bounding_box_in_window = element.BoundsInViewport(); 1876 blink::WebRect bounding_box_in_window = element.BoundsInViewport();
1903 ConvertViewportToWindowViaWidget(&bounding_box_in_window); 1877 ConvertViewportToWindowViaWidget(&bounding_box_in_window);
1904 return gfx::RectF(bounding_box_in_window); 1878 return gfx::RectF(bounding_box_in_window);
1905 } 1879 }
1906 1880
1907 bool RenderViewImpl::HasAddedInputHandler() const { 1881 bool RenderViewImpl::HasAddedInputHandler() const {
1908 return has_added_input_handler_; 1882 return has_added_input_handler_;
1909 } 1883 }
1910 1884
1911 void RenderViewImpl::didChangeIcon(WebLocalFrame* frame,
1912 WebIconURL::Type icon_type) {
1913 if (frame->Parent())
1914 return;
1915
1916 WebVector<WebIconURL> icon_urls = frame->IconURLs(icon_type);
1917 std::vector<FaviconURL> urls;
1918 for (size_t i = 0; i < icon_urls.size(); i++) {
1919 std::vector<gfx::Size> sizes;
1920 ConvertToFaviconSizes(icon_urls[i].Sizes(), &sizes);
1921 urls.push_back(FaviconURL(icon_urls[i].GetIconURL(),
1922 ToFaviconType(icon_urls[i].IconType()), sizes));
1923 }
1924 SendUpdateFaviconURL(urls);
1925 }
1926
1927 void RenderViewImpl::CheckPreferredSize() { 1885 void RenderViewImpl::CheckPreferredSize() {
1928 // We don't always want to send the change messages over IPC, only if we've 1886 // We don't always want to send the change messages over IPC, only if we've
1929 // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| 1887 // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode|
1930 // message. 1888 // message.
1931 if (!send_preferred_size_changes_ || !webview()) 1889 if (!send_preferred_size_changes_ || !webview())
1932 return; 1890 return;
1933 1891
1934 gfx::Size size = webview()->ContentsPreferredMinimumSize(); 1892 gfx::Size size = webview()->ContentsPreferredMinimumSize();
1935 if (size == preferred_size_) 1893 if (size == preferred_size_)
1936 return; 1894 return;
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
2584 webview()->ResolveTapDisambiguation(timestamp_seconds, tap_viewport_offset, 2542 webview()->ResolveTapDisambiguation(timestamp_seconds, tap_viewport_offset,
2585 is_long_press); 2543 is_long_press);
2586 } 2544 }
2587 2545
2588 void RenderViewImpl::DidCommitCompositorFrame() { 2546 void RenderViewImpl::DidCommitCompositorFrame() {
2589 RenderWidget::DidCommitCompositorFrame(); 2547 RenderWidget::DidCommitCompositorFrame();
2590 for (auto& observer : observers_) 2548 for (auto& observer : observers_)
2591 observer.DidCommitCompositorFrame(); 2549 observer.DidCommitCompositorFrame();
2592 } 2550 }
2593 2551
2594 void RenderViewImpl::SendUpdateFaviconURL(const std::vector<FaviconURL>& urls) {
2595 if (!urls.empty())
2596 Send(new ViewHostMsg_UpdateFaviconURL(GetRoutingID(), urls));
2597 }
2598
2599 void RenderViewImpl::DidStopLoadingIcons() {
2600 int icon_types = WebIconURL::kTypeFavicon |
2601 WebIconURL::kTypeTouchPrecomposed | WebIconURL::kTypeTouch;
2602
2603 // Favicons matter only for the top-level frame. If it is a WebRemoteFrame,
2604 // just return early.
2605 if (webview()->MainFrame()->IsWebRemoteFrame())
2606 return;
2607
2608 WebVector<WebIconURL> icon_urls =
2609 webview()->MainFrame()->IconURLs(icon_types);
2610
2611 std::vector<FaviconURL> urls;
2612 for (size_t i = 0; i < icon_urls.size(); i++) {
2613 WebURL url = icon_urls[i].GetIconURL();
2614 std::vector<gfx::Size> sizes;
2615 ConvertToFaviconSizes(icon_urls[i].Sizes(), &sizes);
2616 if (!url.IsEmpty())
2617 urls.push_back(
2618 FaviconURL(url, ToFaviconType(icon_urls[i].IconType()), sizes));
2619 }
2620 SendUpdateFaviconURL(urls);
2621 }
2622
2623 void RenderViewImpl::UpdateWebViewWithDeviceScaleFactor() { 2552 void RenderViewImpl::UpdateWebViewWithDeviceScaleFactor() {
2624 if (!webview()) 2553 if (!webview())
2625 return; 2554 return;
2626 if (IsUseZoomForDSFEnabled()) { 2555 if (IsUseZoomForDSFEnabled()) {
2627 webview()->SetZoomFactorForDeviceScaleFactor(device_scale_factor_); 2556 webview()->SetZoomFactorForDeviceScaleFactor(device_scale_factor_);
2628 } else { 2557 } else {
2629 webview()->SetDeviceScaleFactor(device_scale_factor_); 2558 webview()->SetDeviceScaleFactor(device_scale_factor_);
2630 } 2559 }
2631 webview()->GetSettings()->SetPreferCompositingToLCDTextEnabled( 2560 webview()->GetSettings()->SetPreferCompositingToLCDTextEnabled(
2632 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); 2561 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_));
(...skipping 23 matching lines...) Expand all
2656 input_event.GetCoalescedEventsPointers(), latency_info, 2585 input_event.GetCoalescedEventsPointers(), latency_info,
2657 dispatch_type); 2586 dispatch_type);
2658 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 2587 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
2659 } 2588 }
2660 idle_user_detector_->ActivityDetected(); 2589 idle_user_detector_->ActivityDetected();
2661 return RenderWidget::HandleInputEvent(input_event, latency_info, 2590 return RenderWidget::HandleInputEvent(input_event, latency_info,
2662 dispatch_type); 2591 dispatch_type);
2663 } 2592 }
2664 2593
2665 } // namespace content 2594 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | third_party/WebKit/Source/web/WebRemoteFrameImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698