| 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/ui/tabs/pinned_tab_codec.h" | 5 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/extensions/tab_helper.h" | 8 #include "chrome/browser/extensions/tab_helper.h" |
| 9 #include "chrome/browser/prefs/pref_registry_syncable.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 11 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_iterator.h" | 14 #include "chrome/browser/ui/browser_iterator.h" |
| 14 #include "chrome/browser/ui/browser_list.h" | 15 #include "chrome/browser/ui/browser_list.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 18 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 return false; | 92 return false; |
| 92 tab->url = GURL(url_string); | 93 tab->url = GURL(url_string); |
| 93 | 94 |
| 94 if (value.GetString(kAppID, &(tab->app_id))) | 95 if (value.GetString(kAppID, &(tab->app_id))) |
| 95 tab->is_app = true; | 96 tab->is_app = true; |
| 96 | 97 |
| 97 return true; | 98 return true; |
| 98 } | 99 } |
| 99 | 100 |
| 100 // static | 101 // static |
| 101 void PinnedTabCodec::RegisterUserPrefs(PrefServiceSyncable* prefs) { | 102 void PinnedTabCodec::RegisterUserPrefs(PrefRegistrySyncable* registry) { |
| 102 prefs->RegisterListPref(prefs::kPinnedTabs, | 103 registry->RegisterListPref(prefs::kPinnedTabs, |
| 103 PrefServiceSyncable::UNSYNCABLE_PREF); | 104 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 104 } | 105 } |
| 105 | 106 |
| 106 // static | 107 // static |
| 107 void PinnedTabCodec::WritePinnedTabs(Profile* profile) { | 108 void PinnedTabCodec::WritePinnedTabs(Profile* profile) { |
| 108 PrefService* prefs = profile->GetPrefs(); | 109 PrefService* prefs = profile->GetPrefs(); |
| 109 if (!prefs) | 110 if (!prefs) |
| 110 return; | 111 return; |
| 111 | 112 |
| 112 ListValue values; | 113 ListValue values; |
| 113 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 114 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 for (size_t i = 0, max = tabs_list->GetSize(); i < max; ++i) { | 154 for (size_t i = 0, max = tabs_list->GetSize(); i < max; ++i) { |
| 154 const base::DictionaryValue* tab_values = NULL; | 155 const base::DictionaryValue* tab_values = NULL; |
| 155 if (tabs_list->GetDictionary(i, &tab_values)) { | 156 if (tabs_list->GetDictionary(i, &tab_values)) { |
| 156 StartupTab tab; | 157 StartupTab tab; |
| 157 if (DecodeTab(*tab_values, &tab)) | 158 if (DecodeTab(*tab_values, &tab)) |
| 158 results.push_back(tab); | 159 results.push_back(tab); |
| 159 } | 160 } |
| 160 } | 161 } |
| 161 return results; | 162 return results; |
| 162 } | 163 } |
| OLD | NEW |