| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tabs/pinned_tab_codec.h" | 5 #include "chrome/browser/tabs/pinned_tab_codec.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/extensions/extension_tab_helper.h" | 8 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 ListValue values; | 101 ListValue values; |
| 102 for (BrowserList::const_iterator i = BrowserList::begin(); | 102 for (BrowserList::const_iterator i = BrowserList::begin(); |
| 103 i != BrowserList::end(); ++i) { | 103 i != BrowserList::end(); ++i) { |
| 104 Browser* browser = *i; | 104 Browser* browser = *i; |
| 105 if (browser->is_type_tabbed() && | 105 if (browser->is_type_tabbed() && |
| 106 browser->profile() == profile && HasPinnedTabs(browser)) { | 106 browser->profile() == profile && HasPinnedTabs(browser)) { |
| 107 EncodePinnedTabs(browser, &values); | 107 EncodePinnedTabs(browser, &values); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 prefs->Set(prefs::kPinnedTabs, values); | 110 prefs->Set(prefs::kPinnedTabs, values); |
| 111 prefs->ScheduleSavePersistentPrefs(); | |
| 112 } | 111 } |
| 113 | 112 |
| 114 // static | 113 // static |
| 115 std::vector<Tab> PinnedTabCodec::ReadPinnedTabs(Profile* profile) { | 114 std::vector<Tab> PinnedTabCodec::ReadPinnedTabs(Profile* profile) { |
| 116 std::vector<Tab> results; | 115 std::vector<Tab> results; |
| 117 | 116 |
| 118 PrefService* prefs = profile->GetPrefs(); | 117 PrefService* prefs = profile->GetPrefs(); |
| 119 if (!prefs) | 118 if (!prefs) |
| 120 return results; | 119 return results; |
| 121 | 120 |
| 122 const ListValue* pref_value = prefs->GetList(prefs::kPinnedTabs); | 121 const ListValue* pref_value = prefs->GetList(prefs::kPinnedTabs); |
| 123 if (!pref_value) | 122 if (!pref_value) |
| 124 return results; | 123 return results; |
| 125 | 124 |
| 126 for (size_t i = 0, max = pref_value->GetSize(); i < max; ++i) { | 125 for (size_t i = 0, max = pref_value->GetSize(); i < max; ++i) { |
| 127 DictionaryValue* values = NULL; | 126 DictionaryValue* values = NULL; |
| 128 if (pref_value->GetDictionary(i, &values)) { | 127 if (pref_value->GetDictionary(i, &values)) { |
| 129 Tab tab; | 128 Tab tab; |
| 130 if (DecodeTab(*values, &tab)) | 129 if (DecodeTab(*values, &tab)) |
| 131 results.push_back(tab); | 130 results.push_back(tab); |
| 132 } | 131 } |
| 133 } | 132 } |
| 134 return results; | 133 return results; |
| 135 } | 134 } |
| OLD | NEW |