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" |
11 #include "chrome/browser/tabs/tab_strip_model.h" | 11 #include "chrome/browser/tabs/tab_strip_model.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
17 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
18 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
19 | 19 |
| 20 using content::NavigationEntry; |
| 21 |
20 typedef BrowserInit::LaunchWithProfile::Tab Tab; | 22 typedef BrowserInit::LaunchWithProfile::Tab Tab; |
21 | 23 |
22 // Key used in dictionaries for the app id. | 24 // Key used in dictionaries for the app id. |
23 static const char kAppID[] = "app_id"; | 25 static const char kAppID[] = "app_id"; |
24 | 26 |
25 // Key used in dictionaries for the url. | 27 // Key used in dictionaries for the url. |
26 static const char kURL[] = "url"; | 28 static const char kURL[] = "url"; |
27 | 29 |
28 // Returns true if |browser| has any pinned tabs. | 30 // Returns true if |browser| has any pinned tabs. |
29 static bool HasPinnedTabs(Browser* browser) { | 31 static bool HasPinnedTabs(Browser* browser) { |
(...skipping 17 matching lines...) Expand all Loading... |
47 const Extension* extension = | 49 const Extension* extension = |
48 tab_contents->extension_tab_helper()->extension_app(); | 50 tab_contents->extension_tab_helper()->extension_app(); |
49 DCHECK(extension); | 51 DCHECK(extension); |
50 value->SetString(kAppID, extension->id()); | 52 value->SetString(kAppID, extension->id()); |
51 // For apps we use the launch url. We do this for the following reason: | 53 // For apps we use the launch url. We do this for the following reason: |
52 // . the user is effectively restarting the app, so that returning them to | 54 // . the user is effectively restarting the app, so that returning them to |
53 // the app's launch page seems closest to what they expect. | 55 // the app's launch page seems closest to what they expect. |
54 value->SetString(kURL, extension->GetFullLaunchURL().spec()); | 56 value->SetString(kURL, extension->GetFullLaunchURL().spec()); |
55 values->Append(value.release()); | 57 values->Append(value.release()); |
56 } else { | 58 } else { |
57 content::NavigationEntry* entry = | 59 NavigationEntry* entry = |
58 tab_contents->tab_contents()->GetController().GetActiveEntry(); | 60 tab_contents->tab_contents()->GetController().GetActiveEntry(); |
59 if (!entry && tab_contents->tab_contents()->GetController().entry_count()) | 61 if (!entry && tab_contents->tab_contents()->GetController().entry_count()) |
60 entry = tab_contents->tab_contents()->GetController().GetEntryAtIndex(0); | 62 entry = tab_contents->tab_contents()->GetController().GetEntryAtIndex(0); |
61 if (entry) { | 63 if (entry) { |
62 value->SetString(kURL, entry->GetURL().spec()); | 64 value->SetString(kURL, entry->GetURL().spec()); |
63 values->Append(value.release()); | 65 values->Append(value.release()); |
64 } | 66 } |
65 } | 67 } |
66 } | 68 } |
67 | 69 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 for (size_t i = 0, max = pref_value->GetSize(); i < max; ++i) { | 128 for (size_t i = 0, max = pref_value->GetSize(); i < max; ++i) { |
127 DictionaryValue* values = NULL; | 129 DictionaryValue* values = NULL; |
128 if (pref_value->GetDictionary(i, &values)) { | 130 if (pref_value->GetDictionary(i, &values)) { |
129 Tab tab; | 131 Tab tab; |
130 if (DecodeTab(*values, &tab)) | 132 if (DecodeTab(*values, &tab)) |
131 results.push_back(tab); | 133 results.push_back(tab); |
132 } | 134 } |
133 } | 135 } |
134 return results; | 136 return results; |
135 } | 137 } |
OLD | NEW |