| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/extensions/tab_helper.h" | 12 #include "chrome/browser/extensions/tab_helper.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_iterator.h" | |
| 16 #include "chrome/browser/ui/browser_list.h" | 15 #include "chrome/browser/ui/browser_list.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 17 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 20 #include "components/pref_registry/pref_registry_syncable.h" | 19 #include "components/pref_registry/pref_registry_syncable.h" |
| 21 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
| 22 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 23 #include "extensions/common/extension.h" | 22 #include "extensions/common/extension.h" |
| 24 | 23 |
| 25 using content::NavigationEntry; | 24 using content::NavigationEntry; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 registry->RegisterListPref(prefs::kPinnedTabs); | 82 registry->RegisterListPref(prefs::kPinnedTabs); |
| 84 } | 83 } |
| 85 | 84 |
| 86 // static | 85 // static |
| 87 void PinnedTabCodec::WritePinnedTabs(Profile* profile) { | 86 void PinnedTabCodec::WritePinnedTabs(Profile* profile) { |
| 88 PrefService* prefs = profile->GetPrefs(); | 87 PrefService* prefs = profile->GetPrefs(); |
| 89 if (!prefs) | 88 if (!prefs) |
| 90 return; | 89 return; |
| 91 | 90 |
| 92 base::ListValue values; | 91 base::ListValue values; |
| 93 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 92 for (auto& browser : *BrowserList::GetInstance()) { |
| 94 Browser* browser = *it; | |
| 95 if (browser->is_type_tabbed() && | 93 if (browser->is_type_tabbed() && |
| 96 browser->profile() == profile && HasPinnedTabs(browser)) { | 94 browser->profile() == profile && HasPinnedTabs(browser)) { |
| 97 EncodePinnedTabs(browser, &values); | 95 EncodePinnedTabs(browser, &values); |
| 98 } | 96 } |
| 99 } | 97 } |
| 100 prefs->Set(prefs::kPinnedTabs, values); | 98 prefs->Set(prefs::kPinnedTabs, values); |
| 101 } | 99 } |
| 102 | 100 |
| 103 // static | 101 // static |
| 104 void PinnedTabCodec::WritePinnedTabs(Profile* profile, | 102 void PinnedTabCodec::WritePinnedTabs(Profile* profile, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 133 for (size_t i = 0, max = tabs_list->GetSize(); i < max; ++i) { | 131 for (size_t i = 0, max = tabs_list->GetSize(); i < max; ++i) { |
| 134 const base::DictionaryValue* tab_values = NULL; | 132 const base::DictionaryValue* tab_values = NULL; |
| 135 if (tabs_list->GetDictionary(i, &tab_values)) { | 133 if (tabs_list->GetDictionary(i, &tab_values)) { |
| 136 StartupTab tab; | 134 StartupTab tab; |
| 137 if (DecodeTab(*tab_values, &tab)) | 135 if (DecodeTab(*tab_values, &tab)) |
| 138 results.push_back(tab); | 136 results.push_back(tab); |
| 139 } | 137 } |
| 140 } | 138 } |
| 141 return results; | 139 return results; |
| 142 } | 140 } |
| OLD | NEW |