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

Side by Side Diff: third_party/WebKit/Source/web/WebHistoryItem.cpp

Issue 2883793003: Move detached files from web/ to (core/modules)/exported. (Closed)
Patch Set: Created 3 years, 7 months 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
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
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 */
30
31 #include "public/web/WebHistoryItem.h"
32
33 #include "bindings/core/v8/serialization/SerializedScriptValue.h"
34 #include "core/loader/HistoryItem.h"
35 #include "platform/network/EncodedFormData.h"
36 #include "platform/weborigin/KURL.h"
37 #include "platform/wtf/text/StringHash.h"
38 #include "public/platform/WebFloatPoint.h"
39 #include "public/platform/WebHTTPBody.h"
40 #include "public/platform/WebPoint.h"
41 #include "public/platform/WebString.h"
42 #include "public/platform/WebVector.h"
43 #include "public/web/WebSerializedScriptValue.h"
44
45 namespace blink {
46
47 void WebHistoryItem::Initialize() {
48 private_ = HistoryItem::Create();
49 }
50
51 void WebHistoryItem::Reset() {
52 private_.Reset();
53 target_.Reset();
54 }
55
56 void WebHistoryItem::Assign(const WebHistoryItem& other) {
57 private_ = other.private_;
58 target_ = other.target_;
59 }
60
61 WebString WebHistoryItem::UrlString() const {
62 return private_->UrlString();
63 }
64
65 void WebHistoryItem::SetURLString(const WebString& url) {
66 private_->SetURLString(KURL(kParsedURLString, url).GetString());
67 }
68
69 WebString WebHistoryItem::GetReferrer() const {
70 return private_->GetReferrer().referrer;
71 }
72
73 WebReferrerPolicy WebHistoryItem::GetReferrerPolicy() const {
74 return static_cast<WebReferrerPolicy>(
75 private_->GetReferrer().referrer_policy);
76 }
77
78 void WebHistoryItem::SetReferrer(const WebString& referrer,
79 WebReferrerPolicy referrer_policy) {
80 private_->SetReferrer(
81 Referrer(referrer, static_cast<ReferrerPolicy>(referrer_policy)));
82 }
83
84 const WebString& WebHistoryItem::Target() const {
85 return target_;
86 }
87
88 void WebHistoryItem::SetTarget(const WebString& target) {
89 target_ = target;
90 }
91
92 WebFloatPoint WebHistoryItem::VisualViewportScrollOffset() const {
93 ScrollOffset offset = private_->VisualViewportScrollOffset();
94 return WebFloatPoint(offset.Width(), offset.Height());
95 }
96
97 void WebHistoryItem::SetVisualViewportScrollOffset(
98 const WebFloatPoint& scroll_offset) {
99 private_->SetVisualViewportScrollOffset(ToScrollOffset(scroll_offset));
100 }
101
102 WebPoint WebHistoryItem::GetScrollOffset() const {
103 ScrollOffset offset = private_->GetScrollOffset();
104 return WebPoint(offset.Width(), offset.Height());
105 }
106
107 void WebHistoryItem::SetScrollOffset(const WebPoint& scroll_offset) {
108 private_->SetScrollOffset(ScrollOffset(scroll_offset.x, scroll_offset.y));
109 }
110
111 float WebHistoryItem::PageScaleFactor() const {
112 return private_->PageScaleFactor();
113 }
114
115 void WebHistoryItem::SetPageScaleFactor(float scale) {
116 private_->SetPageScaleFactor(scale);
117 }
118
119 WebVector<WebString> WebHistoryItem::GetDocumentState() const {
120 return private_->GetDocumentState();
121 }
122
123 void WebHistoryItem::SetDocumentState(const WebVector<WebString>& state) {
124 // FIXME: would be nice to avoid the intermediate copy
125 Vector<String> ds;
126 for (size_t i = 0; i < state.size(); ++i)
127 ds.push_back(state[i]);
128 private_->SetDocumentState(ds);
129 }
130
131 long long WebHistoryItem::ItemSequenceNumber() const {
132 return private_->ItemSequenceNumber();
133 }
134
135 void WebHistoryItem::SetItemSequenceNumber(long long item_sequence_number) {
136 private_->SetItemSequenceNumber(item_sequence_number);
137 }
138
139 long long WebHistoryItem::DocumentSequenceNumber() const {
140 return private_->DocumentSequenceNumber();
141 }
142
143 void WebHistoryItem::SetDocumentSequenceNumber(
144 long long document_sequence_number) {
145 private_->SetDocumentSequenceNumber(document_sequence_number);
146 }
147
148 WebHistoryScrollRestorationType WebHistoryItem::ScrollRestorationType() const {
149 return static_cast<WebHistoryScrollRestorationType>(
150 private_->ScrollRestorationType());
151 }
152
153 void WebHistoryItem::SetScrollRestorationType(
154 WebHistoryScrollRestorationType type) {
155 private_->SetScrollRestorationType(
156 static_cast<HistoryScrollRestorationType>(type));
157 }
158
159 WebSerializedScriptValue WebHistoryItem::StateObject() const {
160 return WebSerializedScriptValue(private_->StateObject());
161 }
162
163 void WebHistoryItem::SetStateObject(const WebSerializedScriptValue& object) {
164 private_->SetStateObject(object);
165 }
166
167 WebString WebHistoryItem::HttpContentType() const {
168 return private_->FormContentType();
169 }
170
171 void WebHistoryItem::SetHTTPContentType(const WebString& http_content_type) {
172 private_->SetFormContentType(http_content_type);
173 }
174
175 WebHTTPBody WebHistoryItem::HttpBody() const {
176 return WebHTTPBody(private_->FormData());
177 }
178
179 void WebHistoryItem::SetHTTPBody(const WebHTTPBody& http_body) {
180 private_->SetFormData(http_body);
181 }
182
183 WebVector<WebString> WebHistoryItem::GetReferencedFilePaths() const {
184 HashSet<String> file_paths;
185 const EncodedFormData* form_data = private_->FormData();
186 if (form_data) {
187 for (size_t i = 0; i < form_data->Elements().size(); ++i) {
188 const FormDataElement& element = form_data->Elements()[i];
189 if (element.type_ == FormDataElement::kEncodedFile)
190 file_paths.insert(element.filename_);
191 }
192 }
193
194 const Vector<String>& referenced_file_paths =
195 private_->GetReferencedFilePaths();
196 for (size_t i = 0; i < referenced_file_paths.size(); ++i)
197 file_paths.insert(referenced_file_paths[i]);
198
199 Vector<String> results;
200 CopyToVector(file_paths, results);
201 return results;
202 }
203
204 bool WebHistoryItem::DidSaveScrollOrScaleState() const {
205 return private_->DidSaveScrollOrScaleState();
206 }
207
208 void WebHistoryItem::SetDidSaveScrollOrScaleState(
209 bool has_save_scroll_or_scale_state) {
210 private_->SetDidSaveScrollOrScaleState(has_save_scroll_or_scale_state);
211 }
212
213 WebHistoryItem::WebHistoryItem(HistoryItem* item) : private_(item) {}
214
215 WebHistoryItem& WebHistoryItem::operator=(HistoryItem* item) {
216 private_ = item;
217 return *this;
218 }
219
220 WebHistoryItem::operator HistoryItem*() const {
221 return private_.Get();
222 }
223
224 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698