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