Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1022)

Side by Side Diff: webkit/glue/back_forward_list_client_impl.cc

Issue 338041: Move a bunch of files into webkit/api/src... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file.
4
5 #include "config.h"
6
7 #include "HistoryItem.h"
8 #undef LOG
9
10 #include "webkit/api/public/WebViewClient.h"
11 #include "webkit/glue/back_forward_list_client_impl.h"
12 #include "webkit/glue/webview_impl.h"
13
14 namespace webkit_glue {
15
16 const char kBackForwardNavigationScheme[] = "chrome-back-forward";
17
18 BackForwardListClientImpl::BackForwardListClientImpl(WebViewImpl* webview)
19 : webview_(webview) {
20 }
21
22 BackForwardListClientImpl::~BackForwardListClientImpl() {
23 }
24
25 void BackForwardListClientImpl::SetCurrentHistoryItem(
26 WebCore::HistoryItem* item) {
27 previous_item_ = current_item_;
28 current_item_ = item;
29 }
30
31 WebCore::HistoryItem* BackForwardListClientImpl::GetPreviousHistoryItem()
32 const {
33 return previous_item_.get();
34 }
35
36 void BackForwardListClientImpl::addItem(PassRefPtr<WebCore::HistoryItem> item) {
37 previous_item_ = current_item_;
38 current_item_ = item;
39
40 // If WebCore adds a new HistoryItem, it means this is a new navigation (ie,
41 // not a reload or back/forward).
42 webview_->ObserveNewNavigation();
43
44 if (webview_->client())
45 webview_->client()->didAddHistoryItem();
46 }
47
48 void BackForwardListClientImpl::goToItem(WebCore::HistoryItem* item) {
49 previous_item_ = current_item_;
50 current_item_ = item;
51
52 if (pending_history_item_ == item)
53 pending_history_item_ = NULL;
54 }
55
56 WebCore::HistoryItem* BackForwardListClientImpl::currentItem() {
57 return current_item_.get();
58 }
59
60 WebCore::HistoryItem* BackForwardListClientImpl::itemAtIndex(int index) {
61 if (!webview_->client())
62 return NULL;
63
64 // Since we don't keep the entire back/forward list, we have no way to
65 // properly implement this method. We return a dummy entry instead that we
66 // intercept in our FrameLoaderClient implementation in case WebCore asks
67 // to navigate to this HistoryItem.
68
69 // TODO(darin): We should change WebCore to handle history.{back,forward,go}
70 // differently. It should perhaps just ask the FrameLoaderClient to perform
71 // those navigations.
72
73 WebCore::String url_string = WebCore::String::format(
74 "%s://go/%d", kBackForwardNavigationScheme, index);
75
76 pending_history_item_ =
77 WebCore::HistoryItem::create(url_string, WebCore::String(), 0.0);
78 return pending_history_item_.get();
79 }
80
81 int BackForwardListClientImpl::backListCount() {
82 if (!webview_->client())
83 return 0;
84
85 return webview_->client()->historyBackListCount();
86 }
87
88 int BackForwardListClientImpl::forwardListCount() {
89 if (!webview_->client())
90 return 0;
91
92 return webview_->client()->historyForwardListCount();
93 }
94
95 void BackForwardListClientImpl::close() {
96 current_item_ = NULL;
97 previous_item_ = NULL;
98 pending_history_item_ = NULL;
99 }
100
101 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698