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 <algorithm> | 7 #include <algorithm> |
8 #include <list> | 8 #include <list> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 browser, tab.navigations, tab_index, selected_index, | 221 browser, tab.navigations, tab_index, selected_index, |
222 tab.extension_app_id, | 222 tab.extension_app_id, |
223 disposition == NEW_FOREGROUND_TAB, // selected | 223 disposition == NEW_FOREGROUND_TAB, // selected |
224 tab.pinned, true, nullptr, tab.user_agent_override); | 224 tab.pinned, true, nullptr, tab.user_agent_override); |
225 // Start loading the tab immediately. | 225 // Start loading the tab immediately. |
226 web_contents->GetController().LoadIfNecessary(); | 226 web_contents->GetController().LoadIfNecessary(); |
227 } | 227 } |
228 | 228 |
229 if (use_new_window) { | 229 if (use_new_window) { |
230 browser->tab_strip_model()->ActivateTabAt(0, true); | 230 browser->tab_strip_model()->ActivateTabAt(0, true); |
231 browser->window()->Show(); | 231 // TODO(johnme): Can we sometimes be certain this was for a user gesture? |
| 232 browser->window()->Show(false /* user_gesture */); |
232 } | 233 } |
233 NotifySessionServiceOfRestoredTabs(browser, | 234 NotifySessionServiceOfRestoredTabs(browser, |
234 browser->tab_strip_model()->count()); | 235 browser->tab_strip_model()->count()); |
235 | 236 |
236 // Since FinishedTabCreation() is not called here, |this| will leak if we | 237 // Since FinishedTabCreation() is not called here, |this| will leak if we |
237 // are not in sychronous mode. | 238 // are not in sychronous mode. |
238 DCHECK(synchronous_); | 239 DCHECK(synchronous_); |
239 | 240 |
240 on_session_restored_callbacks_->Notify(1); | 241 on_session_restored_callbacks_->Notify(1); |
241 | 242 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 Browser* browser = nullptr; | 287 Browser* browser = nullptr; |
287 if (!created_tabbed_browser && always_create_tabbed_browser_) { | 288 if (!created_tabbed_browser && always_create_tabbed_browser_) { |
288 browser = | 289 browser = |
289 new Browser(Browser::CreateParams(profile_, host_desktop_type_)); | 290 new Browser(Browser::CreateParams(profile_, host_desktop_type_)); |
290 if (urls_to_open_.empty()) { | 291 if (urls_to_open_.empty()) { |
291 // No tab browsers were created and no URLs were supplied on the command | 292 // No tab browsers were created and no URLs were supplied on the command |
292 // line. Open the new tab page. | 293 // line. Open the new tab page. |
293 urls_to_open_.push_back(GURL(chrome::kChromeUINewTabURL)); | 294 urls_to_open_.push_back(GURL(chrome::kChromeUINewTabURL)); |
294 } | 295 } |
295 AppendURLsToBrowser(browser, urls_to_open_); | 296 AppendURLsToBrowser(browser, urls_to_open_); |
296 browser->window()->Show(); | 297 // TODO(johnme): Can we sometimes be certain this was for a user gesture? |
| 298 browser->window()->Show(false /* user_gesture */); |
297 } | 299 } |
298 | 300 |
299 if (succeeded) { | 301 if (succeeded) { |
300 // Start Loading tabs. | 302 // Start Loading tabs. |
301 if (SessionRestore::GetSmartRestoreMode() != | 303 if (SessionRestore::GetSmartRestoreMode() != |
302 SessionRestore::SMART_RESTORE_MODE_OFF) | 304 SessionRestore::SMART_RESTORE_MODE_OFF) |
303 std::stable_sort(contents_created->begin(), contents_created->end()); | 305 std::stable_sort(contents_created->begin(), contents_created->end()); |
304 SessionRestoreDelegate::RestoreTabs(*contents_created, restore_started_); | 306 SessionRestoreDelegate::RestoreTabs(*contents_created, restore_started_); |
305 } | 307 } |
306 | 308 |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 } | 616 } |
615 | 617 |
616 void ShowBrowser(Browser* browser, int selected_tab_index) { | 618 void ShowBrowser(Browser* browser, int selected_tab_index) { |
617 DCHECK(browser); | 619 DCHECK(browser); |
618 DCHECK(browser->tab_strip_model()->count()); | 620 DCHECK(browser->tab_strip_model()->count()); |
619 browser->tab_strip_model()->ActivateTabAt(selected_tab_index, true); | 621 browser->tab_strip_model()->ActivateTabAt(selected_tab_index, true); |
620 | 622 |
621 if (browser_ == browser) | 623 if (browser_ == browser) |
622 return; | 624 return; |
623 | 625 |
624 browser->window()->Show(); | 626 // TODO(johnme): Can we sometimes be certain this was for a user gesture? |
| 627 browser->window()->Show(false /* user_gesture */); |
625 browser->set_is_session_restore(false); | 628 browser->set_is_session_restore(false); |
626 | 629 |
627 // TODO(jcampan): http://crbug.com/8123 we should not need to set the | 630 // TODO(jcampan): http://crbug.com/8123 we should not need to set the |
628 // initial focus explicitly. | 631 // initial focus explicitly. |
629 browser->tab_strip_model()->GetActiveWebContents()->SetInitialFocus(); | 632 browser->tab_strip_model()->GetActiveWebContents()->SetInitialFocus(); |
630 } | 633 } |
631 | 634 |
632 // Appends the urls in |urls| to |browser|. | 635 // Appends the urls in |urls| to |browser|. |
633 void AppendURLsToBrowser(Browser* browser, const std::vector<GURL>& urls) { | 636 void AppendURLsToBrowser(Browser* browser, const std::vector<GURL>& urls) { |
634 for (size_t i = 0; i < urls.size(); ++i) { | 637 for (size_t i = 0; i < urls.size(); ++i) { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 if (prioritize_tabs == "mru") | 830 if (prioritize_tabs == "mru") |
828 return SMART_RESTORE_MODE_MRU; | 831 return SMART_RESTORE_MODE_MRU; |
829 if (prioritize_tabs == "simple") | 832 if (prioritize_tabs == "simple") |
830 return SMART_RESTORE_MODE_SIMPLE; | 833 return SMART_RESTORE_MODE_SIMPLE; |
831 return SMART_RESTORE_MODE_OFF; | 834 return SMART_RESTORE_MODE_OFF; |
832 } | 835 } |
833 | 836 |
834 // static | 837 // static |
835 base::CallbackList<void(int)>* | 838 base::CallbackList<void(int)>* |
836 SessionRestore::on_session_restored_callbacks_ = nullptr; | 839 SessionRestore::on_session_restored_callbacks_ = nullptr; |
OLD | NEW |