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 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 | 1378 |
1379 // Sends the last committed session history state to the browser so it will be | 1379 // Sends the last committed session history state to the browser so it will be |
1380 // saved before we navigate to a new page. This must be called *before* the | 1380 // saved before we navigate to a new page. This must be called *before* the |
1381 // page ID has been updated so we know what it was. | 1381 // page ID has been updated so we know what it was. |
1382 void RenderViewImpl::UpdateSessionHistory(WebFrame* frame) { | 1382 void RenderViewImpl::UpdateSessionHistory(WebFrame* frame) { |
1383 // If we have a valid page ID at this point, then it corresponds to the page | 1383 // If we have a valid page ID at this point, then it corresponds to the page |
1384 // we are navigating away from. Otherwise, this is the first navigation, so | 1384 // we are navigating away from. Otherwise, this is the first navigation, so |
1385 // there is no past session history to record. | 1385 // there is no past session history to record. |
1386 if (page_id_ == -1) | 1386 if (page_id_ == -1) |
1387 return; | 1387 return; |
1388 | 1388 SendUpdateState(history_controller_->GetPreviousEntry()); |
1389 WebHistoryItem item = history_controller_->GetPreviousItemForExport(); | |
1390 SendUpdateState(item); | |
1391 } | 1389 } |
1392 | 1390 |
1393 void RenderViewImpl::SendUpdateState(const WebHistoryItem& item) { | 1391 void RenderViewImpl::SendUpdateState(HistoryEntry* entry) { |
1394 if (item.isNull()) | 1392 if (!entry) |
1395 return; | 1393 return; |
1396 | 1394 |
1397 // Don't send state updates for kSwappedOutURL. | 1395 // Don't send state updates for kSwappedOutURL. |
1398 if (item.urlString() == WebString::fromUTF8(kSwappedOutURL)) | 1396 if (entry->root().urlString() == WebString::fromUTF8(kSwappedOutURL)) |
1399 return; | 1397 return; |
1400 | 1398 |
1401 Send(new ViewHostMsg_UpdateState( | 1399 Send(new ViewHostMsg_UpdateState( |
1402 routing_id_, page_id_, HistoryItemToPageState(item))); | 1400 routing_id_, page_id_, HistoryEntryToPageState(entry))); |
1403 } | 1401 } |
1404 | 1402 |
1405 // WebViewDelegate ------------------------------------------------------------ | 1403 // WebViewDelegate ------------------------------------------------------------ |
1406 | 1404 |
1407 void RenderViewImpl::LoadNavigationErrorPage( | 1405 void RenderViewImpl::LoadNavigationErrorPage( |
1408 WebFrame* frame, | 1406 WebFrame* frame, |
1409 const WebURLRequest& failed_request, | 1407 const WebURLRequest& failed_request, |
1410 const WebURLError& error, | 1408 const WebURLError& error, |
1411 bool replace) { | 1409 bool replace) { |
1412 std::string error_html; | 1410 std::string error_html; |
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2719 routing_id_, reinterpret_cast<int64>(player))); | 2717 routing_id_, reinterpret_cast<int64>(player))); |
2720 } | 2718 } |
2721 | 2719 |
2722 void RenderViewImpl::PlayerGone(blink::WebMediaPlayer* player) { | 2720 void RenderViewImpl::PlayerGone(blink::WebMediaPlayer* player) { |
2723 DidPause(player); | 2721 DidPause(player); |
2724 } | 2722 } |
2725 | 2723 |
2726 void RenderViewImpl::SyncNavigationState() { | 2724 void RenderViewImpl::SyncNavigationState() { |
2727 if (!webview()) | 2725 if (!webview()) |
2728 return; | 2726 return; |
2729 | 2727 SendUpdateState(history_controller_->GetCurrentEntry()); |
2730 WebHistoryItem item = history_controller_->GetCurrentItemForExport(); | |
2731 SendUpdateState(item); | |
2732 } | 2728 } |
2733 | 2729 |
2734 GURL RenderViewImpl::GetLoadingUrl(blink::WebFrame* frame) const { | 2730 GURL RenderViewImpl::GetLoadingUrl(blink::WebFrame* frame) const { |
2735 WebDataSource* ds = frame->dataSource(); | 2731 WebDataSource* ds = frame->dataSource(); |
2736 if (ds->hasUnreachableURL()) | 2732 if (ds->hasUnreachableURL()) |
2737 return ds->unreachableURL(); | 2733 return ds->unreachableURL(); |
2738 | 2734 |
2739 const WebURLRequest& request = ds->request(); | 2735 const WebURLRequest& request = ds->request(); |
2740 return request.url(); | 2736 return request.url(); |
2741 } | 2737 } |
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4440 std::vector<gfx::Size> sizes; | 4436 std::vector<gfx::Size> sizes; |
4441 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4437 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4442 if (!url.isEmpty()) | 4438 if (!url.isEmpty()) |
4443 urls.push_back( | 4439 urls.push_back( |
4444 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4440 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4445 } | 4441 } |
4446 SendUpdateFaviconURL(urls); | 4442 SendUpdateFaviconURL(urls); |
4447 } | 4443 } |
4448 | 4444 |
4449 } // namespace content | 4445 } // namespace content |
OLD | NEW |