| 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 <stddef.h> | 7 #include <stddef.h> | 
| 8 | 8 | 
| 9 #include <string> | 9 #include <string> | 
| 10 | 10 | 
|  | 11 #include "base/memory/ptr_util.h" | 
| 11 #include "base/values.h" | 12 #include "base/values.h" | 
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" | 
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" | 
| 14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" | 
| 15 #include "components/pref_registry/pref_registry_syncable.h" | 16 #include "components/pref_registry/pref_registry_syncable.h" | 
| 16 #include "components/prefs/pref_service.h" | 17 #include "components/prefs/pref_service.h" | 
| 17 #include "components/prefs/scoped_user_pref_update.h" | 18 #include "components/prefs/scoped_user_pref_update.h" | 
| 18 #include "components/url_formatter/url_fixer.h" | 19 #include "components/url_formatter/url_fixer.h" | 
| 19 | 20 | 
| 20 namespace { | 21 namespace { | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 83   if (!SessionStartupPref::URLsAreManaged(prefs)) { | 84   if (!SessionStartupPref::URLsAreManaged(prefs)) { | 
| 84     // Always save the URLs, that way the UI can remain consistent even if the | 85     // Always save the URLs, that way the UI can remain consistent even if the | 
| 85     // user changes the startup type pref. | 86     // user changes the startup type pref. | 
| 86     // Ownership of the ListValue retains with the pref service. | 87     // Ownership of the ListValue retains with the pref service. | 
| 87     ListPrefUpdate update(prefs, prefs::kURLsToRestoreOnStartup); | 88     ListPrefUpdate update(prefs, prefs::kURLsToRestoreOnStartup); | 
| 88     base::ListValue* url_pref_list = update.Get(); | 89     base::ListValue* url_pref_list = update.Get(); | 
| 89     DCHECK(url_pref_list); | 90     DCHECK(url_pref_list); | 
| 90     url_pref_list->Clear(); | 91     url_pref_list->Clear(); | 
| 91     for (size_t i = 0; i < pref.urls.size(); ++i) { | 92     for (size_t i = 0; i < pref.urls.size(); ++i) { | 
| 92       url_pref_list->Set(static_cast<int>(i), | 93       url_pref_list->Set(static_cast<int>(i), | 
| 93                          new base::Value(pref.urls[i].spec())); | 94                          base::MakeUnique<base::Value>(pref.urls[i].spec())); | 
| 94     } | 95     } | 
| 95   } | 96   } | 
| 96 } | 97 } | 
| 97 | 98 | 
| 98 // static | 99 // static | 
| 99 SessionStartupPref SessionStartupPref::GetStartupPref(Profile* profile) { | 100 SessionStartupPref SessionStartupPref::GetStartupPref(Profile* profile) { | 
| 100   DCHECK(profile); | 101   DCHECK(profile); | 
| 101   return GetStartupPref(profile->GetPrefs()); | 102   return GetStartupPref(profile->GetPrefs()); | 
| 102 } | 103 } | 
| 103 | 104 | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 152     default:                 return SessionStartupPref::DEFAULT; | 153     default:                 return SessionStartupPref::DEFAULT; | 
| 153   } | 154   } | 
| 154 } | 155 } | 
| 155 | 156 | 
| 156 SessionStartupPref::SessionStartupPref(Type type) : type(type) {} | 157 SessionStartupPref::SessionStartupPref(Type type) : type(type) {} | 
| 157 | 158 | 
| 158 SessionStartupPref::SessionStartupPref(const SessionStartupPref& other) = | 159 SessionStartupPref::SessionStartupPref(const SessionStartupPref& other) = | 
| 159     default; | 160     default; | 
| 160 | 161 | 
| 161 SessionStartupPref::~SessionStartupPref() {} | 162 SessionStartupPref::~SessionStartupPref() {} | 
| OLD | NEW | 
|---|