OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/sessions/session_restore.h" | 5 #include "chrome/browser/sessions/session_restore.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 WebContents* RestoreForeignTab(const sessions::SessionTab& tab, | 206 WebContents* RestoreForeignTab(const sessions::SessionTab& tab, |
207 WindowOpenDisposition disposition) { | 207 WindowOpenDisposition disposition) { |
208 DCHECK(!tab.navigations.empty()); | 208 DCHECK(!tab.navigations.empty()); |
209 int selected_index = tab.current_navigation_index; | 209 int selected_index = tab.current_navigation_index; |
210 selected_index = std::max( | 210 selected_index = std::max( |
211 0, | 211 0, |
212 std::min(selected_index, static_cast<int>(tab.navigations.size() - 1))); | 212 std::min(selected_index, static_cast<int>(tab.navigations.size() - 1))); |
213 | 213 |
214 bool use_new_window = disposition == WindowOpenDisposition::NEW_WINDOW; | 214 bool use_new_window = disposition == WindowOpenDisposition::NEW_WINDOW; |
215 | 215 |
216 Browser* browser = | 216 Browser* browser = use_new_window |
217 use_new_window | 217 ? new Browser(Browser::CreateParams(profile_, true)) |
218 ? new Browser(Browser::CreateParams(profile_)) | 218 : browser_; |
219 : browser_; | |
220 | 219 |
221 RecordAppLaunchForTab(browser, tab, selected_index); | 220 RecordAppLaunchForTab(browser, tab, selected_index); |
222 | 221 |
223 WebContents* web_contents; | 222 WebContents* web_contents; |
224 if (disposition == WindowOpenDisposition::CURRENT_TAB) { | 223 if (disposition == WindowOpenDisposition::CURRENT_TAB) { |
225 DCHECK(!use_new_window); | 224 DCHECK(!use_new_window); |
226 web_contents = chrome::ReplaceRestoredTab( | 225 web_contents = chrome::ReplaceRestoredTab( |
227 browser, tab.navigations, selected_index, true, tab.extension_app_id, | 226 browser, tab.navigations, selected_index, true, tab.extension_app_id, |
228 nullptr, tab.user_agent_override); | 227 nullptr, tab.user_agent_override); |
229 } else { | 228 } else { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 // | 285 // |
287 // If successful, this begins loading tabs and deletes itself when all tabs | 286 // If successful, this begins loading tabs and deletes itself when all tabs |
288 // have been loaded. | 287 // have been loaded. |
289 // | 288 // |
290 // Returns the Browser that was created, if any. | 289 // Returns the Browser that was created, if any. |
291 Browser* FinishedTabCreation(bool succeeded, | 290 Browser* FinishedTabCreation(bool succeeded, |
292 bool created_tabbed_browser, | 291 bool created_tabbed_browser, |
293 std::vector<RestoredTab>* contents_created) { | 292 std::vector<RestoredTab>* contents_created) { |
294 Browser* browser = nullptr; | 293 Browser* browser = nullptr; |
295 if (!created_tabbed_browser && always_create_tabbed_browser_) { | 294 if (!created_tabbed_browser && always_create_tabbed_browser_) { |
296 browser = new Browser(Browser::CreateParams(profile_)); | 295 browser = new Browser(Browser::CreateParams(profile_, false)); |
297 if (urls_to_open_.empty()) { | 296 if (urls_to_open_.empty()) { |
298 // No tab browsers were created and no URLs were supplied on the command | 297 // No tab browsers were created and no URLs were supplied on the command |
299 // line. Open the new tab page. | 298 // line. Open the new tab page. |
300 urls_to_open_.push_back(GURL(chrome::kChromeUINewTabURL)); | 299 urls_to_open_.push_back(GURL(chrome::kChromeUINewTabURL)); |
301 } | 300 } |
302 AppendURLsToBrowser(browser, urls_to_open_); | 301 AppendURLsToBrowser(browser, urls_to_open_); |
303 browser->window()->Show(); | 302 browser->window()->Show(); |
304 } | 303 } |
305 | 304 |
306 if (succeeded) { | 305 if (succeeded) { |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 DCHECK(web_contents->GetController().NeedsReload()); | 622 DCHECK(web_contents->GetController().NeedsReload()); |
624 | 623 |
625 return web_contents; | 624 return web_contents; |
626 } | 625 } |
627 | 626 |
628 Browser* CreateRestoredBrowser(Browser::Type type, | 627 Browser* CreateRestoredBrowser(Browser::Type type, |
629 gfx::Rect bounds, | 628 gfx::Rect bounds, |
630 const std::string& workspace, | 629 const std::string& workspace, |
631 ui::WindowShowState show_state, | 630 ui::WindowShowState show_state, |
632 const std::string& app_name) { | 631 const std::string& app_name) { |
633 Browser::CreateParams params(type, profile_); | 632 Browser::CreateParams params(type, profile_, false); |
634 if (!app_name.empty()) { | 633 if (!app_name.empty()) { |
635 const bool trusted_source = true; // We only store trusted app windows. | 634 const bool trusted_source = true; // We only store trusted app windows. |
636 params = Browser::CreateParams::CreateForApp(app_name, trusted_source, | 635 params = Browser::CreateParams::CreateForApp(app_name, trusted_source, |
637 bounds, profile_); | 636 bounds, profile_, false); |
638 } else { | 637 } else { |
639 params.initial_bounds = bounds; | 638 params.initial_bounds = bounds; |
640 } | 639 } |
641 params.initial_show_state = show_state; | 640 params.initial_show_state = show_state; |
642 params.initial_workspace = workspace; | 641 params.initial_workspace = workspace; |
643 params.is_session_restore = true; | 642 params.is_session_restore = true; |
644 return new Browser(params); | 643 return new Browser(params); |
645 } | 644 } |
646 | 645 |
647 void ShowBrowser(Browser* browser, int selected_tab_index) { | 646 void ShowBrowser(Browser* browser, int selected_tab_index) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 // static | 844 // static |
846 SessionRestore::CallbackSubscription | 845 SessionRestore::CallbackSubscription |
847 SessionRestore::RegisterOnSessionRestoredCallback( | 846 SessionRestore::RegisterOnSessionRestoredCallback( |
848 const base::Callback<void(int)>& callback) { | 847 const base::Callback<void(int)>& callback) { |
849 return on_session_restored_callbacks()->Add(callback); | 848 return on_session_restored_callbacks()->Add(callback); |
850 } | 849 } |
851 | 850 |
852 // static | 851 // static |
853 base::CallbackList<void(int)>* | 852 base::CallbackList<void(int)>* |
854 SessionRestore::on_session_restored_callbacks_ = nullptr; | 853 SessionRestore::on_session_restored_callbacks_ = nullptr; |
OLD | NEW |