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

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

Issue 10035043: Update RestoreOnStartupPolicyHandler to translate to the correct preferences (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: \n Created 8 years, 8 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/prefs/session_startup_pref.h ('k') | chrome/test/functional/policy.py » ('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) 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/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/net/url_fixer_upper.h" 10 #include "chrome/browser/net/url_fixer_upper.h"
11 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
12 #include "chrome/browser/prefs/scoped_user_pref_update.h" 12 #include "chrome/browser/prefs/scoped_user_pref_update.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/protector/protected_prefs_watcher.h" 14 #include "chrome/browser/protector/protected_prefs_watcher.h"
15 #include "chrome/browser/protector/protector_service.h" 15 #include "chrome/browser/protector/protector_service.h"
16 #include "chrome/browser/protector/protector_service_factory.h" 16 #include "chrome/browser/protector/protector_service_factory.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 18
19 #if defined(OS_MACOSX) 19 #if defined(OS_MACOSX)
20 #include "chrome/browser/ui/cocoa/window_restore_utils.h" 20 #include "chrome/browser/ui/cocoa/window_restore_utils.h"
21 #endif 21 #endif
22 22
23 using protector::ProtectedPrefsWatcher; 23 using protector::ProtectedPrefsWatcher;
24 using protector::ProtectorServiceFactory; 24 using protector::ProtectorServiceFactory;
25 25
26 namespace { 26 namespace {
27 27
28 // For historical reasons the enum and value registered in the prefs don't line
29 // up. These are the values registered in prefs.
30 const int kPrefValueHomePage = 0; // Deprecated
31 const int kPrefValueLast = 1;
32 const int kPrefValueURLs = 4;
33 const int kPrefValueNewTab = 5;
34
35 // Converts a SessionStartupPref::Type to an integer written to prefs. 28 // Converts a SessionStartupPref::Type to an integer written to prefs.
36 int TypeToPrefValue(SessionStartupPref::Type type) { 29 int TypeToPrefValue(SessionStartupPref::Type type) {
37 switch (type) { 30 switch (type) {
38 case SessionStartupPref::LAST: return kPrefValueLast; 31 case SessionStartupPref::LAST: return SessionStartupPref::kPrefValueLast;
39 case SessionStartupPref::URLS: return kPrefValueURLs; 32 case SessionStartupPref::URLS: return SessionStartupPref::kPrefValueURLs;
40 default: return kPrefValueNewTab; 33 default: return SessionStartupPref::kPrefValueNewTab;
41 } 34 }
42 } 35 }
43 36
44 void SetNewURLList(PrefService* prefs) { 37 void SetNewURLList(PrefService* prefs) {
45 ListValue new_url_pref_list; 38 ListValue new_url_pref_list;
46 StringValue* home_page = new StringValue(prefs->GetString(prefs::kHomePage)); 39 StringValue* home_page = new StringValue(prefs->GetString(prefs::kHomePage));
47 new_url_pref_list.Append(home_page); 40 new_url_pref_list.Append(home_page);
48 prefs->Set(prefs::kURLsToRestoreOnStartup, new_url_pref_list); 41 prefs->Set(prefs::kURLsToRestoreOnStartup, new_url_pref_list);
49 } 42 }
50 43
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 CHECK(prefs_watcher->GetBackupForPref( 200 CHECK(prefs_watcher->GetBackupForPref(
208 prefs::kURLsToRestoreOnStartup)->GetAsList(&url_list)); 201 prefs::kURLsToRestoreOnStartup)->GetAsList(&url_list));
209 URLListToPref(url_list, &backup_pref); 202 URLListToPref(url_list, &backup_pref);
210 203
211 return backup_pref; 204 return backup_pref;
212 } 205 }
213 206
214 SessionStartupPref::SessionStartupPref(Type type) : type(type) {} 207 SessionStartupPref::SessionStartupPref(Type type) : type(type) {}
215 208
216 SessionStartupPref::~SessionStartupPref() {} 209 SessionStartupPref::~SessionStartupPref() {}
OLDNEW
« no previous file with comments | « chrome/browser/prefs/session_startup_pref.h ('k') | chrome/test/functional/policy.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698