| 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.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> // For max(). | 9 #include <algorithm> // For max(). |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // profiles are simply ignored. | 196 // profiles are simply ignored. |
| 197 std::set<const Profile*>::const_iterator i = launched_profiles_.begin(); | 197 std::set<const Profile*>::const_iterator i = launched_profiles_.begin(); |
| 198 for (; i != launched_profiles_.end(); ++i) { | 198 for (; i != launched_profiles_.end(); ++i) { |
| 199 if (opened_profiles_.find(*i) == opened_profiles_.end()) | 199 if (opened_profiles_.find(*i) == opened_profiles_.end()) |
| 200 return; | 200 return; |
| 201 } | 201 } |
| 202 // Asynchronous post to give a chance to the last window to completely | 202 // Asynchronous post to give a chance to the last window to completely |
| 203 // open and activate before trying to activate |profile_to_activate_|. | 203 // open and activate before trying to activate |profile_to_activate_|. |
| 204 BrowserThread::PostTask( | 204 BrowserThread::PostTask( |
| 205 BrowserThread::UI, FROM_HERE, | 205 BrowserThread::UI, FROM_HERE, |
| 206 base::Bind(&ProfileLaunchObserver::ActivateProfile, | 206 base::BindOnce(&ProfileLaunchObserver::ActivateProfile, |
| 207 base::Unretained(this))); | 207 base::Unretained(this))); |
| 208 // Avoid posting more than once before ActivateProfile gets called. | 208 // Avoid posting more than once before ActivateProfile gets called. |
| 209 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 209 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
| 210 content::NotificationService::AllSources()); | 210 content::NotificationService::AllSources()); |
| 211 registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 211 registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 212 content::NotificationService::AllSources()); | 212 content::NotificationService::AllSources()); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void ActivateProfile() { | 215 void ActivateProfile() { |
| 216 // We need to test again, in case the profile got deleted in the mean time. | 216 // We need to test again, in case the profile got deleted in the mean time. |
| 217 if (profile_to_activate_) { | 217 if (profile_to_activate_) { |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 // not open a new browser window even if no output file was given. | 681 // not open a new browser window even if no output file was given. |
| 682 base::FilePath output_file( | 682 base::FilePath output_file( |
| 683 command_line.GetSwitchValuePath(switches::kDumpBrowserHistograms)); | 683 command_line.GetSwitchValuePath(switches::kDumpBrowserHistograms)); |
| 684 if (!output_file.empty()) { | 684 if (!output_file.empty()) { |
| 685 base::PostTaskWithTraits( | 685 base::PostTaskWithTraits( |
| 686 FROM_HERE, | 686 FROM_HERE, |
| 687 base::TaskTraits() | 687 base::TaskTraits() |
| 688 .MayBlock() | 688 .MayBlock() |
| 689 .WithPriority(base::TaskPriority::BACKGROUND) | 689 .WithPriority(base::TaskPriority::BACKGROUND) |
| 690 .WithShutdownBehavior(base::TaskShutdownBehavior::BLOCK_SHUTDOWN), | 690 .WithShutdownBehavior(base::TaskShutdownBehavior::BLOCK_SHUTDOWN), |
| 691 base::Bind(&DumpBrowserHistograms, output_file)); | 691 base::BindOnce(&DumpBrowserHistograms, output_file)); |
| 692 } | 692 } |
| 693 silent_launch = true; | 693 silent_launch = true; |
| 694 } | 694 } |
| 695 | 695 |
| 696 // If --no-startup-window is specified and Chrome is already running then do | 696 // If --no-startup-window is specified and Chrome is already running then do |
| 697 // not open a new window. | 697 // not open a new window. |
| 698 if (!process_startup && command_line.HasSwitch(switches::kNoStartupWindow)) | 698 if (!process_startup && command_line.HasSwitch(switches::kNoStartupWindow)) |
| 699 silent_launch = true; | 699 silent_launch = true; |
| 700 | 700 |
| 701 // If we don't want to launch a new browser window or tab we are done here. | 701 // If we don't want to launch a new browser window or tab we are done here. |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 if (!entry->IsSigninRequired()) { | 1020 if (!entry->IsSigninRequired()) { |
| 1021 Profile* profile = profile_manager->GetProfile(entry->GetPath()); | 1021 Profile* profile = profile_manager->GetProfile(entry->GetPath()); |
| 1022 if (profile) | 1022 if (profile) |
| 1023 return profile; | 1023 return profile; |
| 1024 } | 1024 } |
| 1025 } | 1025 } |
| 1026 | 1026 |
| 1027 return nullptr; | 1027 return nullptr; |
| 1028 } | 1028 } |
| 1029 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 1029 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| OLD | NEW |