| 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 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_emulation_helper_) |
| 2365 device_emulation_helper_->PopupCreated(this, widget); |
| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2448 routing_id_, | 2450 routing_id_, |
| 2449 id, | 2451 id, |
| 2450 base::FilePath::FromUTF16Unsafe(path))); | 2452 base::FilePath::FromUTF16Unsafe(path))); |
| 2451 } | 2453 } |
| 2452 | 2454 |
| 2453 void RenderViewImpl::initializeHelperPluginWebFrame( | 2455 void RenderViewImpl::initializeHelperPluginWebFrame( |
| 2454 WebKit::WebHelperPlugin* plugin) { | 2456 WebKit::WebHelperPlugin* plugin) { |
| 2455 plugin->initializeFrame(main_render_frame_.get()); | 2457 plugin->initializeFrame(main_render_frame_.get()); |
| 2456 } | 2458 } |
| 2457 | 2459 |
| 2460 void RenderViewImpl::emulateDevice( |
| 2461 bool enabled, |
| 2462 const WebKit::WebSize& device_size, |
| 2463 const WebKit::WebRect& view_rect, |
| 2464 float device_scale_factor, |
| 2465 bool fit_to_view) { |
| 2466 if (enabled && webview()) |
| 2467 webview()->settings()->setForceCompositingMode(true); |
| 2468 EmulateDevice(enabled, gfx::Size(device_size), gfx::Rect(view_rect), |
| 2469 device_scale_factor, fit_to_view); |
| 2470 } |
| 2471 |
| 2472 void RenderViewImpl::SetDeviceEmulationScale(float scale) { |
| 2473 if (webview() && webview()->devToolsAgent()) |
| 2474 webview()->devToolsAgent()->setDeviceEmulationScale(scale); |
| 2475 } |
| 2476 |
| 2458 void RenderViewImpl::didStartLoading() { | 2477 void RenderViewImpl::didStartLoading() { |
| 2459 if (is_loading_) { | 2478 if (is_loading_) { |
| 2460 DVLOG(1) << "didStartLoading called while loading"; | 2479 DVLOG(1) << "didStartLoading called while loading"; |
| 2461 return; | 2480 return; |
| 2462 } | 2481 } |
| 2463 | 2482 |
| 2464 is_loading_ = true; | 2483 is_loading_ = true; |
| 2465 | 2484 |
| 2466 Send(new ViewHostMsg_DidStartLoading(routing_id_)); | 2485 Send(new ViewHostMsg_DidStartLoading(routing_id_)); |
| 2467 | 2486 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2648 } | 2667 } |
| 2649 | 2668 |
| 2650 void RenderViewImpl::showContextMenu( | 2669 void RenderViewImpl::showContextMenu( |
| 2651 WebFrame* frame, const WebContextMenuData& data) { | 2670 WebFrame* frame, const WebContextMenuData& data) { |
| 2652 ContextMenuParams params = ContextMenuParamsBuilder::Build(data); | 2671 ContextMenuParams params = ContextMenuParamsBuilder::Build(data); |
| 2653 params.source_type = context_menu_source_type_; | 2672 params.source_type = context_menu_source_type_; |
| 2654 if (context_menu_source_type_ == ui::MENU_SOURCE_TOUCH_EDIT_MENU) { | 2673 if (context_menu_source_type_ == ui::MENU_SOURCE_TOUCH_EDIT_MENU) { |
| 2655 params.x = touch_editing_context_menu_location_.x(); | 2674 params.x = touch_editing_context_menu_location_.x(); |
| 2656 params.y = touch_editing_context_menu_location_.y(); | 2675 params.y = touch_editing_context_menu_location_.y(); |
| 2657 } | 2676 } |
| 2677 if (device_emulation_helper_) |
| 2678 device_emulation_helper_->OnShowContextMenu(this, ¶ms); |
| 2658 | 2679 |
| 2659 // Plugins, e.g. PDF, don't currently update the render view when their | 2680 // 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 | 2681 // 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 | 2682 // selection. If that's the case, update the render view's state just prior |
| 2662 // to showing the context menu. | 2683 // to showing the context menu. |
| 2663 // TODO(asvitkine): http://crbug.com/152432 | 2684 // TODO(asvitkine): http://crbug.com/152432 |
| 2664 if (ShouldUpdateSelectionTextFromContextMenuParams(selection_text_, | 2685 if (ShouldUpdateSelectionTextFromContextMenuParams(selection_text_, |
| 2665 selection_text_offset_, | 2686 selection_text_offset_, |
| 2666 selection_range_, | 2687 selection_range_, |
| 2667 params)) { | 2688 params)) { |
| (...skipping 3852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6520 for (size_t i = 0; i < icon_urls.size(); i++) { | 6541 for (size_t i = 0; i < icon_urls.size(); i++) { |
| 6521 WebURL url = icon_urls[i].iconURL(); | 6542 WebURL url = icon_urls[i].iconURL(); |
| 6522 if (!url.isEmpty()) | 6543 if (!url.isEmpty()) |
| 6523 urls.push_back(FaviconURL(url, | 6544 urls.push_back(FaviconURL(url, |
| 6524 ToFaviconType(icon_urls[i].iconType()))); | 6545 ToFaviconType(icon_urls[i].iconType()))); |
| 6525 } | 6546 } |
| 6526 SendUpdateFaviconURL(urls); | 6547 SendUpdateFaviconURL(urls); |
| 6527 } | 6548 } |
| 6528 | 6549 |
| 6529 } // namespace content | 6550 } // namespace content |
| OLD | NEW |