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/ui/browser_tab_restore_service_delegate.h" | 5 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" |
6 | 6 |
7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/browser_list.h" | 8 #include "chrome/browser/ui/browser_list.h" |
9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
10 #include "content/public/browser/navigation_controller.h" | 10 #include "content/public/browser/navigation_controller.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 } | 22 } |
23 | 23 |
24 int BrowserTabRestoreServiceDelegate::GetTabCount() const { | 24 int BrowserTabRestoreServiceDelegate::GetTabCount() const { |
25 return browser_->tab_count(); | 25 return browser_->tab_count(); |
26 } | 26 } |
27 | 27 |
28 int BrowserTabRestoreServiceDelegate::GetSelectedIndex() const { | 28 int BrowserTabRestoreServiceDelegate::GetSelectedIndex() const { |
29 return browser_->active_index(); | 29 return browser_->active_index(); |
30 } | 30 } |
31 | 31 |
| 32 std::string BrowserTabRestoreServiceDelegate::GetAppName() const { |
| 33 return browser_->app_name(); |
| 34 } |
| 35 |
32 WebContents* BrowserTabRestoreServiceDelegate::GetWebContentsAt( | 36 WebContents* BrowserTabRestoreServiceDelegate::GetWebContentsAt( |
33 int index) const { | 37 int index) const { |
34 return browser_->GetWebContentsAt(index); | 38 return browser_->GetWebContentsAt(index); |
35 } | 39 } |
36 | 40 |
37 WebContents* BrowserTabRestoreServiceDelegate::GetSelectedWebContents() const { | 41 WebContents* BrowserTabRestoreServiceDelegate::GetSelectedWebContents() const { |
38 return browser_->GetSelectedWebContents(); | 42 return browser_->GetSelectedWebContents(); |
39 } | 43 } |
40 | 44 |
41 bool BrowserTabRestoreServiceDelegate::IsTabPinned(int index) const { | 45 bool BrowserTabRestoreServiceDelegate::IsTabPinned(int index) const { |
(...skipping 25 matching lines...) Expand all Loading... |
67 session_storage_namespace); | 71 session_storage_namespace); |
68 } | 72 } |
69 | 73 |
70 void BrowserTabRestoreServiceDelegate::CloseTab() { | 74 void BrowserTabRestoreServiceDelegate::CloseTab() { |
71 browser_->CloseTab(); | 75 browser_->CloseTab(); |
72 } | 76 } |
73 | 77 |
74 // Implementations of TabRestoreServiceDelegate static methods | 78 // Implementations of TabRestoreServiceDelegate static methods |
75 | 79 |
76 // static | 80 // static |
77 TabRestoreServiceDelegate* TabRestoreServiceDelegate::Create(Profile* profile) { | 81 TabRestoreServiceDelegate* TabRestoreServiceDelegate::Create( |
78 Browser* browser = Browser::Create(profile); | 82 Profile* profile, |
| 83 const std::string& app_name) { |
| 84 Browser* browser; |
| 85 if (app_name.empty()) { |
| 86 browser = Browser::Create(profile); |
| 87 } else { |
| 88 browser = Browser::CreateForApp( |
| 89 Browser::TYPE_POPUP, |
| 90 app_name, |
| 91 gfx::Rect(), |
| 92 profile); |
| 93 } |
79 if (browser) | 94 if (browser) |
80 return browser->tab_restore_service_delegate(); | 95 return browser->tab_restore_service_delegate(); |
81 else | 96 else |
82 return NULL; | 97 return NULL; |
83 } | 98 } |
84 | 99 |
85 // static | 100 // static |
86 TabRestoreServiceDelegate* TabRestoreServiceDelegate::FindDelegateForController( | 101 TabRestoreServiceDelegate* TabRestoreServiceDelegate::FindDelegateForController( |
87 const NavigationController* controller, | 102 const NavigationController* controller, |
88 int* index) { | 103 int* index) { |
89 Browser* browser = Browser::GetBrowserForController(controller, index); | 104 Browser* browser = Browser::GetBrowserForController(controller, index); |
90 if (browser) | 105 if (browser) |
91 return browser->tab_restore_service_delegate(); | 106 return browser->tab_restore_service_delegate(); |
92 else | 107 else |
93 return NULL; | 108 return NULL; |
94 } | 109 } |
95 | 110 |
96 // static | 111 // static |
97 TabRestoreServiceDelegate* TabRestoreServiceDelegate::FindDelegateWithID( | 112 TabRestoreServiceDelegate* TabRestoreServiceDelegate::FindDelegateWithID( |
98 SessionID::id_type desired_id) { | 113 SessionID::id_type desired_id) { |
99 Browser* browser = BrowserList::FindBrowserWithID(desired_id); | 114 Browser* browser = BrowserList::FindBrowserWithID(desired_id); |
100 if (browser) | 115 if (browser) |
101 return browser->tab_restore_service_delegate(); | 116 return browser->tab_restore_service_delegate(); |
102 else | 117 else |
103 return NULL; | 118 return NULL; |
104 } | 119 } |
OLD | NEW |