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/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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
18 #include "base/platform_file.h" | 18 #include "base/platform_file.h" |
19 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
20 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/extensions/extension_service.h" | 22 #include "chrome/browser/extensions/extension_service.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/sessions/session_service.h" | 24 #include "chrome/browser/sessions/session_service.h" |
25 #include "chrome/browser/sessions/session_service_factory.h" | 25 #include "chrome/browser/sessions/session_service_factory.h" |
26 #include "chrome/browser/sessions/session_types.h" | 26 #include "chrome/browser/sessions/session_types.h" |
27 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
28 #include "chrome/browser/ui/browser_list.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
29 #include "chrome/browser/ui/browser_navigator.h" | 29 #include "chrome/browser/ui/browser_navigator.h" |
30 #include "chrome/browser/ui/browser_window.h" | 30 #include "chrome/browser/ui/browser_window.h" |
31 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
32 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 32 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
33 #include "chrome/common/chrome_notification_types.h" | 33 #include "chrome/common/chrome_notification_types.h" |
34 #include "content/public/browser/child_process_security_policy.h" | 34 #include "content/public/browser/child_process_security_policy.h" |
35 #include "content/public/browser/navigation_controller.h" | 35 #include "content/public/browser/navigation_controller.h" |
36 #include "content/public/browser/notification_registrar.h" | 36 #include "content/public/browser/notification_registrar.h" |
37 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
38 #include "content/public/browser/render_process_host.h" | 38 #include "content/public/browser/render_process_host.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 if (!tabs_to_load_.empty()) { | 254 if (!tabs_to_load_.empty()) { |
255 NavigationController* tab = tabs_to_load_.front(); | 255 NavigationController* tab = tabs_to_load_.front(); |
256 DCHECK(tab); | 256 DCHECK(tab); |
257 tabs_loading_.insert(tab); | 257 tabs_loading_.insert(tab); |
258 if (tabs_loading_.size() > max_parallel_tab_loads_) | 258 if (tabs_loading_.size() > max_parallel_tab_loads_) |
259 max_parallel_tab_loads_ = tabs_loading_.size(); | 259 max_parallel_tab_loads_ = tabs_loading_.size(); |
260 tabs_to_load_.pop_front(); | 260 tabs_to_load_.pop_front(); |
261 tab->LoadIfNecessary(); | 261 tab->LoadIfNecessary(); |
262 if (tab->GetWebContents()) { | 262 if (tab->GetWebContents()) { |
263 int tab_index; | 263 int tab_index; |
264 Browser* browser = Browser::GetBrowserForController(tab, &tab_index); | 264 Browser* browser = browser::FindBrowserForController(tab, &tab_index); |
265 if (browser && browser->active_index() != tab_index) { | 265 if (browser && browser->active_index() != tab_index) { |
266 // By default tabs are marked as visible. As only the active tab is | 266 // By default tabs are marked as visible. As only the active tab is |
267 // visible we need to explicitly tell non-active tabs they are hidden. | 267 // visible we need to explicitly tell non-active tabs they are hidden. |
268 // Without this call non-active tabs are not marked as backgrounded. | 268 // Without this call non-active tabs are not marked as backgrounded. |
269 // | 269 // |
270 // NOTE: We need to do this here rather than when the tab is added to | 270 // NOTE: We need to do this here rather than when the tab is added to |
271 // the Browser as at that time not everything has been created, so that | 271 // the Browser as at that time not everything has been created, so that |
272 // the call would do nothing. | 272 // the call would do nothing. |
273 tab->GetWebContents()->WasHidden(); | 273 tab->GetWebContents()->WasHidden(); |
274 } | 274 } |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 std::min(selected_index, | 567 std::min(selected_index, |
568 static_cast<int>(tab.navigations.size() - 1))); | 568 static_cast<int>(tab.navigations.size() - 1))); |
569 | 569 |
570 bool use_new_window = disposition == NEW_WINDOW; | 570 bool use_new_window = disposition == NEW_WINDOW; |
571 | 571 |
572 // The browser should not be specified; the browser to use is | 572 // The browser should not be specified; the browser to use is |
573 // dictated by the WindowOpenDisposition. | 573 // dictated by the WindowOpenDisposition. |
574 DCHECK(browser_ == NULL); | 574 DCHECK(browser_ == NULL); |
575 Browser* browser = use_new_window ? | 575 Browser* browser = use_new_window ? |
576 Browser::Create(profile_) : | 576 Browser::Create(profile_) : |
577 BrowserList::GetLastActiveWithProfile(profile_); | 577 browser::FindLastActiveWithProfile(profile_); |
578 | 578 |
579 RecordAppLaunchForTab(browser, tab, selected_index); | 579 RecordAppLaunchForTab(browser, tab, selected_index); |
580 | 580 |
581 if (disposition == CURRENT_TAB) { | 581 if (disposition == CURRENT_TAB) { |
582 DCHECK(!use_new_window); | 582 DCHECK(!use_new_window); |
583 browser->ReplaceRestoredTab(tab.navigations, | 583 browser->ReplaceRestoredTab(tab.navigations, |
584 selected_index, | 584 selected_index, |
585 true, | 585 true, |
586 tab.extension_app_id, | 586 tab.extension_app_id, |
587 NULL); | 587 NULL); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 return FinishedTabCreation(false, false); | 730 return FinishedTabCreation(false, false); |
731 } | 731 } |
732 | 732 |
733 #if defined(OS_CHROMEOS) | 733 #if defined(OS_CHROMEOS) |
734 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( | 734 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( |
735 "SessionRestore-CreatingTabs-Start", false); | 735 "SessionRestore-CreatingTabs-Start", false); |
736 #endif | 736 #endif |
737 StartTabCreation(); | 737 StartTabCreation(); |
738 | 738 |
739 Browser* current_browser = | 739 Browser* current_browser = |
740 browser_ ? browser_ : BrowserList::GetLastActiveWithProfile(profile_); | 740 browser_ ? browser_ : browser::FindLastActiveWithProfile(profile_); |
741 // After the for loop this contains the last TABBED_BROWSER. Is null if no | 741 // After the for loop this contains the last TABBED_BROWSER. Is null if no |
742 // tabbed browsers exist. | 742 // tabbed browsers exist. |
743 Browser* last_browser = NULL; | 743 Browser* last_browser = NULL; |
744 bool has_tabbed_browser = false; | 744 bool has_tabbed_browser = false; |
745 | 745 |
746 // Determine if there is a visible window. | 746 // Determine if there is a visible window. |
747 bool has_visible_browser = false; | 747 bool has_visible_browser = false; |
748 for (std::vector<SessionWindow*>::iterator i = windows->begin(); | 748 for (std::vector<SessionWindow*>::iterator i = windows->begin(); |
749 i != windows->end(); ++i) { | 749 i != windows->end(); ++i) { |
750 if ((*i)->show_state != ui::SHOW_STATE_MINIMIZED) | 750 if ((*i)->show_state != ui::SHOW_STATE_MINIMIZED) |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 if (active_session_restorers == NULL) | 1078 if (active_session_restorers == NULL) |
1079 return false; | 1079 return false; |
1080 for (std::set<SessionRestoreImpl*>::const_iterator it = | 1080 for (std::set<SessionRestoreImpl*>::const_iterator it = |
1081 active_session_restorers->begin(); | 1081 active_session_restorers->begin(); |
1082 it != active_session_restorers->end(); ++it) { | 1082 it != active_session_restorers->end(); ++it) { |
1083 if ((*it)->profile() == profile) | 1083 if ((*it)->profile() == profile) |
1084 return true; | 1084 return true; |
1085 } | 1085 } |
1086 return false; | 1086 return false; |
1087 } | 1087 } |
OLD | NEW |