OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/page_state.h" | 8 #include "chrome/browser/page_state.h" |
9 #include "chrome/common/json_value_serializer.h" | 9 #include "chrome/common/json_value_serializer.h" |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 JSONStringValueSerializer serializer(out); | 55 JSONStringValueSerializer serializer(out); |
56 if (!serializer.Serialize(*state_)) | 56 if (!serializer.Serialize(*state_)) |
57 NOTREACHED(); | 57 NOTREACHED(); |
58 } | 58 } |
59 | 59 |
60 void PageState::SetProperty(const std::wstring& key, | 60 void PageState::SetProperty(const std::wstring& key, |
61 const std::wstring& value) { | 61 const std::wstring& value) { |
62 state_->Set(key, new StringValue(value)); | 62 state_->Set(key, new StringValue(value)); |
63 } | 63 } |
64 | 64 |
65 bool PageState::GetProperty(const std::wstring& key, std::wstring* value) const
{ | 65 bool PageState::GetProperty(const std::wstring& key, |
| 66 std::wstring* value) const { |
66 if (state_->HasKey(key)) { | 67 if (state_->HasKey(key)) { |
67 Value* v; | 68 Value* v; |
68 state_->Get(key, &v); | 69 state_->Get(key, &v); |
69 if (v->GetType() == Value::TYPE_STRING) { | 70 if (v->GetType() == Value::TYPE_STRING) { |
70 StringValue* sv = reinterpret_cast<StringValue*>(v); | 71 StringValue* sv = reinterpret_cast<StringValue*>(v); |
71 sv->GetAsString(value); | 72 sv->GetAsString(value); |
72 return true; | 73 return true; |
73 } | 74 } |
74 } | 75 } |
75 return false; | 76 return false; |
(...skipping 22 matching lines...) Expand all Loading... |
98 } | 99 } |
99 return false; | 100 return false; |
100 } | 101 } |
101 | 102 |
102 PageState* PageState::Copy() const { | 103 PageState* PageState::Copy() const { |
103 PageState* copy = new PageState(); | 104 PageState* copy = new PageState(); |
104 if (state_.get()) | 105 if (state_.get()) |
105 copy->state_.reset(static_cast<DictionaryValue*>(state_->DeepCopy())); | 106 copy->state_.reset(static_cast<DictionaryValue*>(state_->DeepCopy())); |
106 return copy; | 107 return copy; |
107 } | 108 } |
OLD | NEW |