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

Side by Side Diff: chrome/browser/ui/browser_init.cc

Issue 7497056: Mac Lion: Chrome opens new window on restart when no windows were previously open (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Braces Created 9 years, 4 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
« no previous file with comments | « base/mac/mac_util.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_init.h" 5 #include "chrome/browser/ui/browser_init.h"
6 6
7 #include <algorithm> // For max(). 7 #include <algorithm> // For max().
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 #include "grit/generated_resources.h" 71 #include "grit/generated_resources.h"
72 #include "grit/locale_settings.h" 72 #include "grit/locale_settings.h"
73 #include "grit/theme_resources.h" 73 #include "grit/theme_resources.h"
74 #include "grit/theme_resources_standard.h" 74 #include "grit/theme_resources_standard.h"
75 #include "net/base/net_util.h" 75 #include "net/base/net_util.h"
76 #include "ui/base/l10n/l10n_util.h" 76 #include "ui/base/l10n/l10n_util.h"
77 #include "ui/base/resource/resource_bundle.h" 77 #include "ui/base/resource/resource_bundle.h"
78 #include "webkit/glue/webkit_glue.h" 78 #include "webkit/glue/webkit_glue.h"
79 79
80 #if defined(OS_MACOSX) 80 #if defined(OS_MACOSX)
81 #include "base/mac/mac_util.h"
81 #include "chrome/browser/ui/cocoa/keystone_infobar.h" 82 #include "chrome/browser/ui/cocoa/keystone_infobar.h"
82 #endif 83 #endif
83 84
84 #if defined(TOOLKIT_USES_GTK) 85 #if defined(TOOLKIT_USES_GTK)
85 #include "chrome/browser/ui/gtk/gtk_util.h" 86 #include "chrome/browser/ui/gtk/gtk_util.h"
86 #endif 87 #endif
87 88
88 #if defined(OS_CHROMEOS) 89 #if defined(OS_CHROMEOS)
89 #include "chrome/browser/chromeos/cros/cros_library.h" 90 #include "chrome/browser/chromeos/cros/cros_library.h"
90 #include "chrome/browser/chromeos/cros/mount_library.h" 91 #include "chrome/browser/chromeos/cros/mount_library.h"
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 906
906 if (pref.type == SessionStartupPref::LAST) { 907 if (pref.type == SessionStartupPref::LAST) {
907 if (!profile_->DidLastSessionExitCleanly() && 908 if (!profile_->DidLastSessionExitCleanly() &&
908 !command_line_.HasSwitch(switches::kRestoreLastSession)) { 909 !command_line_.HasSwitch(switches::kRestoreLastSession)) {
909 // The last session crashed. It's possible automatically loading the 910 // The last session crashed. It's possible automatically loading the
910 // page will trigger another crash, locking the user out of chrome. 911 // page will trigger another crash, locking the user out of chrome.
911 // To avoid this, don't restore on startup but instead show the crashed 912 // To avoid this, don't restore on startup but instead show the crashed
912 // infobar. 913 // infobar.
913 return false; 914 return false;
914 } 915 }
915 Browser* browser = SessionRestore::RestoreSession( 916
916 profile_, NULL, 917 uint32 restore_behavior = SessionRestore::SYNCHRONOUS |
917 (SessionRestore::SYNCHRONOUS | 918 SessionRestore::ALWAYS_CREATE_TABBED_BROWSER;
918 SessionRestore::ALWAYS_CREATE_TABBED_BROWSER), urls_to_open); 919 #if defined(OS_MACOSX)
920 // On Mac, when restoring a session with no windows, suppress the creation
921 // of a new window in the case where the system is launching Chrome via a
922 // login item or Lion's resume feature.
923 if (base::mac::WasLaunchedAsLoginOrResumeItem()) {
924 restore_behavior = restore_behavior &
925 ~SessionRestore::ALWAYS_CREATE_TABBED_BROWSER;
926 }
927 #endif
928
929 Browser* browser = SessionRestore::RestoreSession(profile_,
930 NULL,
931 restore_behavior,
932 urls_to_open);
919 AddInfoBarsIfNecessary(browser); 933 AddInfoBarsIfNecessary(browser);
920 return true; 934 return true;
921 } 935 }
922 936
923 std::vector<Tab> tabs = PinnedTabCodec::ReadPinnedTabs(profile_); 937 std::vector<Tab> tabs = PinnedTabCodec::ReadPinnedTabs(profile_);
924 938
925 RecordAppLaunches(profile_, urls_to_open, tabs); 939 RecordAppLaunches(profile_, urls_to_open, tabs);
926 940
927 if (!urls_to_open.empty()) { 941 if (!urls_to_open.empty()) {
928 // If urls were specified on the command line, use them. 942 // If urls were specified on the command line, use them.
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 return false; 1466 return false;
1453 automation->SetExpectedTabCount(expected_tabs); 1467 automation->SetExpectedTabCount(expected_tabs);
1454 1468
1455 AutomationProviderList* list = 1469 AutomationProviderList* list =
1456 g_browser_process->InitAutomationProviderList(); 1470 g_browser_process->InitAutomationProviderList();
1457 DCHECK(list); 1471 DCHECK(list);
1458 list->AddProvider(automation); 1472 list->AddProvider(automation);
1459 1473
1460 return true; 1474 return true;
1461 } 1475 }
OLDNEW
« no previous file with comments | « base/mac/mac_util.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698