| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| 11 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
| 12 #include "chrome/browser/tab_contents_wrapper.h" |
| 12 #include "chrome/browser/tabs/tab_strip_model.h" | 13 #include "chrome/browser/tabs/tab_strip_model.h" |
| 13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 15 #include "chrome/common/page_transition_types.h" | 16 #include "chrome/common/page_transition_types.h" |
| 16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 17 #include "ipc/ipc_message.h" | 18 #include "ipc/ipc_message.h" |
| 18 | 19 |
| 19 typedef BrowserInit::LaunchWithProfile::Tab Tab; | 20 typedef BrowserInit::LaunchWithProfile::Tab Tab; |
| 20 | 21 |
| 21 // Key used in dictionaries for the app id. | 22 // Key used in dictionaries for the app id. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 34 return false; | 35 return false; |
| 35 } | 36 } |
| 36 | 37 |
| 37 // Adds a DictionaryValue to |values| representing the pinned tab at the | 38 // Adds a DictionaryValue to |values| representing the pinned tab at the |
| 38 // specified index. | 39 // specified index. |
| 39 static void EncodePinnedTab(TabStripModel* model, | 40 static void EncodePinnedTab(TabStripModel* model, |
| 40 int index, | 41 int index, |
| 41 ListValue* values) { | 42 ListValue* values) { |
| 42 scoped_ptr<DictionaryValue> value(new DictionaryValue()); | 43 scoped_ptr<DictionaryValue> value(new DictionaryValue()); |
| 43 | 44 |
| 44 TabContents* tab_contents = model->GetTabContentsAt(index); | 45 TabContentsWrapper* tab_contents = model->GetTabContentsAt(index); |
| 45 if (model->IsAppTab(index)) { | 46 if (model->IsAppTab(index)) { |
| 46 const Extension* extension = tab_contents->extension_app(); | 47 const Extension* extension = tab_contents->extension_app(); |
| 47 DCHECK(extension); | 48 DCHECK(extension); |
| 48 value->SetString(kAppID, extension->id()); | 49 value->SetString(kAppID, extension->id()); |
| 49 // 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: |
| 50 // . 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 |
| 51 // the app's launch page seems closest to what they expect. | 52 // the app's launch page seems closest to what they expect. |
| 52 value->SetString(kURL, extension->GetFullLaunchURL().spec()); | 53 value->SetString(kURL, extension->GetFullLaunchURL().spec()); |
| 53 values->Append(value.release()); | 54 values->Append(value.release()); |
| 54 } else { | 55 } else { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 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) { |
| 125 DictionaryValue* values = NULL; | 126 DictionaryValue* values = NULL; |
| 126 if (pref_value->GetDictionary(i, &values)) { | 127 if (pref_value->GetDictionary(i, &values)) { |
| 127 Tab tab; | 128 Tab tab; |
| 128 if (DecodeTab(*values, &tab)) | 129 if (DecodeTab(*values, &tab)) |
| 129 results.push_back(tab); | 130 results.push_back(tab); |
| 130 } | 131 } |
| 131 } | 132 } |
| 132 return results; | 133 return results; |
| 133 } | 134 } |
| OLD | NEW |