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