Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/session_startup_pref.h" | 5 #include "chrome/browser/session_startup_pref.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
| 9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
| 10 #include "chrome/common/pref_service.h" | 10 #include "chrome/common/pref_service.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 DCHECK(prefs); | 30 DCHECK(prefs); |
| 31 int type = 0; | 31 int type = 0; |
| 32 switch(pref.type) { | 32 switch(pref.type) { |
| 33 case LAST: | 33 case LAST: |
| 34 type = 1; | 34 type = 1; |
| 35 break; | 35 break; |
| 36 | 36 |
| 37 case URLS: | 37 case URLS: |
| 38 type = 4; | 38 type = 4; |
| 39 break; | 39 break; |
| 40 | |
| 41 default: | |
|
M-A Ruel
2008/09/19 12:51:18
add 'NOTREACHED();' here.
Dean McNamee
2008/09/19 12:58:10
That's a lie, it is reached. It's the case of DEF
M-A Ruel
2008/09/19 12:59:49
Ok, don't listen to me.
On 2008/09/19 12:58:10, d
| |
| 42 break; | |
| 40 } | 43 } |
| 41 prefs->SetInteger(prefs::kRestoreOnStartup, type); | 44 prefs->SetInteger(prefs::kRestoreOnStartup, type); |
| 42 | 45 |
| 43 // Always save the URLs, that way the UI can remain consistent even if the | 46 // Always save the URLs, that way the UI can remain consistent even if the |
| 44 // user changes the startup type pref. | 47 // user changes the startup type pref. |
| 45 // Ownership of the ListValue retains with the pref service. | 48 // Ownership of the ListValue retains with the pref service. |
| 46 ListValue* url_pref_list = | 49 ListValue* url_pref_list = |
| 47 prefs->GetMutableList(prefs::kURLsToRestoreOnStartup); | 50 prefs->GetMutableList(prefs::kURLsToRestoreOnStartup); |
| 48 DCHECK(url_pref_list); | 51 DCHECK(url_pref_list); |
| 49 url_pref_list->Clear(); | 52 url_pref_list->Clear(); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 79 } | 82 } |
| 80 | 83 |
| 81 ListValue* url_pref_list = prefs->GetMutableList( | 84 ListValue* url_pref_list = prefs->GetMutableList( |
| 82 prefs::kURLsToRestoreOnStartup); | 85 prefs::kURLsToRestoreOnStartup); |
| 83 DCHECK(url_pref_list); | 86 DCHECK(url_pref_list); |
| 84 for (size_t i = 0; i < url_pref_list->GetSize(); ++i) { | 87 for (size_t i = 0; i < url_pref_list->GetSize(); ++i) { |
| 85 Value* value = NULL; | 88 Value* value = NULL; |
| 86 if (url_pref_list->Get(i, &value)) { | 89 if (url_pref_list->Get(i, &value)) { |
| 87 std::wstring url_text; | 90 std::wstring url_text; |
| 88 if (value->GetAsString(&url_text)) | 91 if (value->GetAsString(&url_text)) |
| 89 pref.urls.push_back(GURL(url_text)); | 92 pref.urls.push_back(GURL(WideToUTF8(url_text))); |
| 90 } | 93 } |
| 91 } | 94 } |
| 92 | 95 |
| 93 return pref; | 96 return pref; |
| 94 } | 97 } |
| 95 | 98 |
| OLD | NEW |