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

Side by Side Diff: chrome/browser/sessions/session_service.cc

Issue 10383114: Rename BrowserInit to StartupBrowserCreator, and move into startup subdir. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
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/sessions/session_service.h" 5 #include "chrome/browser/sessions/session_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
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/command_line.h" 14 #include "base/command_line.h"
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
17 #include "base/message_loop.h" 17 #include "base/message_loop.h"
18 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
19 #include "base/pickle.h" 19 #include "base/pickle.h"
20 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
21 #include "chrome/browser/extensions/extension_tab_helper.h" 21 #include "chrome/browser/extensions/extension_tab_helper.h"
22 #include "chrome/browser/prefs/session_startup_pref.h" 22 #include "chrome/browser/prefs/session_startup_pref.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/sessions/restore_tab_helper.h" 24 #include "chrome/browser/sessions/restore_tab_helper.h"
25 #include "chrome/browser/sessions/session_backend.h" 25 #include "chrome/browser/sessions/session_backend.h"
26 #include "chrome/browser/sessions/session_command.h" 26 #include "chrome/browser/sessions/session_command.h"
27 #include "chrome/browser/sessions/session_restore.h" 27 #include "chrome/browser/sessions/session_restore.h"
28 #include "chrome/browser/sessions/session_types.h" 28 #include "chrome/browser/sessions/session_types.h"
29 #include "chrome/browser/tabs/tab_strip_model.h" 29 #include "chrome/browser/tabs/tab_strip_model.h"
30 #include "chrome/browser/ui/browser_init.h"
31 #include "chrome/browser/ui/browser_list.h" 30 #include "chrome/browser/ui/browser_list.h"
32 #include "chrome/browser/ui/browser_window.h" 31 #include "chrome/browser/ui/browser_window.h"
32 #include "chrome/browser/ui/startup/startup_browser_creator.h"
33 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 33 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
34 #include "chrome/common/chrome_notification_types.h" 34 #include "chrome/common/chrome_notification_types.h"
35 #include "chrome/common/extensions/extension.h" 35 #include "chrome/common/extensions/extension.h"
36 #include "content/public/browser/navigation_details.h" 36 #include "content/public/browser/navigation_details.h"
37 #include "content/public/browser/navigation_entry.h" 37 #include "content/public/browser/navigation_entry.h"
38 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
39 #include "content/public/browser/notification_details.h" 39 #include "content/public/browser/notification_details.h"
40 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
41 41
42 #if defined(OS_MACOSX) 42 #if defined(OS_MACOSX)
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 525
526 bool SessionService::ShouldNewWindowStartSession() { 526 bool SessionService::ShouldNewWindowStartSession() {
527 // ChromeOS and OSX have different ideas of application lifetime than 527 // ChromeOS and OSX have different ideas of application lifetime than
528 // the other platforms. 528 // the other platforms.
529 // On ChromeOS opening a new window should never start a new session. 529 // On ChromeOS opening a new window should never start a new session.
530 #if defined(OS_CHROMEOS) 530 #if defined(OS_CHROMEOS)
531 if (!force_browser_not_alive_with_no_windows_) 531 if (!force_browser_not_alive_with_no_windows_)
532 return false; 532 return false;
533 #endif 533 #endif
534 if (!has_open_trackable_browsers_ && 534 if (!has_open_trackable_browsers_ &&
535 !BrowserInit::InSynchronousProfileLaunch() && 535 !StartupBrowserCreator::InSynchronousProfileLaunch() &&
536 !SessionRestore::IsRestoring(profile()) 536 !SessionRestore::IsRestoring(profile())
537 #if defined(OS_MACOSX) 537 #if defined(OS_MACOSX)
538 // On OSX, a new window should not start a new session if it was opened 538 // On OSX, a new window should not start a new session if it was opened
539 // from the dock or the menubar. 539 // from the dock or the menubar.
540 && !app_controller_mac::IsOpeningNewWindow() 540 && !app_controller_mac::IsOpeningNewWindow()
541 #endif // OS_MACOSX 541 #endif // OS_MACOSX
542 ) { 542 ) {
543 return true; 543 return true;
544 } 544 }
545 return false; 545 return false;
546 } 546 }
547 547
548 bool SessionService::RestoreIfNecessary(const std::vector<GURL>& urls_to_open, 548 bool SessionService::RestoreIfNecessary(const std::vector<GURL>& urls_to_open,
549 Browser* browser) { 549 Browser* browser) {
550 if (ShouldNewWindowStartSession()) { 550 if (ShouldNewWindowStartSession()) {
551 // We're going from no tabbed browsers to a tabbed browser (and not in 551 // We're going from no tabbed browsers to a tabbed browser (and not in
552 // process startup), restore the last session. 552 // process startup), restore the last session.
553 if (move_on_new_browser_) { 553 if (move_on_new_browser_) {
554 // Make the current session the last. 554 // Make the current session the last.
555 MoveCurrentSessionToLastSession(); 555 MoveCurrentSessionToLastSession();
556 move_on_new_browser_ = false; 556 move_on_new_browser_ = false;
557 } 557 }
558 SessionStartupPref pref = BrowserInit::GetSessionStartupPref( 558 SessionStartupPref pref = StartupBrowserCreator::GetSessionStartupPref(
559 *CommandLine::ForCurrentProcess(), profile()); 559 *CommandLine::ForCurrentProcess(), profile());
560 if (pref.type == SessionStartupPref::LAST) { 560 if (pref.type == SessionStartupPref::LAST) {
561 SessionRestore::RestoreSession( 561 SessionRestore::RestoreSession(
562 profile(), browser, 562 profile(), browser,
563 browser ? 0 : SessionRestore::ALWAYS_CREATE_TABBED_BROWSER, 563 browser ? 0 : SessionRestore::ALWAYS_CREATE_TABBED_BROWSER,
564 urls_to_open); 564 urls_to_open);
565 return true; 565 return true;
566 } 566 }
567 } 567 }
568 return false; 568 return false;
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 50); 1622 50);
1623 if (use_long_period) { 1623 if (use_long_period) {
1624 std::string long_name_("SessionRestore.SaveLongPeriod"); 1624 std::string long_name_("SessionRestore.SaveLongPeriod");
1625 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, 1625 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_,
1626 delta, 1626 delta,
1627 save_delay_in_mins_, 1627 save_delay_in_mins_,
1628 save_delay_in_hrs_, 1628 save_delay_in_hrs_,
1629 50); 1629 50);
1630 } 1630 }
1631 } 1631 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore_browsertest.cc ('k') | chrome/browser/tabs/pinned_tab_codec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698