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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 const Extension* extension = | 46 const Extension* extension = |
47 tab_contents->extension_tab_helper()->extension_app(); | 47 tab_contents->extension_tab_helper()->extension_app(); |
48 DCHECK(extension); | 48 DCHECK(extension); |
49 value->SetString(kAppID, extension->id()); | 49 value->SetString(kAppID, extension->id()); |
50 // For apps we use the launch url. We do this for the following reason: | 50 // For apps we use the launch url. We do this for the following reason: |
51 // . the user is effectively restarting the app, so that returning them to | 51 // . the user is effectively restarting the app, so that returning them to |
52 // the app's launch page seems closest to what they expect. | 52 // the app's launch page seems closest to what they expect. |
53 value->SetString(kURL, extension->GetFullLaunchURL().spec()); | 53 value->SetString(kURL, extension->GetFullLaunchURL().spec()); |
54 values->Append(value.release()); | 54 values->Append(value.release()); |
55 } else { | 55 } else { |
56 NavigationEntry* entry = tab_contents->controller().GetActiveEntry(); | 56 NavigationEntry* entry = |
57 if (!entry && tab_contents->controller().entry_count()) | 57 tab_contents->tab_contents()->controller().GetActiveEntry(); |
58 entry = tab_contents->controller().GetEntryAtIndex(0); | 58 if (!entry && tab_contents->tab_contents()->controller().entry_count()) |
| 59 entry = tab_contents->tab_contents()->controller().GetEntryAtIndex(0); |
59 if (entry) { | 60 if (entry) { |
60 value->SetString(kURL, entry->url().spec()); | 61 value->SetString(kURL, entry->url().spec()); |
61 values->Append(value.release()); | 62 values->Append(value.release()); |
62 } | 63 } |
63 } | 64 } |
64 } | 65 } |
65 | 66 |
66 // Invokes EncodePinnedTab for each pinned tab in browser. | 67 // Invokes EncodePinnedTab for each pinned tab in browser. |
67 static void EncodePinnedTabs(Browser* browser, ListValue* values) { | 68 static void EncodePinnedTabs(Browser* browser, ListValue* values) { |
68 TabStripModel* tab_model = browser->tabstrip_model(); | 69 TabStripModel* tab_model = browser->tabstrip_model(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 for (size_t i = 0, max = pref_value->GetSize(); i < max; ++i) { | 126 for (size_t i = 0, max = pref_value->GetSize(); i < max; ++i) { |
126 DictionaryValue* values = NULL; | 127 DictionaryValue* values = NULL; |
127 if (pref_value->GetDictionary(i, &values)) { | 128 if (pref_value->GetDictionary(i, &values)) { |
128 Tab tab; | 129 Tab tab; |
129 if (DecodeTab(*values, &tab)) | 130 if (DecodeTab(*values, &tab)) |
130 results.push_back(tab); | 131 results.push_back(tab); |
131 } | 132 } |
132 } | 133 } |
133 return results; | 134 return results; |
134 } | 135 } |
OLD | NEW |