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 "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 2321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2332 // Copy over the alternate error page URL so we can have alt error pages in | 2332 // Copy over the alternate error page URL so we can have alt error pages in |
2333 // the new render view (we don't need the browser to send the URL back down). | 2333 // the new render view (we don't need the browser to send the URL back down). |
2334 view->alternate_error_page_url_ = alternate_error_page_url_; | 2334 view->alternate_error_page_url_ = alternate_error_page_url_; |
2335 | 2335 |
2336 return view->webview(); | 2336 return view->webview(); |
2337 } | 2337 } |
2338 | 2338 |
2339 WebWidget* RenderViewImpl::createPopupMenu(WebKit::WebPopupType popup_type) { | 2339 WebWidget* RenderViewImpl::createPopupMenu(WebKit::WebPopupType popup_type) { |
2340 RenderWidget* widget = | 2340 RenderWidget* widget = |
2341 RenderWidget::Create(routing_id_, popup_type, screen_info_); | 2341 RenderWidget::Create(routing_id_, popup_type, screen_info_); |
| 2342 if (screen_metrics_emulator_) { |
| 2343 widget->SetPopupOriginAdjustmentsForEmulation( |
| 2344 screen_metrics_emulator_.get()); |
| 2345 } |
2342 return widget->webwidget(); | 2346 return widget->webwidget(); |
2343 } | 2347 } |
2344 | 2348 |
2345 WebExternalPopupMenu* RenderViewImpl::createExternalPopupMenu( | 2349 WebExternalPopupMenu* RenderViewImpl::createExternalPopupMenu( |
2346 const WebPopupMenuInfo& popup_menu_info, | 2350 const WebPopupMenuInfo& popup_menu_info, |
2347 WebExternalPopupMenuClient* popup_menu_client) { | 2351 WebExternalPopupMenuClient* popup_menu_client) { |
2348 // An IPC message is sent to the browser to build and display the actual | 2352 // An IPC message is sent to the browser to build and display the actual |
2349 // popup. The user could have time to click a different select by the time | 2353 // popup. The user could have time to click a different select by the time |
2350 // the popup is shown. In that case external_popup_menu_ is non NULL. | 2354 // the popup is shown. In that case external_popup_menu_ is non NULL. |
2351 // By returning NULL in that case, we instruct WebKit to cancel that new | 2355 // By returning NULL in that case, we instruct WebKit to cancel that new |
2352 // popup. So from the user perspective, only the first one will show, and | 2356 // popup. So from the user perspective, only the first one will show, and |
2353 // will have to close the first one before another one can be shown. | 2357 // will have to close the first one before another one can be shown. |
2354 if (external_popup_menu_) | 2358 if (external_popup_menu_) |
2355 return NULL; | 2359 return NULL; |
2356 external_popup_menu_.reset( | 2360 external_popup_menu_.reset( |
2357 new ExternalPopupMenu(this, popup_menu_info, popup_menu_client)); | 2361 new ExternalPopupMenu(this, popup_menu_info, popup_menu_client)); |
| 2362 if (screen_metrics_emulator_) { |
| 2363 SetExternalPopupOriginAdjustmentsForEmulation( |
| 2364 external_popup_menu_.get(), screen_metrics_emulator_.get()); |
| 2365 } |
2358 return external_popup_menu_.get(); | 2366 return external_popup_menu_.get(); |
2359 } | 2367 } |
2360 | 2368 |
2361 WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace() { | 2369 WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace() { |
2362 CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); | 2370 CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); |
2363 return new WebStorageNamespaceImpl(session_storage_namespace_id_); | 2371 return new WebStorageNamespaceImpl(session_storage_namespace_id_); |
2364 } | 2372 } |
2365 | 2373 |
2366 bool RenderViewImpl::shouldReportDetailedMessageForSource( | 2374 bool RenderViewImpl::shouldReportDetailedMessageForSource( |
2367 const WebString& source) { | 2375 const WebString& source) { |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2626 } | 2634 } |
2627 | 2635 |
2628 void RenderViewImpl::showContextMenu( | 2636 void RenderViewImpl::showContextMenu( |
2629 WebFrame* frame, const WebContextMenuData& data) { | 2637 WebFrame* frame, const WebContextMenuData& data) { |
2630 ContextMenuParams params = ContextMenuParamsBuilder::Build(data); | 2638 ContextMenuParams params = ContextMenuParamsBuilder::Build(data); |
2631 params.source_type = context_menu_source_type_; | 2639 params.source_type = context_menu_source_type_; |
2632 if (context_menu_source_type_ == ui::MENU_SOURCE_TOUCH_EDIT_MENU) { | 2640 if (context_menu_source_type_ == ui::MENU_SOURCE_TOUCH_EDIT_MENU) { |
2633 params.x = touch_editing_context_menu_location_.x(); | 2641 params.x = touch_editing_context_menu_location_.x(); |
2634 params.y = touch_editing_context_menu_location_.y(); | 2642 params.y = touch_editing_context_menu_location_.y(); |
2635 } | 2643 } |
| 2644 OnShowHostContextMenu(¶ms); |
2636 | 2645 |
2637 // Plugins, e.g. PDF, don't currently update the render view when their | 2646 // Plugins, e.g. PDF, don't currently update the render view when their |
2638 // selected text changes, but the context menu params do contain the updated | 2647 // selected text changes, but the context menu params do contain the updated |
2639 // selection. If that's the case, update the render view's state just prior | 2648 // selection. If that's the case, update the render view's state just prior |
2640 // to showing the context menu. | 2649 // to showing the context menu. |
2641 // TODO(asvitkine): http://crbug.com/152432 | 2650 // TODO(asvitkine): http://crbug.com/152432 |
2642 if (ShouldUpdateSelectionTextFromContextMenuParams(selection_text_, | 2651 if (ShouldUpdateSelectionTextFromContextMenuParams(selection_text_, |
2643 selection_text_offset_, | 2652 selection_text_offset_, |
2644 selection_range_, | 2653 selection_range_, |
2645 params)) { | 2654 params)) { |
(...skipping 3431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6077 return; | 6086 return; |
6078 if (!webview()->devToolsAgent()) | 6087 if (!webview()->devToolsAgent()) |
6079 return; | 6088 return; |
6080 webview()->devToolsAgent()->willComposite(); | 6089 webview()->devToolsAgent()->willComposite(); |
6081 } | 6090 } |
6082 | 6091 |
6083 bool RenderViewImpl::AllowPartialSwap() const { | 6092 bool RenderViewImpl::AllowPartialSwap() const { |
6084 return allow_partial_swap_; | 6093 return allow_partial_swap_; |
6085 } | 6094 } |
6086 | 6095 |
| 6096 void RenderViewImpl::SetScreenMetricsEmulationParameters( |
| 6097 float device_scale_factor, float root_layer_scale) { |
| 6098 if (webview()) { |
| 6099 webview()->setCompositorDeviceScaleFactorOverride(device_scale_factor); |
| 6100 webview()->setRootLayerScaleTransform(root_layer_scale); |
| 6101 } |
| 6102 } |
| 6103 |
6087 bool RenderViewImpl::ScheduleFileChooser( | 6104 bool RenderViewImpl::ScheduleFileChooser( |
6088 const FileChooserParams& params, | 6105 const FileChooserParams& params, |
6089 WebFileChooserCompletion* completion) { | 6106 WebFileChooserCompletion* completion) { |
6090 static const size_t kMaximumPendingFileChooseRequests = 4; | 6107 static const size_t kMaximumPendingFileChooseRequests = 4; |
6091 if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) { | 6108 if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) { |
6092 // This sanity check prevents too many file choose requests from getting | 6109 // This sanity check prevents too many file choose requests from getting |
6093 // queued which could DoS the user. Getting these is most likely a | 6110 // queued which could DoS the user. Getting these is most likely a |
6094 // programming error (there are many ways to DoS the user so it's not | 6111 // programming error (there are many ways to DoS the user so it's not |
6095 // considered a "real" security check), either in JS requesting many file | 6112 // considered a "real" security check), either in JS requesting many file |
6096 // choosers to pop up, or in a plugin. | 6113 // choosers to pop up, or in a plugin. |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6505 for (size_t i = 0; i < icon_urls.size(); i++) { | 6522 for (size_t i = 0; i < icon_urls.size(); i++) { |
6506 WebURL url = icon_urls[i].iconURL(); | 6523 WebURL url = icon_urls[i].iconURL(); |
6507 if (!url.isEmpty()) | 6524 if (!url.isEmpty()) |
6508 urls.push_back(FaviconURL(url, | 6525 urls.push_back(FaviconURL(url, |
6509 ToFaviconType(icon_urls[i].iconType()))); | 6526 ToFaviconType(icon_urls[i].iconType()))); |
6510 } | 6527 } |
6511 SendUpdateFaviconURL(urls); | 6528 SendUpdateFaviconURL(urls); |
6512 } | 6529 } |
6513 | 6530 |
6514 } // namespace content | 6531 } // namespace content |
OLD | NEW |