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

Side by Side Diff: chrome/browser/profile_manager.h

Issue 31014: Port DictionaryValue to use string16 instead of wstring. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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
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 // This class keeps track of the currently-active profiles in the runtime. 5 // This class keeps track of the currently-active profiles in the runtime.
6 6
7 #ifndef CHROME_BROWSER_PROFILE_MANAGER_H__ 7 #ifndef CHROME_BROWSER_PROFILE_MANAGER_H__
8 #define CHROME_BROWSER_PROFILE_MANAGER_H__ 8 #define CHROME_BROWSER_PROFILE_MANAGER_H__
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/file_path.h" 15 #include "base/file_path.h"
16 #include "base/message_loop.h" 16 #include "base/message_loop.h"
17 #include "base/non_thread_safe.h" 17 #include "base/non_thread_safe.h"
18 #include "base/string_util.h"
18 #include "base/system_monitor.h" 19 #include "base/system_monitor.h"
19 #include "base/values.h" 20 #include "base/values.h"
20 #include "chrome/browser/profile.h" 21 #include "chrome/browser/profile.h"
21 22
22 // This is a small storage class that simply represents some metadata about 23 // This is a small storage class that simply represents some metadata about
23 // profiles that are available in the current user data directory. 24 // profiles that are available in the current user data directory.
24 // These are cached in local state so profiles don't need to be scanned 25 // These are cached in local state so profiles don't need to be scanned
25 // for their metadata on every launch. 26 // for their metadata on every launch.
26 class AvailableProfile { 27 class AvailableProfile {
27 public: 28 public:
28 AvailableProfile(const std::wstring& name, 29 AvailableProfile(const std::wstring& name,
29 const std::wstring& id, 30 const std::wstring& id,
30 const FilePath& directory) 31 const FilePath& directory)
31 : name_(name), id_(id), directory_(directory) {} 32 : name_(name), id_(id), directory_(directory) {}
32 33
33 // Decodes a DictionaryValue into an AvailableProfile 34 // Decodes a DictionaryValue into an AvailableProfile
34 static AvailableProfile* FromValue(DictionaryValue* value) { 35 static AvailableProfile* FromValue(DictionaryValue* value) {
35 DCHECK(value); 36 DCHECK(value);
36 std::wstring name, id; 37 string16 name, id;
37 FilePath::StringType directory; 38 FilePath::StringType directory;
38 value->GetString(L"name", &name); 39 value->GetString(ASCIIToUTF16("name"), &name);
39 value->GetString(L"id", &id); 40 value->GetString(ASCIIToUTF16("id"), &id);
40 value->GetString(L"directory", &directory); 41 value->GetString(ASCIIToUTF16("directory"), &directory);
41 return new AvailableProfile(name, id, FilePath(directory)); 42 return new AvailableProfile(UTF16ToWideHack(name), UTF16ToWideHack(id),
43 FilePath(directory));
42 } 44 }
43 45
44 // Encodes this AvailableProfile into a new DictionaryValue 46 // Encodes this AvailableProfile into a new DictionaryValue
45 DictionaryValue* ToValue() { 47 DictionaryValue* ToValue() {
46 DictionaryValue* value = new DictionaryValue; 48 DictionaryValue* value = new DictionaryValue;
47 value->SetString(L"name", name_); 49 value->SetString(ASCIIToUTF16("name"), WideToUTF16Hack(name_));
48 value->SetString(L"id", id_); 50 value->SetString(ASCIIToUTF16("id"), WideToUTF16Hack(id_));
49 value->SetString(L"directory", directory_.value()); 51 value->SetString(ASCIIToUTF16("directory"), directory_.value());
50 return value; 52 return value;
51 } 53 }
52 54
53 std::wstring name() const { return name_; } 55 std::wstring name() const { return name_; }
54 std::wstring id() const { return id_; } 56 std::wstring id() const { return id_; }
55 FilePath directory() const { return directory_; } 57 FilePath directory() const { return directory_; }
56 58
57 private: 59 private:
58 std::wstring name_; // User-visible profile name 60 std::wstring name_; // User-visible profile name
59 std::wstring id_; // Profile identifier 61 std::wstring id_; // Profile identifier
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // We keep a simple vector of profiles rather than something fancier 178 // We keep a simple vector of profiles rather than something fancier
177 // because we expect there to be a small number of profiles active. 179 // because we expect there to be a small number of profiles active.
178 ProfileVector profiles_; 180 ProfileVector profiles_;
179 181
180 AvailableProfileVector available_profiles_; 182 AvailableProfileVector available_profiles_;
181 183
182 DISALLOW_EVIL_CONSTRUCTORS(ProfileManager); 184 DISALLOW_EVIL_CONSTRUCTORS(ProfileManager);
183 }; 185 };
184 186
185 #endif // CHROME_BROWSER_PROFILE_MANAGER_H__ 187 #endif // CHROME_BROWSER_PROFILE_MANAGER_H__
186
OLDNEW
« no previous file with comments | « chrome/browser/page_state.cc ('k') | chrome/browser/safe_browsing/safe_browsing_blocking_page.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698