OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profiles/profile_window.h" | 5 #include "chrome/browser/profiles/profile_window.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "content/public/browser/user_metrics.h" | 37 #include "content/public/browser/user_metrics.h" |
38 | 38 |
39 #if defined(ENABLE_EXTENSIONS) | 39 #if defined(ENABLE_EXTENSIONS) |
40 #include "chrome/browser/extensions/extension_service.h" | 40 #include "chrome/browser/extensions/extension_service.h" |
41 #include "extensions/browser/extension_prefs.h" | 41 #include "extensions/browser/extension_prefs.h" |
42 #include "extensions/browser/extension_registry.h" | 42 #include "extensions/browser/extension_registry.h" |
43 #include "extensions/browser/extension_registry_factory.h" | 43 #include "extensions/browser/extension_registry_factory.h" |
44 #include "extensions/browser/extension_system.h" | 44 #include "extensions/browser/extension_system.h" |
45 #endif // defined(ENABLE_EXTENSIONS) | 45 #endif // defined(ENABLE_EXTENSIONS) |
46 | 46 |
47 #if !defined(OS_IOS) | 47 #if !defined(OS_ANDROID) |
48 #include "chrome/browser/ui/browser_finder.h" | 48 #include "chrome/browser/ui/browser_finder.h" |
49 #include "chrome/browser/ui/browser_list.h" | 49 #include "chrome/browser/ui/browser_list.h" |
50 #include "chrome/browser/ui/browser_list_observer.h" | 50 #include "chrome/browser/ui/browser_list_observer.h" |
51 #include "chrome/browser/ui/browser_window.h" | 51 #include "chrome/browser/ui/browser_window.h" |
52 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 52 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
53 #endif // !defined (OS_IOS) | 53 #endif // !defined (OS_ANDROID) |
54 | 54 |
55 using base::UserMetricsAction; | 55 using base::UserMetricsAction; |
56 using content::BrowserThread; | 56 using content::BrowserThread; |
57 | 57 |
58 namespace { | 58 namespace { |
59 | 59 |
60 const char kNewProfileManagementExperimentInternalName[] = | 60 const char kNewProfileManagementExperimentInternalName[] = |
61 "enable-new-profile-management"; | 61 "enable-new-profile-management"; |
62 | 62 |
63 #if defined(ENABLE_EXTENSIONS) | 63 #if defined(ENABLE_EXTENSIONS) |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } | 255 } |
256 return base::FilePath(); | 256 return base::FilePath(); |
257 } | 257 } |
258 | 258 |
259 void FindOrCreateNewWindowForProfile( | 259 void FindOrCreateNewWindowForProfile( |
260 Profile* profile, | 260 Profile* profile, |
261 chrome::startup::IsProcessStartup process_startup, | 261 chrome::startup::IsProcessStartup process_startup, |
262 chrome::startup::IsFirstRun is_first_run, | 262 chrome::startup::IsFirstRun is_first_run, |
263 chrome::HostDesktopType desktop_type, | 263 chrome::HostDesktopType desktop_type, |
264 bool always_create) { | 264 bool always_create) { |
265 #if defined(OS_IOS) | |
266 NOTREACHED(); | |
267 #else | |
268 DCHECK(profile); | 265 DCHECK(profile); |
269 | 266 |
270 if (!always_create) { | 267 if (!always_create) { |
271 Browser* browser = chrome::FindTabbedBrowser(profile, false, desktop_type); | 268 Browser* browser = chrome::FindTabbedBrowser(profile, false, desktop_type); |
272 if (browser) { | 269 if (browser) { |
273 browser->window()->Activate(); | 270 browser->window()->Activate(); |
274 return; | 271 return; |
275 } | 272 } |
276 } | 273 } |
277 | 274 |
278 content::RecordAction(UserMetricsAction("NewWindow")); | 275 content::RecordAction(UserMetricsAction("NewWindow")); |
279 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 276 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
280 StartupBrowserCreator browser_creator; | 277 StartupBrowserCreator browser_creator; |
281 browser_creator.LaunchBrowser( | 278 browser_creator.LaunchBrowser( |
282 command_line, profile, base::FilePath(), process_startup, is_first_run); | 279 command_line, profile, base::FilePath(), process_startup, is_first_run); |
283 #endif // defined(OS_IOS) | |
284 } | 280 } |
285 | 281 |
| 282 #if !defined(OS_ANDROID) |
286 void SwitchToProfile(const base::FilePath& path, | 283 void SwitchToProfile(const base::FilePath& path, |
287 chrome::HostDesktopType desktop_type, | 284 chrome::HostDesktopType desktop_type, |
288 bool always_create, | 285 bool always_create, |
289 ProfileManager::CreateCallback callback, | 286 ProfileManager::CreateCallback callback, |
290 ProfileMetrics::ProfileOpen metric) { | 287 ProfileMetrics::ProfileOpen metric) { |
291 ProfileMetrics::LogProfileSwitch(metric, | 288 ProfileMetrics::LogProfileSwitch(metric, |
292 g_browser_process->profile_manager(), | 289 g_browser_process->profile_manager(), |
293 path); | 290 path); |
294 g_browser_process->profile_manager()->CreateProfileAsync( | 291 g_browser_process->profile_manager()->CreateProfileAsync( |
295 path, | 292 path, |
(...skipping 17 matching lines...) Expand all Loading... |
313 path, | 310 path, |
314 base::Bind(&OpenBrowserWindowForProfile, | 311 base::Bind(&OpenBrowserWindowForProfile, |
315 callback, | 312 callback, |
316 false, | 313 false, |
317 false, | 314 false, |
318 desktop_type), | 315 desktop_type), |
319 base::string16(), | 316 base::string16(), |
320 base::string16(), | 317 base::string16(), |
321 std::string()); | 318 std::string()); |
322 } | 319 } |
| 320 #endif |
323 | 321 |
324 bool HasProfileSwitchTargets(Profile* profile) { | 322 bool HasProfileSwitchTargets(Profile* profile) { |
325 size_t min_profiles = profile->IsGuestSession() ? 1 : 2; | 323 size_t min_profiles = profile->IsGuestSession() ? 1 : 2; |
326 size_t number_of_profiles = | 324 size_t number_of_profiles = |
327 g_browser_process->profile_manager()->GetNumberOfProfiles(); | 325 g_browser_process->profile_manager()->GetNumberOfProfiles(); |
328 return number_of_profiles >= min_profiles; | 326 return number_of_profiles >= min_profiles; |
329 } | 327 } |
330 | 328 |
331 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type, | 329 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type, |
332 ProfileManager::CreateCallback callback, | 330 ProfileManager::CreateCallback callback, |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 PrefService* local_state = g_browser_process->local_state(); | 552 PrefService* local_state = g_browser_process->local_state(); |
555 const bool dismissed = local_state->GetBoolean( | 553 const bool dismissed = local_state->GetBoolean( |
556 prefs::kProfileAvatarRightClickTutorialDismissed); | 554 prefs::kProfileAvatarRightClickTutorialDismissed); |
557 | 555 |
558 // Don't show the tutorial if it's already been dismissed or if right-clicking | 556 // Don't show the tutorial if it's already been dismissed or if right-clicking |
559 // wouldn't show any targets. | 557 // wouldn't show any targets. |
560 return !dismissed && HasProfileSwitchTargets(profile); | 558 return !dismissed && HasProfileSwitchTargets(profile); |
561 } | 559 } |
562 | 560 |
563 } // namespace profiles | 561 } // namespace profiles |
OLD | NEW |