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

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: Small cleanup. Created 3 years, 7 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 auto* window = browser_->window();
sky 2017/05/08 22:51:35 Please don't use auto* here. Using auto here reduc
chrisha 2017/05/09 15:44:54 Yeah, from what I can see window() should never be
62 if (window)
63 return window->GetRestoredBounds();
64 return browser_->override_bounds();
65 }
66
67 ui::WindowShowState BrowserLiveTabContext::GetShowState() const {
68 auto* window = browser_->window();
69 if (window)
70 return window->GetRestoredState();
71 return browser_->initial_show_state();
72 }
73
74 std::string BrowserLiveTabContext::GetWorkspace() const {
75 auto* window = browser_->window();
76 if (window)
77 return window->GetWorkspace();
78 return browser_->initial_workspace();
79 }
80
60 sessions::LiveTab* BrowserLiveTabContext::AddRestoredTab( 81 sessions::LiveTab* BrowserLiveTabContext::AddRestoredTab(
61 const std::vector<sessions::SerializedNavigationEntry>& navigations, 82 const std::vector<sessions::SerializedNavigationEntry>& navigations,
62 int tab_index, 83 int tab_index,
63 int selected_navigation, 84 int selected_navigation,
64 const std::string& extension_app_id, 85 const std::string& extension_app_id,
65 bool select, 86 bool select,
66 bool pin, 87 bool pin,
67 bool from_last_session, 88 bool from_last_session,
68 const sessions::PlatformSpecificTabData* tab_platform_data, 89 const sessions::PlatformSpecificTabData* tab_platform_data,
69 const std::string& user_agent_override) { 90 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); 141 return sessions::ContentLiveTab::GetForWebContents(web_contents);
121 } 142 }
122 143
123 void BrowserLiveTabContext::CloseTab() { 144 void BrowserLiveTabContext::CloseTab() {
124 chrome::CloseTab(browser_); 145 chrome::CloseTab(browser_);
125 } 146 }
126 147
127 // static 148 // static
128 sessions::LiveTabContext* BrowserLiveTabContext::Create( 149 sessions::LiveTabContext* BrowserLiveTabContext::Create(
129 Profile* profile, 150 Profile* profile,
130 const std::string& app_name) { 151 const std::string& app_name,
152 const gfx::Rect& bounds,
153 ui::WindowShowState show_state,
154 const std::string& workspace) {
131 Browser* browser; 155 Browser* browser;
sky 2017/05/08 22:51:35 Move this to line 170 where it's used.
chrisha 2017/05/09 15:44:54 Done.
156 std::unique_ptr<Browser::CreateParams> create_params;
132 if (app_name.empty()) { 157 if (app_name.empty()) {
133 browser = new Browser(Browser::CreateParams(profile, true)); 158 create_params = std::make_unique<Browser::CreateParams>(
sky 2017/05/08 22:51:35 MakeUnique? We're not using c++ 14 yet are we?
chrisha 2017/05/09 15:44:54 Oops, not yet :)
159 Browser::CreateParams(profile, true));
160 create_params->initial_bounds = bounds;
134 } else { 161 } else {
135 // Only trusted app popup windows should ever be restored. 162 // Only trusted app popup windows should ever be restored.
136 browser = new Browser(Browser::CreateParams::CreateForApp( 163 create_params = std::make_unique<Browser::CreateParams>(
137 app_name, true /* trusted_source */, gfx::Rect(), profile, true)); 164 Browser::CreateParams::CreateForApp(app_name, true /* trusted_source */,
165 bounds, profile,
166 true /* user_gesture */));
138 } 167 }
168 create_params->initial_show_state = show_state;
169 create_params->initial_workspace = workspace;
170 browser = new Browser(*create_params.get());
139 if (browser) 171 if (browser)
sky 2017/05/08 22:51:35 |browser| should always be non-null.
chrisha 2017/05/09 15:44:54 Done.
140 return browser->live_tab_context(); 172 return browser->live_tab_context();
141 else 173
142 return NULL; 174 return nullptr;
143 } 175 }
144 176
145 // static 177 // static
146 sessions::LiveTabContext* BrowserLiveTabContext::FindContextForWebContents( 178 sessions::LiveTabContext* BrowserLiveTabContext::FindContextForWebContents(
147 const WebContents* contents) { 179 const WebContents* contents) {
148 Browser* browser = chrome::FindBrowserWithWebContents(contents); 180 Browser* browser = chrome::FindBrowserWithWebContents(contents);
149 return browser ? browser->live_tab_context() : nullptr; 181 return browser ? browser->live_tab_context() : nullptr;
150 } 182 }
151 183
152 // static 184 // static
153 sessions::LiveTabContext* BrowserLiveTabContext::FindContextWithID( 185 sessions::LiveTabContext* BrowserLiveTabContext::FindContextWithID(
154 SessionID::id_type desired_id) { 186 SessionID::id_type desired_id) {
155 Browser* browser = chrome::FindBrowserWithID(desired_id); 187 Browser* browser = chrome::FindBrowserWithID(desired_id);
156 return browser ? browser->live_tab_context() : nullptr; 188 return browser ? browser->live_tab_context() : nullptr;
157 } 189 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698