OLD | NEW |
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" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 GURL fixed_url = URLFixerUpper::FixupURL(url_text, ""); | 55 GURL fixed_url = URLFixerUpper::FixupURL(url_text, ""); |
56 pref->urls.push_back(fixed_url); | 56 pref->urls.push_back(fixed_url); |
57 } | 57 } |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 } // namespace | 61 } // namespace |
62 | 62 |
63 // static | 63 // static |
64 void SessionStartupPref::RegisterUserPrefs(PrefService* prefs) { | 64 void SessionStartupPref::RegisterUserPrefs(PrefService* prefs) { |
| 65 prefs->RegisterIntegerPref(prefs::kRestoreOnStartup, |
| 66 TypeToPrefValue(GetDefaultStartupType()), |
| 67 PrefService::SYNCABLE_PREF); |
| 68 prefs->RegisterListPref(prefs::kURLsToRestoreOnStartup, |
| 69 PrefService::SYNCABLE_PREF); |
| 70 } |
| 71 |
| 72 // static |
| 73 SessionStartupPref::Type SessionStartupPref::GetDefaultStartupType() { |
65 #if defined(OS_CHROMEOS) | 74 #if defined(OS_CHROMEOS) |
66 SessionStartupPref::Type type = SessionStartupPref::LAST; | 75 SessionStartupPref::Type type = SessionStartupPref::LAST; |
67 #else | 76 #else |
68 SessionStartupPref::Type type = SessionStartupPref::DEFAULT; | 77 SessionStartupPref::Type type = SessionStartupPref::DEFAULT; |
69 #endif | 78 #endif |
70 | 79 |
71 #if defined(OS_MACOSX) | 80 #if defined(OS_MACOSX) |
72 // Use Lion's system preference, if it is set. | 81 // Use Lion's system preference, if it is set. |
73 if (restore_utils::IsWindowRestoreEnabled()) | 82 if (restore_utils::IsWindowRestoreEnabled()) |
74 type = SessionStartupPref::LAST; | 83 type = SessionStartupPref::LAST; |
75 #endif | 84 #endif |
76 | 85 |
77 prefs->RegisterIntegerPref(prefs::kRestoreOnStartup, | 86 return type; |
78 TypeToPrefValue(type), | |
79 PrefService::SYNCABLE_PREF); | |
80 prefs->RegisterListPref(prefs::kURLsToRestoreOnStartup, | |
81 PrefService::SYNCABLE_PREF); | |
82 } | 87 } |
83 | 88 |
84 // static | 89 // static |
85 void SessionStartupPref::SetStartupPref( | 90 void SessionStartupPref::SetStartupPref( |
86 Profile* profile, | 91 Profile* profile, |
87 const SessionStartupPref& pref) { | 92 const SessionStartupPref& pref) { |
88 DCHECK(profile); | 93 DCHECK(profile); |
89 SetStartupPref(profile->GetPrefs(), pref); | 94 SetStartupPref(profile->GetPrefs(), pref); |
90 } | 95 } |
91 | 96 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 CHECK(prefs_watcher->GetBackupForPref( | 207 CHECK(prefs_watcher->GetBackupForPref( |
203 prefs::kURLsToRestoreOnStartup)->GetAsList(&url_list)); | 208 prefs::kURLsToRestoreOnStartup)->GetAsList(&url_list)); |
204 URLListToPref(url_list, &backup_pref); | 209 URLListToPref(url_list, &backup_pref); |
205 | 210 |
206 return backup_pref; | 211 return backup_pref; |
207 } | 212 } |
208 | 213 |
209 SessionStartupPref::SessionStartupPref(Type type) : type(type) {} | 214 SessionStartupPref::SessionStartupPref(Type type) : type(type) {} |
210 | 215 |
211 SessionStartupPref::~SessionStartupPref() {} | 216 SessionStartupPref::~SessionStartupPref() {} |
OLD | NEW |