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

Side by Side Diff: webkit/api/src/BackForwardListClientImpl.cpp

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
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this 1 /*
2 // source code is governed by a BSD-style license that can be found in the 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 // LICENSE file. 3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
4 30
5 #include "config.h" 31 #include "config.h"
32 #include "BackForwardListClientImpl.h"
6 33
7 #include "HistoryItem.h" 34 #include "HistoryItem.h"
8 #undef LOG 35 #include "WebViewClient.h"
9 36
10 #include "webkit/api/public/WebViewClient.h" 37 // FIXME: Remove this once WebViewImpl moves out of glue/.
11 #include "webkit/glue/back_forward_list_client_impl.h"
12 #include "webkit/glue/webview_impl.h" 38 #include "webkit/glue/webview_impl.h"
13 39
14 namespace webkit_glue { 40 using namespace WebCore;
15 41
16 const char kBackForwardNavigationScheme[] = "chrome-back-forward"; 42 namespace WebKit {
17 43
18 BackForwardListClientImpl::BackForwardListClientImpl(WebViewImpl* webview) 44 const char backForwardNavigationScheme[] = "chrome-back-forward";
19 : webview_(webview) { 45
46 BackForwardListClientImpl::BackForwardListClientImpl(WebViewImpl* webView)
47 : m_webView(webView)
48 {
20 } 49 }
21 50
22 BackForwardListClientImpl::~BackForwardListClientImpl() { 51 BackForwardListClientImpl::~BackForwardListClientImpl()
52 {
23 } 53 }
24 54
25 void BackForwardListClientImpl::SetCurrentHistoryItem( 55 void BackForwardListClientImpl::SetCurrentHistoryItem(HistoryItem* item)
26 WebCore::HistoryItem* item) { 56 {
27 previous_item_ = current_item_; 57 m_previousItem = m_currentItem;
28 current_item_ = item; 58 m_currentItem = item;
29 } 59 }
30 60
31 WebCore::HistoryItem* BackForwardListClientImpl::GetPreviousHistoryItem() 61 HistoryItem* BackForwardListClientImpl::GetPreviousHistoryItem() const
32 const { 62 {
33 return previous_item_.get(); 63 return m_previousItem.get();
34 } 64 }
35 65
36 void BackForwardListClientImpl::addItem(PassRefPtr<WebCore::HistoryItem> item) { 66 void BackForwardListClientImpl::addItem(PassRefPtr<HistoryItem> item)
37 previous_item_ = current_item_; 67 {
38 current_item_ = item; 68 m_previousItem = m_currentItem;
69 m_currentItem = item;
39 70
40 // If WebCore adds a new HistoryItem, it means this is a new navigation (ie, 71 // If WebCore adds a new HistoryItem, it means this is a new navigation (ie,
41 // not a reload or back/forward). 72 // not a reload or back/forward).
42 webview_->ObserveNewNavigation(); 73 m_webView->ObserveNewNavigation();
43 74
44 if (webview_->client()) 75 if (m_webView->client())
45 webview_->client()->didAddHistoryItem(); 76 m_webView->client()->didAddHistoryItem();
46 } 77 }
47 78
48 void BackForwardListClientImpl::goToItem(WebCore::HistoryItem* item) { 79 void BackForwardListClientImpl::goToItem(HistoryItem* item)
49 previous_item_ = current_item_; 80 {
50 current_item_ = item; 81 m_previousItem = m_currentItem;
82 m_currentItem = item;
51 83
52 if (pending_history_item_ == item) 84 if (m_pendingHistoryItem == item)
53 pending_history_item_ = NULL; 85 m_pendingHistoryItem = 0;
54 } 86 }
55 87
56 WebCore::HistoryItem* BackForwardListClientImpl::currentItem() { 88 HistoryItem* BackForwardListClientImpl::currentItem()
57 return current_item_.get(); 89 {
90 return m_currentItem.get();
58 } 91 }
59 92
60 WebCore::HistoryItem* BackForwardListClientImpl::itemAtIndex(int index) { 93 HistoryItem* BackForwardListClientImpl::itemAtIndex(int index)
61 if (!webview_->client()) 94 {
62 return NULL; 95 if (!m_webView->client())
96 return 0;
63 97
64 // Since we don't keep the entire back/forward list, we have no way to 98 // 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 99 // properly implement this method. We return a dummy entry instead that we
66 // intercept in our FrameLoaderClient implementation in case WebCore asks 100 // intercept in our FrameLoaderClient implementation in case WebCore asks
67 // to navigate to this HistoryItem. 101 // to navigate to this HistoryItem.
68 102
69 // TODO(darin): We should change WebCore to handle history.{back,forward,go} 103 // FIXME: We should change WebCore to handle history.{back,forward,go}
70 // differently. It should perhaps just ask the FrameLoaderClient to perform 104 // differently. It should perhaps just ask the FrameLoaderClient to
71 // those navigations. 105 // perform those navigations.
72 106
73 WebCore::String url_string = WebCore::String::format( 107 String url_string = String::format(
74 "%s://go/%d", kBackForwardNavigationScheme, index); 108 "%s://go/%d", backForwardNavigationScheme, index);
75 109
76 pending_history_item_ = 110 m_pendingHistoryItem =
77 WebCore::HistoryItem::create(url_string, WebCore::String(), 0.0); 111 HistoryItem::create(url_string, String(), 0.0);
78 return pending_history_item_.get(); 112 return m_pendingHistoryItem.get();
79 } 113 }
80 114
81 int BackForwardListClientImpl::backListCount() { 115 int BackForwardListClientImpl::backListCount()
82 if (!webview_->client()) 116 {
83 return 0; 117 if (!m_webView->client())
118 return 0;
84 119
85 return webview_->client()->historyBackListCount(); 120 return m_webView->client()->historyBackListCount();
86 } 121 }
87 122
88 int BackForwardListClientImpl::forwardListCount() { 123 int BackForwardListClientImpl::forwardListCount()
89 if (!webview_->client()) 124 {
90 return 0; 125 if (!m_webView->client())
126 return 0;
91 127
92 return webview_->client()->historyForwardListCount(); 128 return m_webView->client()->historyForwardListCount();
93 } 129 }
94 130
95 void BackForwardListClientImpl::close() { 131 void BackForwardListClientImpl::close()
96 current_item_ = NULL; 132 {
97 previous_item_ = NULL; 133 m_currentItem = 0;
98 pending_history_item_ = NULL; 134 m_previousItem = 0;
135 m_pendingHistoryItem = 0;
99 } 136 }
100 137
101 } // namespace webkit_glue 138 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698