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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/prefs/scoped_user_pref_update.h" | 11 #include "base/prefs/scoped_user_pref_update.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "base/version.h" | 14 #include "base/version.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
17 #include "components/pref_registry/pref_registry_syncable.h" | 17 #include "components/pref_registry/pref_registry_syncable.h" |
18 #include "components/url_fixer/url_fixer.h" | 18 #include "components/url_formatter/url_fixer.h" |
19 | 19 |
20 #if defined(OS_MACOSX) | 20 #if defined(OS_MACOSX) |
21 #include "chrome/browser/ui/cocoa/window_restore_utils.h" | 21 #include "chrome/browser/ui/cocoa/window_restore_utils.h" |
22 #endif | 22 #endif |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 enum StartupURLsMigrationMetrics { | 26 enum StartupURLsMigrationMetrics { |
27 STARTUP_URLS_MIGRATION_METRICS_PERFORMED, | 27 STARTUP_URLS_MIGRATION_METRICS_PERFORMED, |
28 STARTUP_URLS_MIGRATION_METRICS_NOT_PRESENT, | 28 STARTUP_URLS_MIGRATION_METRICS_NOT_PRESENT, |
(...skipping 18 matching lines...) Expand all Loading... |
47 new_url_pref_list.Append(home_page); | 47 new_url_pref_list.Append(home_page); |
48 prefs->Set(prefs::kURLsToRestoreOnStartup, new_url_pref_list); | 48 prefs->Set(prefs::kURLsToRestoreOnStartup, new_url_pref_list); |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 void URLListToPref(const base::ListValue* url_list, SessionStartupPref* pref) { | 52 void URLListToPref(const base::ListValue* url_list, SessionStartupPref* pref) { |
53 pref->urls.clear(); | 53 pref->urls.clear(); |
54 for (size_t i = 0; i < url_list->GetSize(); ++i) { | 54 for (size_t i = 0; i < url_list->GetSize(); ++i) { |
55 std::string url_text; | 55 std::string url_text; |
56 if (url_list->GetString(i, &url_text)) { | 56 if (url_list->GetString(i, &url_text)) { |
57 GURL fixed_url = url_fixer::FixupURL(url_text, std::string()); | 57 GURL fixed_url = url_formatter::FixupURL(url_text, std::string()); |
58 pref->urls.push_back(fixed_url); | 58 pref->urls.push_back(fixed_url); |
59 } | 59 } |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 } // namespace | 63 } // namespace |
64 | 64 |
65 // static | 65 // static |
66 void SessionStartupPref::RegisterProfilePrefs( | 66 void SessionStartupPref::RegisterProfilePrefs( |
67 user_prefs::PrefRegistrySyncable* registry) { | 67 user_prefs::PrefRegistrySyncable* registry) { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 case kPrefValueLast: return SessionStartupPref::LAST; | 289 case kPrefValueLast: return SessionStartupPref::LAST; |
290 case kPrefValueURLs: return SessionStartupPref::URLS; | 290 case kPrefValueURLs: return SessionStartupPref::URLS; |
291 case kPrefValueHomePage: return SessionStartupPref::HOMEPAGE; | 291 case kPrefValueHomePage: return SessionStartupPref::HOMEPAGE; |
292 default: return SessionStartupPref::DEFAULT; | 292 default: return SessionStartupPref::DEFAULT; |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 SessionStartupPref::SessionStartupPref(Type type) : type(type) {} | 296 SessionStartupPref::SessionStartupPref(Type type) : type(type) {} |
297 | 297 |
298 SessionStartupPref::~SessionStartupPref() {} | 298 SessionStartupPref::~SessionStartupPref() {} |
OLD | NEW |