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

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

Issue 23364004: Implementation of device metrics emulation in render view. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Moved helper class to cc Created 7 years, 3 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 | Annotate | Revision Log
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 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 // Copy over the alternate error page URL so we can have alt error pages in 2354 // Copy over the alternate error page URL so we can have alt error pages in
2355 // the new render view (we don't need the browser to send the URL back down). 2355 // the new render view (we don't need the browser to send the URL back down).
2356 view->alternate_error_page_url_ = alternate_error_page_url_; 2356 view->alternate_error_page_url_ = alternate_error_page_url_;
2357 2357
2358 return view->webview(); 2358 return view->webview();
2359 } 2359 }
2360 2360
2361 WebWidget* RenderViewImpl::createPopupMenu(WebKit::WebPopupType popup_type) { 2361 WebWidget* RenderViewImpl::createPopupMenu(WebKit::WebPopupType popup_type) {
2362 RenderWidget* widget = 2362 RenderWidget* widget =
2363 RenderWidget::Create(routing_id_, popup_type, screen_info_); 2363 RenderWidget::Create(routing_id_, popup_type, screen_info_);
2364 if (device_emulator_)
2365 widget->set_popup_device_emulator(device_emulator_.get());
aelias_OOO_until_Jul13 2013/09/20 07:10:14 This weak pointer is sketchy. The popup didn't ne
dgozman 2013/09/27 19:02:03 I don't really want to move this logic to Blink, e
2364 return widget->webwidget(); 2366 return widget->webwidget();
2365 } 2367 }
2366 2368
2367 WebExternalPopupMenu* RenderViewImpl::createExternalPopupMenu( 2369 WebExternalPopupMenu* RenderViewImpl::createExternalPopupMenu(
2368 const WebPopupMenuInfo& popup_menu_info, 2370 const WebPopupMenuInfo& popup_menu_info,
2369 WebExternalPopupMenuClient* popup_menu_client) { 2371 WebExternalPopupMenuClient* popup_menu_client) {
2370 // An IPC message is sent to the browser to build and display the actual 2372 // An IPC message is sent to the browser to build and display the actual
2371 // popup. The user could have time to click a different select by the time 2373 // popup. The user could have time to click a different select by the time
2372 // the popup is shown. In that case external_popup_menu_ is non NULL. 2374 // the popup is shown. In that case external_popup_menu_ is non NULL.
2373 // By returning NULL in that case, we instruct WebKit to cancel that new 2375 // By returning NULL in that case, we instruct WebKit to cancel that new
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
2648 } 2650 }
2649 2651
2650 void RenderViewImpl::showContextMenu( 2652 void RenderViewImpl::showContextMenu(
2651 WebFrame* frame, const WebContextMenuData& data) { 2653 WebFrame* frame, const WebContextMenuData& data) {
2652 ContextMenuParams params = ContextMenuParamsBuilder::Build(data); 2654 ContextMenuParams params = ContextMenuParamsBuilder::Build(data);
2653 params.source_type = context_menu_source_type_; 2655 params.source_type = context_menu_source_type_;
2654 if (context_menu_source_type_ == ui::MENU_SOURCE_TOUCH_EDIT_MENU) { 2656 if (context_menu_source_type_ == ui::MENU_SOURCE_TOUCH_EDIT_MENU) {
2655 params.x = touch_editing_context_menu_location_.x(); 2657 params.x = touch_editing_context_menu_location_.x();
2656 params.y = touch_editing_context_menu_location_.y(); 2658 params.y = touch_editing_context_menu_location_.y();
2657 } 2659 }
2660 OnShowHostContextMenu(&params);
2658 2661
2659 // Plugins, e.g. PDF, don't currently update the render view when their 2662 // Plugins, e.g. PDF, don't currently update the render view when their
2660 // selected text changes, but the context menu params do contain the updated 2663 // selected text changes, but the context menu params do contain the updated
2661 // selection. If that's the case, update the render view's state just prior 2664 // selection. If that's the case, update the render view's state just prior
2662 // to showing the context menu. 2665 // to showing the context menu.
2663 // TODO(asvitkine): http://crbug.com/152432 2666 // TODO(asvitkine): http://crbug.com/152432
2664 if (ShouldUpdateSelectionTextFromContextMenuParams(selection_text_, 2667 if (ShouldUpdateSelectionTextFromContextMenuParams(selection_text_,
2665 selection_text_offset_, 2668 selection_text_offset_,
2666 selection_range_, 2669 selection_range_,
2667 params)) { 2670 params)) {
(...skipping 3425 matching lines...) Expand 10 before | Expand all | Expand 10 after
6093 return; 6096 return;
6094 if (!webview()->devToolsAgent()) 6097 if (!webview()->devToolsAgent())
6095 return; 6098 return;
6096 webview()->devToolsAgent()->willComposite(); 6099 webview()->devToolsAgent()->willComposite();
6097 } 6100 }
6098 6101
6099 bool RenderViewImpl::AllowPartialSwap() const { 6102 bool RenderViewImpl::AllowPartialSwap() const {
6100 return allow_partial_swap_; 6103 return allow_partial_swap_;
6101 } 6104 }
6102 6105
6106 void RenderViewImpl::SetDeviceEmulationParameters(
6107 bool enabled, float device_scale_factor, float root_layer_scale) {
6108 if (webview()) {
6109 webview()->setDeviceEmulationParameters(
6110 enabled, device_scale_factor, root_layer_scale);
6111 }
6112 }
6113
6103 bool RenderViewImpl::ScheduleFileChooser( 6114 bool RenderViewImpl::ScheduleFileChooser(
6104 const FileChooserParams& params, 6115 const FileChooserParams& params,
6105 WebFileChooserCompletion* completion) { 6116 WebFileChooserCompletion* completion) {
6106 static const size_t kMaximumPendingFileChooseRequests = 4; 6117 static const size_t kMaximumPendingFileChooseRequests = 4;
6107 if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) { 6118 if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) {
6108 // This sanity check prevents too many file choose requests from getting 6119 // This sanity check prevents too many file choose requests from getting
6109 // queued which could DoS the user. Getting these is most likely a 6120 // queued which could DoS the user. Getting these is most likely a
6110 // programming error (there are many ways to DoS the user so it's not 6121 // programming error (there are many ways to DoS the user so it's not
6111 // considered a "real" security check), either in JS requesting many file 6122 // considered a "real" security check), either in JS requesting many file
6112 // choosers to pop up, or in a plugin. 6123 // choosers to pop up, or in a plugin.
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
6520 for (size_t i = 0; i < icon_urls.size(); i++) { 6531 for (size_t i = 0; i < icon_urls.size(); i++) {
6521 WebURL url = icon_urls[i].iconURL(); 6532 WebURL url = icon_urls[i].iconURL();
6522 if (!url.isEmpty()) 6533 if (!url.isEmpty())
6523 urls.push_back(FaviconURL(url, 6534 urls.push_back(FaviconURL(url,
6524 ToFaviconType(icon_urls[i].iconType()))); 6535 ToFaviconType(icon_urls[i].iconType())));
6525 } 6536 }
6526 SendUpdateFaviconURL(urls); 6537 SendUpdateFaviconURL(urls);
6527 } 6538 }
6528 6539
6529 } // namespace content 6540 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698