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/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_commands.h" | 8 #include "chrome/browser/ui/browser_commands.h" |
9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
| 10 #include "chrome/browser/ui/browser_tabrestore.h" |
| 11 #include "chrome/browser/ui/browser_tabstrip.h" |
10 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
11 #include "content/public/browser/navigation_controller.h" | 14 #include "content/public/browser/navigation_controller.h" |
12 | 15 |
13 using content::NavigationController; | 16 using content::NavigationController; |
14 using content::SessionStorageNamespace; | 17 using content::SessionStorageNamespace; |
15 using content::WebContents; | 18 using content::WebContents; |
16 | 19 |
17 void BrowserTabRestoreServiceDelegate::ShowBrowserWindow() { | 20 void BrowserTabRestoreServiceDelegate::ShowBrowserWindow() { |
18 browser_->window()->Show(); | 21 browser_->window()->Show(); |
19 } | 22 } |
20 | 23 |
21 const SessionID& BrowserTabRestoreServiceDelegate::GetSessionID() const { | 24 const SessionID& BrowserTabRestoreServiceDelegate::GetSessionID() const { |
22 return browser_->session_id(); | 25 return browser_->session_id(); |
23 } | 26 } |
24 | 27 |
25 int BrowserTabRestoreServiceDelegate::GetTabCount() const { | 28 int BrowserTabRestoreServiceDelegate::GetTabCount() const { |
26 return browser_->tab_count(); | 29 return browser_->tab_count(); |
27 } | 30 } |
28 | 31 |
29 int BrowserTabRestoreServiceDelegate::GetSelectedIndex() const { | 32 int BrowserTabRestoreServiceDelegate::GetSelectedIndex() const { |
30 return browser_->active_index(); | 33 return browser_->active_index(); |
31 } | 34 } |
32 | 35 |
33 std::string BrowserTabRestoreServiceDelegate::GetAppName() const { | 36 std::string BrowserTabRestoreServiceDelegate::GetAppName() const { |
34 return browser_->app_name(); | 37 return browser_->app_name(); |
35 } | 38 } |
36 | 39 |
37 WebContents* BrowserTabRestoreServiceDelegate::GetWebContentsAt( | 40 WebContents* BrowserTabRestoreServiceDelegate::GetWebContentsAt( |
38 int index) const { | 41 int index) const { |
39 return browser_->GetWebContentsAt(index); | 42 return chrome::GetWebContentsAt(browser_, index); |
40 } | 43 } |
41 | 44 |
42 WebContents* BrowserTabRestoreServiceDelegate::GetActiveWebContents() const { | 45 WebContents* BrowserTabRestoreServiceDelegate::GetActiveWebContents() const { |
43 return browser_->GetActiveWebContents(); | 46 return chrome::GetActiveWebContents(browser_); |
44 } | 47 } |
45 | 48 |
46 bool BrowserTabRestoreServiceDelegate::IsTabPinned(int index) const { | 49 bool BrowserTabRestoreServiceDelegate::IsTabPinned(int index) const { |
47 return browser_->IsTabPinned(index); | 50 return browser_->tab_strip_model()->IsTabPinned(index); |
48 } | 51 } |
49 | 52 |
50 WebContents* BrowserTabRestoreServiceDelegate::AddRestoredTab( | 53 WebContents* BrowserTabRestoreServiceDelegate::AddRestoredTab( |
51 const std::vector<TabNavigation>& navigations, | 54 const std::vector<TabNavigation>& navigations, |
52 int tab_index, | 55 int tab_index, |
53 int selected_navigation, | 56 int selected_navigation, |
54 const std::string& extension_app_id, | 57 const std::string& extension_app_id, |
55 bool select, | 58 bool select, |
56 bool pin, | 59 bool pin, |
57 bool from_last_session, | 60 bool from_last_session, |
58 SessionStorageNamespace* storage_namespace) { | 61 SessionStorageNamespace* storage_namespace) { |
59 return browser_->AddRestoredTab(navigations, tab_index, selected_navigation, | 62 return chrome::AddRestoredTab(browser_, navigations, tab_index, |
60 extension_app_id, select, pin, | 63 selected_navigation, extension_app_id, select, |
61 from_last_session, storage_namespace); | 64 pin, from_last_session, storage_namespace); |
62 } | 65 } |
63 | 66 |
64 void BrowserTabRestoreServiceDelegate::ReplaceRestoredTab( | 67 void BrowserTabRestoreServiceDelegate::ReplaceRestoredTab( |
65 const std::vector<TabNavigation>& navigations, | 68 const std::vector<TabNavigation>& navigations, |
66 int selected_navigation, | 69 int selected_navigation, |
67 bool from_last_session, | 70 bool from_last_session, |
68 const std::string& extension_app_id, | 71 const std::string& extension_app_id, |
69 SessionStorageNamespace* session_storage_namespace) { | 72 SessionStorageNamespace* session_storage_namespace) { |
70 browser_->ReplaceRestoredTab(navigations, selected_navigation, | 73 chrome::ReplaceRestoredTab(browser_, navigations, selected_navigation, |
71 from_last_session, extension_app_id, | 74 from_last_session, extension_app_id, |
72 session_storage_namespace); | 75 session_storage_namespace); |
73 } | 76 } |
74 | 77 |
75 void BrowserTabRestoreServiceDelegate::CloseTab() { | 78 void BrowserTabRestoreServiceDelegate::CloseTab() { |
76 chrome::CloseTab(browser_); | 79 chrome::CloseTab(browser_); |
77 } | 80 } |
78 | 81 |
79 // Implementations of TabRestoreServiceDelegate static methods | 82 // Implementations of TabRestoreServiceDelegate static methods |
80 | 83 |
81 // static | 84 // static |
82 TabRestoreServiceDelegate* TabRestoreServiceDelegate::Create( | 85 TabRestoreServiceDelegate* TabRestoreServiceDelegate::Create( |
(...skipping 20 matching lines...) Expand all Loading... |
103 Browser* browser = browser::FindBrowserWithWebContents(contents); | 106 Browser* browser = browser::FindBrowserWithWebContents(contents); |
104 return browser ? browser->tab_restore_service_delegate() : NULL; | 107 return browser ? browser->tab_restore_service_delegate() : NULL; |
105 } | 108 } |
106 | 109 |
107 // static | 110 // static |
108 TabRestoreServiceDelegate* TabRestoreServiceDelegate::FindDelegateWithID( | 111 TabRestoreServiceDelegate* TabRestoreServiceDelegate::FindDelegateWithID( |
109 SessionID::id_type desired_id) { | 112 SessionID::id_type desired_id) { |
110 Browser* browser = browser::FindBrowserWithID(desired_id); | 113 Browser* browser = browser::FindBrowserWithID(desired_id); |
111 return browser ? browser->tab_restore_service_delegate() : NULL; | 114 return browser ? browser->tab_restore_service_delegate() : NULL; |
112 } | 115 } |
OLD | NEW |