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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 #if defined(OS_WIN) | 653 #if defined(OS_WIN) |
654 focused_plugin_id_(-1), | 654 focused_plugin_id_(-1), |
655 #endif | 655 #endif |
656 #if defined(ENABLE_PLUGINS) | 656 #if defined(ENABLE_PLUGINS) |
657 plugin_find_handler_(NULL), | 657 plugin_find_handler_(NULL), |
658 focused_pepper_plugin_(NULL), | 658 focused_pepper_plugin_(NULL), |
659 pepper_last_mouse_event_target_(NULL), | 659 pepper_last_mouse_event_target_(NULL), |
660 #endif | 660 #endif |
661 enumeration_completion_id_(0), | 661 enumeration_completion_id_(0), |
662 session_storage_namespace_id_(params.session_storage_namespace_id), | 662 session_storage_namespace_id_(params.session_storage_namespace_id), |
663 next_snapshot_id_(0), | |
664 page_scale_factor_is_one_(true), | 663 page_scale_factor_is_one_(true), |
665 debug_info_(params.debug_info) { | 664 debug_info_(params.debug_info) { |
666 } | 665 } |
667 | 666 |
668 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, | 667 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, |
669 CompositorDependencies* compositor_deps, | 668 CompositorDependencies* compositor_deps, |
670 bool was_created_by_renderer) { | 669 bool was_created_by_renderer) { |
671 routing_id_ = params.view_id; | 670 routing_id_ = params.view_id; |
672 surface_id_ = params.surface_id; | 671 surface_id_ = params.surface_id; |
673 if (params.opener_route_id != MSG_ROUTING_NONE && was_created_by_renderer) | 672 if (params.opener_route_id != MSG_ROUTING_NONE && was_created_by_renderer) |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 IPC_MESSAGE_HANDLER( | 1333 IPC_MESSAGE_HANDLER( |
1335 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 1334 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
1336 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 1335 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
1337 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) | 1336 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) |
1338 // TODO(viettrungluu): Move to a separate message filter. | 1337 // TODO(viettrungluu): Move to a separate message filter. |
1339 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryOffsetAndLength, | 1338 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryOffsetAndLength, |
1340 OnSetHistoryOffsetAndLength) | 1339 OnSetHistoryOffsetAndLength) |
1341 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 1340 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
1342 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, | 1341 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, |
1343 OnReleaseDisambiguationPopupBitmap) | 1342 OnReleaseDisambiguationPopupBitmap) |
1344 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, | |
1345 OnWindowSnapshotCompleted) | |
1346 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) | 1343 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) |
1347 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) | 1344 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) |
1348 #if defined(OS_ANDROID) | 1345 #if defined(OS_ANDROID) |
1349 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, | 1346 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, |
1350 OnActivateNearestFindResult) | 1347 OnActivateNearestFindResult) |
1351 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects) | 1348 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects) |
1352 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, | 1349 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, |
1353 OnUpdateTopControlsState) | 1350 OnUpdateTopControlsState) |
1354 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) | 1351 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) |
1355 #elif defined(OS_MACOSX) | 1352 #elif defined(OS_MACOSX) |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog | 1492 // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog |
1496 // it is particularly important that we do not call willEnterModalLoop as | 1493 // it is particularly important that we do not call willEnterModalLoop as |
1497 // that would defer resource loads for the dialog itself. | 1494 // that would defer resource loads for the dialog itself. |
1498 if (RenderThreadImpl::current()) // Will be NULL during unit tests. | 1495 if (RenderThreadImpl::current()) // Will be NULL during unit tests. |
1499 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); | 1496 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); |
1500 | 1497 |
1501 message->EnableMessagePumping(); // Runs a nested message loop. | 1498 message->EnableMessagePumping(); // Runs a nested message loop. |
1502 return Send(message); | 1499 return Send(message); |
1503 } | 1500 } |
1504 | 1501 |
1505 void RenderViewImpl::GetWindowSnapshot(const WindowSnapshotCallback& callback) { | |
1506 int id = next_snapshot_id_++; | |
1507 pending_snapshots_.insert(std::make_pair(id, callback)); | |
1508 ui::LatencyInfo latency_info; | |
1509 latency_info.AddLatencyNumber(ui::WINDOW_OLD_SNAPSHOT_FRAME_NUMBER_COMPONENT, | |
1510 0, | |
1511 id); | |
1512 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor; | |
1513 if (RenderWidgetCompositor* rwc = compositor()) { | |
1514 latency_info_swap_promise_monitor = | |
1515 rwc->CreateLatencyInfoSwapPromiseMonitor(&latency_info).Pass(); | |
1516 } | |
1517 ScheduleCompositeWithForcedRedraw(); | |
1518 } | |
1519 | |
1520 void RenderViewImpl::OnForceRedraw(int id) { | 1502 void RenderViewImpl::OnForceRedraw(int id) { |
1521 ui::LatencyInfo latency_info; | 1503 ui::LatencyInfo latency_info; |
1522 if (id) { | 1504 if (id) { |
1523 latency_info.AddLatencyNumber(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, | 1505 latency_info.AddLatencyNumber(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
1524 0, | 1506 0, |
1525 id); | 1507 id); |
1526 } | 1508 } |
1527 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor; | 1509 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor; |
1528 if (RenderWidgetCompositor* rwc = compositor()) { | 1510 if (RenderWidgetCompositor* rwc = compositor()) { |
1529 latency_info_swap_promise_monitor = | 1511 latency_info_swap_promise_monitor = |
1530 rwc->CreateLatencyInfoSwapPromiseMonitor(&latency_info).Pass(); | 1512 rwc->CreateLatencyInfoSwapPromiseMonitor(&latency_info).Pass(); |
1531 } | 1513 } |
1532 ScheduleCompositeWithForcedRedraw(); | 1514 ScheduleCompositeWithForcedRedraw(); |
1533 } | 1515 } |
1534 | 1516 |
1535 void RenderViewImpl::OnWindowSnapshotCompleted(const int snapshot_id, | |
1536 const gfx::Size& size, const std::vector<unsigned char>& png) { | |
1537 | |
1538 // Any pending snapshots with a lower ID than the one received are considered | |
1539 // to be implicitly complete, and returned the same snapshot data. | |
1540 PendingSnapshotMap::iterator it = pending_snapshots_.begin(); | |
1541 while(it != pending_snapshots_.end()) { | |
1542 if (it->first <= snapshot_id) { | |
1543 it->second.Run(size, png); | |
1544 pending_snapshots_.erase(it++); | |
1545 } else { | |
1546 ++it; | |
1547 } | |
1548 } | |
1549 } | |
1550 | |
1551 // blink::WebViewClient ------------------------------------------------------ | 1517 // blink::WebViewClient ------------------------------------------------------ |
1552 | 1518 |
1553 WebView* RenderViewImpl::createView(WebLocalFrame* creator, | 1519 WebView* RenderViewImpl::createView(WebLocalFrame* creator, |
1554 const WebURLRequest& request, | 1520 const WebURLRequest& request, |
1555 const WebWindowFeatures& features, | 1521 const WebWindowFeatures& features, |
1556 const WebString& frame_name, | 1522 const WebString& frame_name, |
1557 WebNavigationPolicy policy, | 1523 WebNavigationPolicy policy, |
1558 bool suppress_opener) { | 1524 bool suppress_opener) { |
1559 ViewHostMsg_CreateWindow_Params params; | 1525 ViewHostMsg_CreateWindow_Params params; |
1560 params.opener_id = routing_id_; | 1526 params.opener_id = routing_id_; |
(...skipping 2467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4028 std::vector<gfx::Size> sizes; | 3994 std::vector<gfx::Size> sizes; |
4029 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 3995 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4030 if (!url.isEmpty()) | 3996 if (!url.isEmpty()) |
4031 urls.push_back( | 3997 urls.push_back( |
4032 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 3998 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4033 } | 3999 } |
4034 SendUpdateFaviconURL(urls); | 4000 SendUpdateFaviconURL(urls); |
4035 } | 4001 } |
4036 | 4002 |
4037 } // namespace content | 4003 } // namespace content |
OLD | NEW |