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/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/extensions/tab_helper.h" | 10 #include "chrome/browser/extensions/tab_helper.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 TabStripModel* tab_model = browser->tab_strip_model(); | 31 TabStripModel* tab_model = browser->tab_strip_model(); |
32 for (int i = 0; i < tab_model->count(); ++i) { | 32 for (int i = 0; i < tab_model->count(); ++i) { |
33 if (tab_model->IsTabPinned(i)) | 33 if (tab_model->IsTabPinned(i)) |
34 return true; | 34 return true; |
35 } | 35 } |
36 return false; | 36 return false; |
37 } | 37 } |
38 | 38 |
39 // Adds a DictionaryValue to |values| representing |tab|. | 39 // Adds a DictionaryValue to |values| representing |tab|. |
40 static void EncodeTab(const StartupTab& tab, base::ListValue* values) { | 40 static void EncodeTab(const StartupTab& tab, base::ListValue* values) { |
41 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue); | 41 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); |
42 value->SetString(kURL, tab.url.spec()); | 42 value->SetString(kURL, tab.url.spec()); |
43 values->Append(value.release()); | 43 values->Append(value.release()); |
44 } | 44 } |
45 | 45 |
46 // Adds a base::DictionaryValue to |values| representing the pinned tab at the | 46 // Adds a base::DictionaryValue to |values| representing the pinned tab at the |
47 // specified index. | 47 // specified index. |
48 static void EncodePinnedTab(TabStripModel* model, | 48 static void EncodePinnedTab(TabStripModel* model, |
49 int index, | 49 int index, |
50 base::ListValue* values) { | 50 base::ListValue* values) { |
51 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 51 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
52 | 52 |
53 content::WebContents* web_contents = model->GetWebContentsAt(index); | 53 content::WebContents* web_contents = model->GetWebContentsAt(index); |
54 NavigationEntry* entry = web_contents->GetController().GetActiveEntry(); | 54 NavigationEntry* entry = web_contents->GetController().GetActiveEntry(); |
55 if (entry) { | 55 if (entry) { |
56 value->SetString(kURL, entry->GetURL().spec()); | 56 value->SetString(kURL, entry->GetURL().spec()); |
57 values->Append(value.release()); | 57 values->Append(value.release()); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 // Invokes EncodePinnedTab for each pinned tab in browser. | 61 // Invokes EncodePinnedTab for each pinned tab in browser. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 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) { |
132 const base::DictionaryValue* tab_values = NULL; | 132 const base::DictionaryValue* tab_values = NULL; |
133 if (tabs_list->GetDictionary(i, &tab_values)) { | 133 if (tabs_list->GetDictionary(i, &tab_values)) { |
134 StartupTab tab; | 134 StartupTab tab; |
135 if (DecodeTab(*tab_values, &tab)) | 135 if (DecodeTab(*tab_values, &tab)) |
136 results.push_back(tab); | 136 results.push_back(tab); |
137 } | 137 } |
138 } | 138 } |
139 return results; | 139 return results; |
140 } | 140 } |
OLD | NEW |