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

Side by Side Diff: chrome/browser/page_state.cc

Issue 3056029: Move the number conversions from string_util to a new file.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/page_info_model.cc ('k') | chrome/browser/parsers/metadata_parser_filebase.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/page_state.h" 11 #include "chrome/browser/page_state.h"
12 #include "chrome/common/json_value_serializer.h" 12 #include "chrome/common/json_value_serializer.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 #include "net/base/escape.h" 14 #include "net/base/escape.h"
15 15
16 void PageState::InitWithURL(const GURL& url) { 16 void PageState::InitWithURL(const GURL& url) {
17 // Reset our state 17 // Reset our state
18 state_.reset(new DictionaryValue); 18 state_.reset(new DictionaryValue);
19 19
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 if (v->GetType() == Value::TYPE_STRING) { 73 if (v->GetType() == Value::TYPE_STRING) {
74 StringValue* sv = reinterpret_cast<StringValue*>(v); 74 StringValue* sv = reinterpret_cast<StringValue*>(v);
75 sv->GetAsString(value); 75 sv->GetAsString(value);
76 return true; 76 return true;
77 } 77 }
78 } 78 }
79 return false; 79 return false;
80 } 80 }
81 81
82 void PageState::SetInt64Property(const std::wstring& key, int64 value) { 82 void PageState::SetInt64Property(const std::wstring& key, int64 value) {
83 SetProperty(key, Int64ToWString(value)); 83 SetProperty(key, UTF8ToWide(base::Int64ToString(value)));
84 } 84 }
85 85
86 bool PageState::GetInt64Property(const std::wstring& key, int64* value) const { 86 bool PageState::GetInt64Property(const std::wstring& key, int64* value) const {
87 std::wstring v; 87 std::wstring v;
88 if (GetProperty(key, &v)) { 88 if (GetProperty(key, &v)) {
89 return StringToInt64(WideToUTF16Hack(v), value); 89 return base::StringToInt64(WideToUTF8(v), value);
90 } 90 }
91 return false; 91 return false;
92 } 92 }
93 93
94 void PageState::SetIntProperty(const std::wstring& key, int value) { 94 void PageState::SetIntProperty(const std::wstring& key, int value) {
95 SetProperty(key, IntToWString(value)); 95 SetProperty(key, UTF8ToWide(base::IntToString(value)));
96 } 96 }
97 97
98 bool PageState::GetIntProperty(const std::wstring& key, int* value) const { 98 bool PageState::GetIntProperty(const std::wstring& key, int* value) const {
99 std::wstring v; 99 std::wstring v;
100 if (GetProperty(key, &v)) { 100 if (GetProperty(key, &v)) {
101 return StringToInt(WideToUTF16Hack(v), value); 101 return base::StringToInt(WideToUTF8(v), value);
102 } 102 }
103 return false; 103 return false;
104 } 104 }
105 105
106 PageState* PageState::Copy() const { 106 PageState* PageState::Copy() const {
107 PageState* copy = new PageState(); 107 PageState* copy = new PageState();
108 if (state_.get()) 108 if (state_.get())
109 copy->state_.reset(static_cast<DictionaryValue*>(state_->DeepCopy())); 109 copy->state_.reset(static_cast<DictionaryValue*>(state_->DeepCopy()));
110 return copy; 110 return copy;
111 } 111 }
OLDNEW
« no previous file with comments | « chrome/browser/page_info_model.cc ('k') | chrome/browser/parsers/metadata_parser_filebase.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698