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 <algorithm> // For max(). | 7 #include <algorithm> // For max(). |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "apps/app_load_service.h" | 10 #include "apps/app_load_service.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 bool HasBeenLaunched(const Profile* profile) const { | 149 bool HasBeenLaunched(const Profile* profile) const { |
150 return launched_profiles_.find(profile) != launched_profiles_.end(); | 150 return launched_profiles_.find(profile) != launched_profiles_.end(); |
151 } | 151 } |
152 | 152 |
153 void AddLaunched(Profile* profile) { | 153 void AddLaunched(Profile* profile) { |
154 launched_profiles_.insert(profile); | 154 launched_profiles_.insert(profile); |
155 // Since the startup code only executes for browsers launched in | 155 // Since the startup code only executes for browsers launched in |
156 // desktop mode, i.e., HOST_DESKTOP_TYPE_NATIVE. Ash should never get here. | 156 // desktop mode, i.e., ui::HOST_DESKTOP_TYPE_NATIVE. Ash should never get |
157 if (chrome::FindBrowserWithProfile(profile, | 157 // here. |
158 chrome::HOST_DESKTOP_TYPE_NATIVE)) { | 158 if (chrome::FindBrowserWithProfile(profile, ui::HOST_DESKTOP_TYPE_NATIVE)) { |
159 // A browser may get opened before we get initialized (e.g., in tests), | 159 // A browser may get opened before we get initialized (e.g., in tests), |
160 // so we never see the NOTIFICATION_BROWSER_WINDOW_READY for it. | 160 // so we never see the NOTIFICATION_BROWSER_WINDOW_READY for it. |
161 opened_profiles_.insert(profile); | 161 opened_profiles_.insert(profile); |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 void Clear() { | 165 void Clear() { |
166 launched_profiles_.clear(); | 166 launched_profiles_.clear(); |
167 opened_profiles_.clear(); | 167 opened_profiles_.clear(); |
168 } | 168 } |
(...skipping 27 matching lines...) Expand all Loading... |
196 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 196 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
197 content::NotificationService::AllSources()); | 197 content::NotificationService::AllSources()); |
198 registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 198 registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
199 content::NotificationService::AllSources()); | 199 content::NotificationService::AllSources()); |
200 } | 200 } |
201 | 201 |
202 void ActivateProfile() { | 202 void ActivateProfile() { |
203 // We need to test again, in case the profile got deleted in the mean time. | 203 // We need to test again, in case the profile got deleted in the mean time. |
204 if (profile_to_activate_) { | 204 if (profile_to_activate_) { |
205 Browser* browser = chrome::FindBrowserWithProfile( | 205 Browser* browser = chrome::FindBrowserWithProfile( |
206 profile_to_activate_, chrome::HOST_DESKTOP_TYPE_NATIVE); | 206 profile_to_activate_, ui::HOST_DESKTOP_TYPE_NATIVE); |
207 // |profile| may never get launched, e.g., if it only had | 207 // |profile| may never get launched, e.g., if it only had |
208 // incognito Windows and one of them was used to exit Chrome. | 208 // incognito Windows and one of them was used to exit Chrome. |
209 // So it won't have a browser in that case. | 209 // So it won't have a browser in that case. |
210 if (browser) | 210 if (browser) |
211 browser->window()->Activate(); | 211 browser->window()->Activate(); |
212 // No need try to activate this profile again. | 212 // No need try to activate this profile again. |
213 profile_to_activate_ = NULL; | 213 profile_to_activate_ = NULL; |
214 } | 214 } |
215 // Assign true here, even if no browser was actually activated, so that | 215 // Assign true here, even if no browser was actually activated, so that |
216 // the test can stop waiting, and fail gracefully when needed. | 216 // the test can stop waiting, and fail gracefully when needed. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 // Note: This check should have been done in ProcessCmdLineImpl() | 313 // Note: This check should have been done in ProcessCmdLineImpl() |
314 // before calling this function. However chromeos/login/login_utils.cc | 314 // before calling this function. However chromeos/login/login_utils.cc |
315 // calls this function directly (see comments there) so it has to be checked | 315 // calls this function directly (see comments there) so it has to be checked |
316 // again. | 316 // again. |
317 const bool silent_launch = command_line.HasSwitch(switches::kSilentLaunch); | 317 const bool silent_launch = command_line.HasSwitch(switches::kSilentLaunch); |
318 | 318 |
319 if (!silent_launch) { | 319 if (!silent_launch) { |
320 StartupBrowserCreatorImpl lwp(cur_dir, command_line, this, is_first_run); | 320 StartupBrowserCreatorImpl lwp(cur_dir, command_line, this, is_first_run); |
321 const std::vector<GURL> urls_to_launch = | 321 const std::vector<GURL> urls_to_launch = |
322 GetURLsFromCommandLine(command_line, cur_dir, profile); | 322 GetURLsFromCommandLine(command_line, cur_dir, profile); |
323 chrome::HostDesktopType host_desktop_type = | 323 ui::HostDesktopType host_desktop_type = ui::HOST_DESKTOP_TYPE_NATIVE; |
324 chrome::HOST_DESKTOP_TYPE_NATIVE; | |
325 | 324 |
326 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | 325 #if defined(USE_ASH) && !defined(OS_CHROMEOS) |
327 // We want to maintain only one type of instance for now, either ASH | 326 // We want to maintain only one type of instance for now, either ASH |
328 // or desktop. | 327 // or desktop. |
329 // TODO(shrikant): Remove this code once we decide on running both desktop | 328 // TODO(shrikant): Remove this code once we decide on running both desktop |
330 // and ASH instances side by side. | 329 // and ASH instances side by side. |
331 if (ash::Shell::HasInstance()) | 330 if (ash::Shell::HasInstance()) |
332 host_desktop_type = chrome::HOST_DESKTOP_TYPE_ASH; | 331 host_desktop_type = ui::HOST_DESKTOP_TYPE_ASH; |
333 #endif | 332 #endif |
334 | 333 |
335 const bool launched = lwp.Launch(profile, urls_to_launch, | 334 const bool launched = lwp.Launch(profile, urls_to_launch, |
336 in_synchronous_profile_launch_, | 335 in_synchronous_profile_launch_, |
337 host_desktop_type); | 336 host_desktop_type); |
338 in_synchronous_profile_launch_ = false; | 337 in_synchronous_profile_launch_ = false; |
339 if (!launched) { | 338 if (!launched) { |
340 LOG(ERROR) << "launch error"; | 339 LOG(ERROR) << "launch error"; |
341 return false; | 340 return false; |
342 } | 341 } |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 base::FilePath GetStartupProfilePath(const base::FilePath& user_data_dir, | 834 base::FilePath GetStartupProfilePath(const base::FilePath& user_data_dir, |
836 const base::CommandLine& command_line) { | 835 const base::CommandLine& command_line) { |
837 if (command_line.HasSwitch(switches::kProfileDirectory)) { | 836 if (command_line.HasSwitch(switches::kProfileDirectory)) { |
838 return user_data_dir.Append( | 837 return user_data_dir.Append( |
839 command_line.GetSwitchValuePath(switches::kProfileDirectory)); | 838 command_line.GetSwitchValuePath(switches::kProfileDirectory)); |
840 } | 839 } |
841 | 840 |
842 // If we are showing the app list then chrome isn't shown so load the app | 841 // If we are showing the app list then chrome isn't shown so load the app |
843 // list's profile rather than chrome's. | 842 // list's profile rather than chrome's. |
844 if (command_line.HasSwitch(switches::kShowAppList)) { | 843 if (command_line.HasSwitch(switches::kShowAppList)) { |
845 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> | 844 return AppListService::Get(ui::HOST_DESKTOP_TYPE_NATIVE) |
846 GetProfilePath(user_data_dir); | 845 ->GetProfilePath(user_data_dir); |
847 } | 846 } |
848 | 847 |
849 return g_browser_process->profile_manager()->GetLastUsedProfileDir( | 848 return g_browser_process->profile_manager()->GetLastUsedProfileDir( |
850 user_data_dir); | 849 user_data_dir); |
851 } | 850 } |
OLD | NEW |