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

Side by Side Diff: chrome/browser/prefs/session_startup_pref.cc

Issue 104493005: Update some uses of Value in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/prefs/session_startup_pref.h" 5 #include "chrome/browser/prefs/session_startup_pref.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 DCHECK(prefs); 106 DCHECK(prefs);
107 107
108 if (!SessionStartupPref::TypeIsManaged(prefs)) 108 if (!SessionStartupPref::TypeIsManaged(prefs))
109 prefs->SetInteger(prefs::kRestoreOnStartup, TypeToPrefValue(pref.type)); 109 prefs->SetInteger(prefs::kRestoreOnStartup, TypeToPrefValue(pref.type));
110 110
111 if (!SessionStartupPref::URLsAreManaged(prefs)) { 111 if (!SessionStartupPref::URLsAreManaged(prefs)) {
112 // Always save the URLs, that way the UI can remain consistent even if the 112 // Always save the URLs, that way the UI can remain consistent even if the
113 // user changes the startup type pref. 113 // user changes the startup type pref.
114 // Ownership of the ListValue retains with the pref service. 114 // Ownership of the ListValue retains with the pref service.
115 ListPrefUpdate update(prefs, prefs::kURLsToRestoreOnStartup); 115 ListPrefUpdate update(prefs, prefs::kURLsToRestoreOnStartup);
116 ListValue* url_pref_list = update.Get(); 116 base::ListValue* url_pref_list = update.Get();
117 DCHECK(url_pref_list); 117 DCHECK(url_pref_list);
118 url_pref_list->Clear(); 118 url_pref_list->Clear();
119 for (size_t i = 0; i < pref.urls.size(); ++i) { 119 for (size_t i = 0; i < pref.urls.size(); ++i) {
120 url_pref_list->Set(static_cast<int>(i), 120 url_pref_list->Set(static_cast<int>(i),
121 new StringValue(pref.urls[i].spec())); 121 new base::StringValue(pref.urls[i].spec()));
122 } 122 }
123 } 123 }
124 } 124 }
125 125
126 // static 126 // static
127 SessionStartupPref SessionStartupPref::GetStartupPref(Profile* profile) { 127 SessionStartupPref SessionStartupPref::GetStartupPref(Profile* profile) {
128 DCHECK(profile); 128 DCHECK(profile);
129 return GetStartupPref(profile->GetPrefs()); 129 return GetStartupPref(profile->GetPrefs());
130 } 130 }
131 131
132 // static 132 // static
133 SessionStartupPref SessionStartupPref::GetStartupPref(PrefService* prefs) { 133 SessionStartupPref SessionStartupPref::GetStartupPref(PrefService* prefs) {
134 DCHECK(prefs); 134 DCHECK(prefs);
135 135
136 MigrateIfNecessary(prefs); 136 MigrateIfNecessary(prefs);
137 MigrateMacDefaultPrefIfNecessary(prefs); 137 MigrateMacDefaultPrefIfNecessary(prefs);
138 138
139 SessionStartupPref pref( 139 SessionStartupPref pref(
140 PrefValueToType(prefs->GetInteger(prefs::kRestoreOnStartup))); 140 PrefValueToType(prefs->GetInteger(prefs::kRestoreOnStartup)));
141 141
142 // Always load the urls, even if the pref type isn't URLS. This way the 142 // Always load the urls, even if the pref type isn't URLS. This way the
143 // preferences panels can show the user their last choice. 143 // preferences panels can show the user their last choice.
144 const ListValue* url_list = prefs->GetList(prefs::kURLsToRestoreOnStartup); 144 const base::ListValue* url_list =
145 prefs->GetList(prefs::kURLsToRestoreOnStartup);
145 URLListToPref(url_list, &pref); 146 URLListToPref(url_list, &pref);
146 147
147 return pref; 148 return pref;
148 } 149 }
149 150
150 // static 151 // static
151 void SessionStartupPref::MigrateIfNecessary(PrefService* prefs) { 152 void SessionStartupPref::MigrateIfNecessary(PrefService* prefs) {
152 DCHECK(prefs); 153 DCHECK(prefs);
153 154
154 // Check if we need to migrate the old version of the startup URLs preference 155 // Check if we need to migrate the old version of the startup URLs preference
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 case kPrefValueLast: return SessionStartupPref::LAST; 296 case kPrefValueLast: return SessionStartupPref::LAST;
296 case kPrefValueURLs: return SessionStartupPref::URLS; 297 case kPrefValueURLs: return SessionStartupPref::URLS;
297 case kPrefValueHomePage: return SessionStartupPref::HOMEPAGE; 298 case kPrefValueHomePage: return SessionStartupPref::HOMEPAGE;
298 default: return SessionStartupPref::DEFAULT; 299 default: return SessionStartupPref::DEFAULT;
299 } 300 }
300 } 301 }
301 302
302 SessionStartupPref::SessionStartupPref(Type type) : type(type) {} 303 SessionStartupPref::SessionStartupPref(Type type) : type(type) {}
303 304
304 SessionStartupPref::~SessionStartupPref() {} 305 SessionStartupPref::~SessionStartupPref() {}
OLDNEW
« no previous file with comments | « chrome/browser/prefs/proxy_policy_unittest.cc ('k') | chrome/browser/prefs/session_startup_pref_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698