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_live_tab_context.h" | 5 #include "chrome/browser/ui/browser_live_tab_context.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" | 10 #include "chrome/browser/ui/browser_tabrestore.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 sessions::LiveTab* BrowserLiveTabContext::GetActiveLiveTab() const { | 51 sessions::LiveTab* BrowserLiveTabContext::GetActiveLiveTab() const { |
52 return sessions::ContentLiveTab::GetForWebContents( | 52 return sessions::ContentLiveTab::GetForWebContents( |
53 browser_->tab_strip_model()->GetActiveWebContents()); | 53 browser_->tab_strip_model()->GetActiveWebContents()); |
54 } | 54 } |
55 | 55 |
56 bool BrowserLiveTabContext::IsTabPinned(int index) const { | 56 bool BrowserLiveTabContext::IsTabPinned(int index) const { |
57 return browser_->tab_strip_model()->IsTabPinned(index); | 57 return browser_->tab_strip_model()->IsTabPinned(index); |
58 } | 58 } |
59 | 59 |
| 60 const gfx::Rect BrowserLiveTabContext::GetRestoredBounds() const { |
| 61 return browser_->window()->GetRestoredBounds(); |
| 62 } |
| 63 |
| 64 ui::WindowShowState BrowserLiveTabContext::GetRestoredState() const { |
| 65 return browser_->window()->GetRestoredState(); |
| 66 } |
| 67 |
| 68 std::string BrowserLiveTabContext::GetWorkspace() const { |
| 69 return browser_->window()->GetWorkspace(); |
| 70 } |
| 71 |
60 sessions::LiveTab* BrowserLiveTabContext::AddRestoredTab( | 72 sessions::LiveTab* BrowserLiveTabContext::AddRestoredTab( |
61 const std::vector<sessions::SerializedNavigationEntry>& navigations, | 73 const std::vector<sessions::SerializedNavigationEntry>& navigations, |
62 int tab_index, | 74 int tab_index, |
63 int selected_navigation, | 75 int selected_navigation, |
64 const std::string& extension_app_id, | 76 const std::string& extension_app_id, |
65 bool select, | 77 bool select, |
66 bool pin, | 78 bool pin, |
67 bool from_last_session, | 79 bool from_last_session, |
68 const sessions::PlatformSpecificTabData* tab_platform_data, | 80 const sessions::PlatformSpecificTabData* tab_platform_data, |
69 const std::string& user_agent_override) { | 81 const std::string& user_agent_override) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return sessions::ContentLiveTab::GetForWebContents(web_contents); | 134 return sessions::ContentLiveTab::GetForWebContents(web_contents); |
123 } | 135 } |
124 | 136 |
125 void BrowserLiveTabContext::CloseTab() { | 137 void BrowserLiveTabContext::CloseTab() { |
126 chrome::CloseTab(browser_); | 138 chrome::CloseTab(browser_); |
127 } | 139 } |
128 | 140 |
129 // static | 141 // static |
130 sessions::LiveTabContext* BrowserLiveTabContext::Create( | 142 sessions::LiveTabContext* BrowserLiveTabContext::Create( |
131 Profile* profile, | 143 Profile* profile, |
132 const std::string& app_name) { | 144 const std::string& app_name, |
133 Browser* browser; | 145 const gfx::Rect& bounds, |
| 146 ui::WindowShowState show_state, |
| 147 const std::string& workspace) { |
| 148 std::unique_ptr<Browser::CreateParams> create_params; |
134 if (app_name.empty()) { | 149 if (app_name.empty()) { |
135 browser = new Browser(Browser::CreateParams(profile, true)); | 150 create_params = base::MakeUnique<Browser::CreateParams>( |
| 151 Browser::CreateParams(profile, true)); |
| 152 create_params->initial_bounds = bounds; |
136 } else { | 153 } else { |
137 // Only trusted app popup windows should ever be restored. | 154 // Only trusted app popup windows should ever be restored. |
138 browser = new Browser(Browser::CreateParams::CreateForApp( | 155 create_params = base::MakeUnique<Browser::CreateParams>( |
139 app_name, true /* trusted_source */, gfx::Rect(), profile, true)); | 156 Browser::CreateParams::CreateForApp(app_name, true /* trusted_source */, |
| 157 bounds, profile, |
| 158 true /* user_gesture */)); |
140 } | 159 } |
141 if (browser) | 160 create_params->initial_show_state = show_state; |
142 return browser->live_tab_context(); | 161 create_params->initial_workspace = workspace; |
143 else | 162 Browser* browser = new Browser(*create_params.get()); |
144 return NULL; | 163 return browser->live_tab_context(); |
145 } | 164 } |
146 | 165 |
147 // static | 166 // static |
148 sessions::LiveTabContext* BrowserLiveTabContext::FindContextForWebContents( | 167 sessions::LiveTabContext* BrowserLiveTabContext::FindContextForWebContents( |
149 const WebContents* contents) { | 168 const WebContents* contents) { |
150 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 169 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
151 return browser ? browser->live_tab_context() : nullptr; | 170 return browser ? browser->live_tab_context() : nullptr; |
152 } | 171 } |
153 | 172 |
154 // static | 173 // static |
155 sessions::LiveTabContext* BrowserLiveTabContext::FindContextWithID( | 174 sessions::LiveTabContext* BrowserLiveTabContext::FindContextWithID( |
156 SessionID::id_type desired_id) { | 175 SessionID::id_type desired_id) { |
157 Browser* browser = chrome::FindBrowserWithID(desired_id); | 176 Browser* browser = chrome::FindBrowserWithID(desired_id); |
158 return browser ? browser->live_tab_context() : nullptr; | 177 return browser ? browser->live_tab_context() : nullptr; |
159 } | 178 } |
OLD | NEW |