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 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2712 routing_id_, reinterpret_cast<int64>(player))); | 2710 routing_id_, reinterpret_cast<int64>(player))); |
2713 } | 2711 } |
2714 | 2712 |
2715 void RenderViewImpl::PlayerGone(blink::WebMediaPlayer* player) { | 2713 void RenderViewImpl::PlayerGone(blink::WebMediaPlayer* player) { |
2716 DidPause(player); | 2714 DidPause(player); |
2717 } | 2715 } |
2718 | 2716 |
2719 void RenderViewImpl::SyncNavigationState() { | 2717 void RenderViewImpl::SyncNavigationState() { |
2720 if (!webview()) | 2718 if (!webview()) |
2721 return; | 2719 return; |
2722 | 2720 SendUpdateState(history_controller_->GetCurrentEntry()); |
2723 WebHistoryItem item = history_controller_->GetCurrentItemForExport(); | |
2724 SendUpdateState(item); | |
2725 } | 2721 } |
2726 | 2722 |
2727 GURL RenderViewImpl::GetLoadingUrl(blink::WebFrame* frame) const { | 2723 GURL RenderViewImpl::GetLoadingUrl(blink::WebFrame* frame) const { |
2728 WebDataSource* ds = frame->dataSource(); | 2724 WebDataSource* ds = frame->dataSource(); |
2729 if (ds->hasUnreachableURL()) | 2725 if (ds->hasUnreachableURL()) |
2730 return ds->unreachableURL(); | 2726 return ds->unreachableURL(); |
2731 | 2727 |
2732 const WebURLRequest& request = ds->request(); | 2728 const WebURLRequest& request = ds->request(); |
2733 return request.url(); | 2729 return request.url(); |
2734 } | 2730 } |
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4434 std::vector<gfx::Size> sizes; | 4430 std::vector<gfx::Size> sizes; |
4435 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4431 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4436 if (!url.isEmpty()) | 4432 if (!url.isEmpty()) |
4437 urls.push_back( | 4433 urls.push_back( |
4438 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4434 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4439 } | 4435 } |
4440 SendUpdateFaviconURL(urls); | 4436 SendUpdateFaviconURL(urls); |
4441 } | 4437 } |
4442 | 4438 |
4443 } // namespace content | 4439 } // namespace content |
OLD | NEW |