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/ui/startup/startup_browser_creator_impl.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "apps/app_restore_service.h" | 10 #include "apps/app_restore_service.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 | 285 |
286 GURL GetWelcomePageURL() { | 286 GURL GetWelcomePageURL() { |
287 std::string welcome_url = l10n_util::GetStringUTF8(IDS_WELCOME_PAGE_URL); | 287 std::string welcome_url = l10n_util::GetStringUTF8(IDS_WELCOME_PAGE_URL); |
288 return GURL(welcome_url); | 288 return GURL(welcome_url); |
289 } | 289 } |
290 | 290 |
291 } // namespace internals | 291 } // namespace internals |
292 | 292 |
293 StartupBrowserCreatorImpl::StartupBrowserCreatorImpl( | 293 StartupBrowserCreatorImpl::StartupBrowserCreatorImpl( |
294 const base::FilePath& cur_dir, | 294 const base::FilePath& cur_dir, |
295 const CommandLine& command_line, | 295 const base::CommandLine& command_line, |
296 chrome::startup::IsFirstRun is_first_run) | 296 chrome::startup::IsFirstRun is_first_run) |
297 : cur_dir_(cur_dir), | 297 : cur_dir_(cur_dir), |
298 command_line_(command_line), | 298 command_line_(command_line), |
299 profile_(NULL), | 299 profile_(NULL), |
300 browser_creator_(NULL), | 300 browser_creator_(NULL), |
301 is_first_run_(is_first_run == chrome::startup::IS_FIRST_RUN) { | 301 is_first_run_(is_first_run == chrome::startup::IS_FIRST_RUN) { |
302 } | 302 } |
303 | 303 |
304 StartupBrowserCreatorImpl::StartupBrowserCreatorImpl( | 304 StartupBrowserCreatorImpl::StartupBrowserCreatorImpl( |
305 const base::FilePath& cur_dir, | 305 const base::FilePath& cur_dir, |
306 const CommandLine& command_line, | 306 const base::CommandLine& command_line, |
307 StartupBrowserCreator* browser_creator, | 307 StartupBrowserCreator* browser_creator, |
308 chrome::startup::IsFirstRun is_first_run) | 308 chrome::startup::IsFirstRun is_first_run) |
309 : cur_dir_(cur_dir), | 309 : cur_dir_(cur_dir), |
310 command_line_(command_line), | 310 command_line_(command_line), |
311 profile_(NULL), | 311 profile_(NULL), |
312 browser_creator_(browser_creator), | 312 browser_creator_(browser_creator), |
313 is_first_run_(is_first_run == chrome::startup::IS_FIRST_RUN) { | 313 is_first_run_(is_first_run == chrome::startup::IS_FIRST_RUN) { |
314 } | 314 } |
315 | 315 |
316 StartupBrowserCreatorImpl::~StartupBrowserCreatorImpl() { | 316 StartupBrowserCreatorImpl::~StartupBrowserCreatorImpl() { |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 // The last session crashed. It's possible automatically loading the | 609 // The last session crashed. It's possible automatically loading the |
610 // page will trigger another crash, locking the user out of chrome. | 610 // page will trigger another crash, locking the user out of chrome. |
611 // To avoid this, don't restore on startup but instead show the crashed | 611 // To avoid this, don't restore on startup but instead show the crashed |
612 // infobar. | 612 // infobar. |
613 VLOG(1) << "Unclean exit; not processing"; | 613 VLOG(1) << "Unclean exit; not processing"; |
614 return false; | 614 return false; |
615 } | 615 } |
616 | 616 |
617 uint32 restore_behavior = SessionRestore::SYNCHRONOUS; | 617 uint32 restore_behavior = SessionRestore::SYNCHRONOUS; |
618 if (browser_defaults::kAlwaysCreateTabbedBrowserOnSessionRestore || | 618 if (browser_defaults::kAlwaysCreateTabbedBrowserOnSessionRestore || |
619 CommandLine::ForCurrentProcess()->HasSwitch( | 619 base::CommandLine::ForCurrentProcess()->HasSwitch( |
620 switches::kCreateBrowserOnStartupForTests)) { | 620 switches::kCreateBrowserOnStartupForTests)) { |
621 restore_behavior |= SessionRestore::ALWAYS_CREATE_TABBED_BROWSER; | 621 restore_behavior |= SessionRestore::ALWAYS_CREATE_TABBED_BROWSER; |
622 } | 622 } |
623 | 623 |
624 #if defined(OS_MACOSX) | 624 #if defined(OS_MACOSX) |
625 // On Mac, when restoring a session with no windows, suppress the creation | 625 // On Mac, when restoring a session with no windows, suppress the creation |
626 // of a new window in the case where the system is launching Chrome via a | 626 // of a new window in the case where the system is launching Chrome via a |
627 // login item or Lion's resume feature. | 627 // login item or Lion's resume feature. |
628 if (base::mac::WasLaunchedAsLoginOrResumeItem()) { | 628 if (base::mac::WasLaunchedAsLoginOrResumeItem()) { |
629 restore_behavior = restore_behavior & | 629 restore_behavior = restore_behavior & |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 } | 796 } |
797 | 797 |
798 // The default behavior is to show the window, as expressed by the default | 798 // The default behavior is to show the window, as expressed by the default |
799 // value of StartupBrowserCreated::show_main_browser_window_. If this was set | 799 // value of StartupBrowserCreated::show_main_browser_window_. If this was set |
800 // to true ahead of this place, it means another task must have been spawned | 800 // to true ahead of this place, it means another task must have been spawned |
801 // to take care of that. | 801 // to take care of that. |
802 if (!browser_creator_ || browser_creator_->show_main_browser_window()) | 802 if (!browser_creator_ || browser_creator_->show_main_browser_window()) |
803 browser->window()->Show(); | 803 browser->window()->Show(); |
804 | 804 |
805 // In kiosk mode, we want to always be fullscreen, so switch to that now. | 805 // In kiosk mode, we want to always be fullscreen, so switch to that now. |
806 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) || | 806 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) || |
807 CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartFullscreen)) | 807 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 808 switches::kStartFullscreen)) |
808 chrome::ToggleFullscreenMode(browser); | 809 chrome::ToggleFullscreenMode(browser); |
809 | 810 |
810 return browser; | 811 return browser; |
811 } | 812 } |
812 | 813 |
813 void StartupBrowserCreatorImpl::AddInfoBarsIfNecessary( | 814 void StartupBrowserCreatorImpl::AddInfoBarsIfNecessary( |
814 Browser* browser, | 815 Browser* browser, |
815 chrome::startup::IsProcessStartup is_process_startup) { | 816 chrome::startup::IsProcessStartup is_process_startup) { |
816 if (!browser || !profile_ || browser->tab_strip_model()->count() == 0) | 817 if (!browser || !profile_ || browser->tab_strip_model()->count() == 0) |
817 return; | 818 return; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 // behavior is desired because completing or skipping the sync promo | 906 // behavior is desired because completing or skipping the sync promo |
906 // causes a redirect to the NTP. | 907 // causes a redirect to the NTP. |
907 if (!startup_urls->empty() && | 908 if (!startup_urls->empty() && |
908 startup_urls->at(0) == GURL(chrome::kChromeUINewTabURL)) | 909 startup_urls->at(0) == GURL(chrome::kChromeUINewTabURL)) |
909 startup_urls->at(0) = sync_promo_url; | 910 startup_urls->at(0) = sync_promo_url; |
910 else | 911 else |
911 startup_urls->insert(startup_urls->begin(), sync_promo_url); | 912 startup_urls->insert(startup_urls->begin(), sync_promo_url); |
912 } | 913 } |
913 } | 914 } |
914 } | 915 } |
OLD | NEW |