OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/public/common/page_state.h" | 5 #include "content/public/common/page_state.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/logging.h" | |
9 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
10 #include "content/common/page_state_serialization.h" | 9 #include "content/common/page_state_serialization.h" |
11 | 10 |
12 namespace content { | 11 namespace content { |
13 namespace { | 12 namespace { |
14 | 13 |
15 base::NullableString16 ToNullableString16(const std::string& utf8) { | 14 base::NullableString16 ToNullableString16(const std::string& utf8) { |
16 return base::NullableString16(base::UTF8ToUTF16(utf8), false); | 15 return base::NullableString16(base::UTF8ToUTF16(utf8), false); |
17 } | 16 } |
18 | 17 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 112 } |
114 | 113 |
115 bool PageState::Equals(const PageState& other) const { | 114 bool PageState::Equals(const PageState& other) const { |
116 return data_ == other.data_; | 115 return data_ == other.data_; |
117 } | 116 } |
118 | 117 |
119 const std::string& PageState::ToEncodedData() const { | 118 const std::string& PageState::ToEncodedData() const { |
120 return data_; | 119 return data_; |
121 } | 120 } |
122 | 121 |
123 std::string PageState::GetTopLevelUrlStringTemporaryForBug369661() const { | |
124 ExplodedPageState state; | |
125 CHECK(DecodePageState(data_, &state)); | |
126 | |
127 base::NullableString16& url_string = state.top.url_string; | |
128 CHECK(!url_string.is_null()); | |
129 return base::UTF16ToUTF8(url_string.string()); | |
130 } | |
131 | |
132 std::vector<base::FilePath> PageState::GetReferencedFiles() const { | 122 std::vector<base::FilePath> PageState::GetReferencedFiles() const { |
133 std::vector<base::FilePath> results; | 123 std::vector<base::FilePath> results; |
134 | 124 |
135 ExplodedPageState state; | 125 ExplodedPageState state; |
136 if (DecodePageState(data_, &state)) | 126 if (DecodePageState(data_, &state)) |
137 ToFilePathVector(state.referenced_files, &results); | 127 ToFilePathVector(state.referenced_files, &results); |
138 | 128 |
139 return results; | 129 return results; |
140 } | 130 } |
141 | 131 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 163 } |
174 | 164 |
175 PageState::PageState(const std::string& data) | 165 PageState::PageState(const std::string& data) |
176 : data_(data) { | 166 : data_(data) { |
177 // TODO(darin): Enable this DCHECK once tests have been fixed up to not pass | 167 // TODO(darin): Enable this DCHECK once tests have been fixed up to not pass |
178 // bogus encoded data to CreateFromEncodedData. | 168 // bogus encoded data to CreateFromEncodedData. |
179 //DCHECK(IsValid()); | 169 //DCHECK(IsValid()); |
180 } | 170 } |
181 | 171 |
182 } // namespace content | 172 } // namespace content |
OLD | NEW |