Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Side by Side Diff: chrome/browser/ui/browser_live_tab_context.cc

Issue 2868983003: Ensure History > Recent Tabs restore preserves window disposition. (Closed)
Patch Set: Minor cleanup. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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::GetBounds() const {
61 return browser_->window()->GetRestoredBounds();
62 }
63
64 ui::WindowShowState BrowserLiveTabContext::GetShowState() 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return sessions::ContentLiveTab::GetForWebContents(web_contents); 132 return sessions::ContentLiveTab::GetForWebContents(web_contents);
121 } 133 }
122 134
123 void BrowserLiveTabContext::CloseTab() { 135 void BrowserLiveTabContext::CloseTab() {
124 chrome::CloseTab(browser_); 136 chrome::CloseTab(browser_);
125 } 137 }
126 138
127 // static 139 // static
128 sessions::LiveTabContext* BrowserLiveTabContext::Create( 140 sessions::LiveTabContext* BrowserLiveTabContext::Create(
129 Profile* profile, 141 Profile* profile,
130 const std::string& app_name) { 142 const std::string& app_name,
131 Browser* browser; 143 const gfx::Rect& bounds,
144 ui::WindowShowState show_state,
145 const std::string& workspace) {
146 std::unique_ptr<Browser::CreateParams> create_params;
132 if (app_name.empty()) { 147 if (app_name.empty()) {
133 browser = new Browser(Browser::CreateParams(profile, true)); 148 create_params = base::MakeUnique<Browser::CreateParams>(
149 Browser::CreateParams(profile, true));
150 create_params->initial_bounds = bounds;
134 } else { 151 } else {
135 // Only trusted app popup windows should ever be restored. 152 // Only trusted app popup windows should ever be restored.
136 browser = new Browser(Browser::CreateParams::CreateForApp( 153 create_params = base::MakeUnique<Browser::CreateParams>(
137 app_name, true /* trusted_source */, gfx::Rect(), profile, true)); 154 Browser::CreateParams::CreateForApp(app_name, true /* trusted_source */,
155 bounds, profile,
156 true /* user_gesture */));
138 } 157 }
139 if (browser) 158 create_params->initial_show_state = show_state;
140 return browser->live_tab_context(); 159 create_params->initial_workspace = workspace;
141 else 160 Browser* browser = new Browser(*create_params.get());
142 return NULL; 161 return browser->live_tab_context();
143 } 162 }
144 163
145 // static 164 // static
146 sessions::LiveTabContext* BrowserLiveTabContext::FindContextForWebContents( 165 sessions::LiveTabContext* BrowserLiveTabContext::FindContextForWebContents(
147 const WebContents* contents) { 166 const WebContents* contents) {
148 Browser* browser = chrome::FindBrowserWithWebContents(contents); 167 Browser* browser = chrome::FindBrowserWithWebContents(contents);
149 return browser ? browser->live_tab_context() : nullptr; 168 return browser ? browser->live_tab_context() : nullptr;
150 } 169 }
151 170
152 // static 171 // static
153 sessions::LiveTabContext* BrowserLiveTabContext::FindContextWithID( 172 sessions::LiveTabContext* BrowserLiveTabContext::FindContextWithID(
154 SessionID::id_type desired_id) { 173 SessionID::id_type desired_id) {
155 Browser* browser = chrome::FindBrowserWithID(desired_id); 174 Browser* browser = chrome::FindBrowserWithID(desired_id);
156 return browser ? browser->live_tab_context() : nullptr; 175 return browser ? browser->live_tab_context() : nullptr;
157 } 176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698