| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "components/flags_ui/pref_service_flags_storage.h" | 42 #include "components/flags_ui/pref_service_flags_storage.h" |
| 43 #include "components/prefs/pref_service.h" | 43 #include "components/prefs/pref_service.h" |
| 44 #include "components/signin/core/browser/account_reconcilor.h" | 44 #include "components/signin/core/browser/account_reconcilor.h" |
| 45 #include "components/signin/core/browser/account_tracker_service.h" | 45 #include "components/signin/core/browser/account_tracker_service.h" |
| 46 #include "components/signin/core/browser/signin_manager.h" | 46 #include "components/signin/core/browser/signin_manager.h" |
| 47 #include "components/signin/core/common/profile_management_switches.h" | 47 #include "components/signin/core/common/profile_management_switches.h" |
| 48 #include "components/signin/core/common/signin_pref_names.h" | 48 #include "components/signin/core/common/signin_pref_names.h" |
| 49 #include "components/signin/core/common/signin_switches.h" | 49 #include "components/signin/core/common/signin_switches.h" |
| 50 #include "content/public/browser/browser_thread.h" | 50 #include "content/public/browser/browser_thread.h" |
| 51 #include "content/public/browser/user_metrics.h" | 51 #include "content/public/browser/user_metrics.h" |
| 52 #include "extensions/features/features.h" |
| 52 #include "net/base/escape.h" | 53 #include "net/base/escape.h" |
| 53 | 54 |
| 54 #if defined(ENABLE_EXTENSIONS) | 55 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 55 #include "chrome/browser/extensions/extension_service.h" | 56 #include "chrome/browser/extensions/extension_service.h" |
| 56 #include "extensions/browser/extension_prefs.h" | 57 #include "extensions/browser/extension_prefs.h" |
| 57 #include "extensions/browser/extension_registry.h" | 58 #include "extensions/browser/extension_registry.h" |
| 58 #include "extensions/browser/extension_registry_factory.h" | 59 #include "extensions/browser/extension_registry_factory.h" |
| 59 #include "extensions/browser/extension_system.h" | 60 #include "extensions/browser/extension_system.h" |
| 60 #endif // defined(ENABLE_EXTENSIONS) | 61 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 61 | 62 |
| 62 #if !defined(OS_ANDROID) | 63 #if !defined(OS_ANDROID) |
| 63 #include "chrome/browser/ui/browser_finder.h" | 64 #include "chrome/browser/ui/browser_finder.h" |
| 64 #include "chrome/browser/ui/browser_list.h" | 65 #include "chrome/browser/ui/browser_list.h" |
| 65 #include "chrome/browser/ui/browser_list_observer.h" | 66 #include "chrome/browser/ui/browser_list_observer.h" |
| 66 #include "chrome/browser/ui/browser_window.h" | 67 #include "chrome/browser/ui/browser_window.h" |
| 67 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 68 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 68 #endif // !defined (OS_ANDROID) | 69 #endif // !defined (OS_ANDROID) |
| 69 | 70 |
| 70 using base::UserMetricsAction; | 71 using base::UserMetricsAction; |
| 71 using content::BrowserThread; | 72 using content::BrowserThread; |
| 72 | 73 |
| 73 namespace { | 74 namespace { |
| 74 | 75 |
| 75 #if defined(ENABLE_EXTENSIONS) | 76 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 76 void BlockExtensions(Profile* profile) { | 77 void BlockExtensions(Profile* profile) { |
| 77 ExtensionService* extension_service = | 78 ExtensionService* extension_service = |
| 78 extensions::ExtensionSystem::Get(profile)->extension_service(); | 79 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 79 extension_service->BlockAllExtensions(); | 80 extension_service->BlockAllExtensions(); |
| 80 } | 81 } |
| 81 | 82 |
| 82 void UnblockExtensions(Profile* profile) { | 83 void UnblockExtensions(Profile* profile) { |
| 83 ExtensionService* extension_service = | 84 ExtensionService* extension_service = |
| 84 extensions::ExtensionSystem::Get(profile)->extension_service(); | 85 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 85 extension_service->UnblockAllExtensions(); | 86 extension_service->UnblockAllExtensions(); |
| 86 } | 87 } |
| 87 #endif // defined(ENABLE_EXTENSIONS) | 88 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 88 | 89 |
| 89 // Handles running a callback when a new Browser for the given profile | 90 // Handles running a callback when a new Browser for the given profile |
| 90 // has been completely created. | 91 // has been completely created. |
| 91 class BrowserAddedForProfileObserver : public chrome::BrowserListObserver { | 92 class BrowserAddedForProfileObserver : public chrome::BrowserListObserver { |
| 92 public: | 93 public: |
| 93 BrowserAddedForProfileObserver( | 94 BrowserAddedForProfileObserver( |
| 94 Profile* profile, | 95 Profile* profile, |
| 95 ProfileManager::CreateCallback callback) | 96 ProfileManager::CreateCallback callback) |
| 96 : profile_(profile), | 97 : profile_(profile), |
| 97 callback_(callback) { | 98 callback_(callback) { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 chrome::startup::IsProcessStartup is_process_startup = | 242 chrome::startup::IsProcessStartup is_process_startup = |
| 242 chrome::startup::IS_NOT_PROCESS_STARTUP; | 243 chrome::startup::IS_NOT_PROCESS_STARTUP; |
| 243 chrome::startup::IsFirstRun is_first_run = chrome::startup::IS_NOT_FIRST_RUN; | 244 chrome::startup::IsFirstRun is_first_run = chrome::startup::IS_NOT_FIRST_RUN; |
| 244 | 245 |
| 245 // If this is a brand new profile, then start a first run window. | 246 // If this is a brand new profile, then start a first run window. |
| 246 if (is_new_profile) { | 247 if (is_new_profile) { |
| 247 is_process_startup = chrome::startup::IS_PROCESS_STARTUP; | 248 is_process_startup = chrome::startup::IS_PROCESS_STARTUP; |
| 248 is_first_run = chrome::startup::IS_FIRST_RUN; | 249 is_first_run = chrome::startup::IS_FIRST_RUN; |
| 249 } | 250 } |
| 250 | 251 |
| 251 #if defined(ENABLE_EXTENSIONS) | 252 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 252 // The signin bit will still be set if the profile is being unlocked and the | 253 // The signin bit will still be set if the profile is being unlocked and the |
| 253 // browser window for it is opening. As part of this unlock process, unblock | 254 // browser window for it is opening. As part of this unlock process, unblock |
| 254 // all the extensions. | 255 // all the extensions. |
| 255 if (!profile->IsGuestSession()) { | 256 if (!profile->IsGuestSession()) { |
| 256 ProfileAttributesEntry* entry; | 257 ProfileAttributesEntry* entry; |
| 257 if (g_browser_process->profile_manager()->GetProfileAttributesStorage(). | 258 if (g_browser_process->profile_manager()->GetProfileAttributesStorage(). |
| 258 GetProfileAttributesWithPath(profile->GetPath(), &entry) && | 259 GetProfileAttributesWithPath(profile->GetPath(), &entry) && |
| 259 entry->IsSigninRequired()) { | 260 entry->IsSigninRequired()) { |
| 260 UnblockExtensions(profile); | 261 UnblockExtensions(profile); |
| 261 } | 262 } |
| 262 } | 263 } |
| 263 #endif // defined(ENABLE_EXTENSIONS) | 264 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 264 | 265 |
| 265 // If |always_create| is false, and we have a |callback| to run, check | 266 // If |always_create| is false, and we have a |callback| to run, check |
| 266 // whether a browser already exists so that we can run the callback. We don't | 267 // whether a browser already exists so that we can run the callback. We don't |
| 267 // want to rely on the observer listening to OnBrowserSetLastActive in this | 268 // want to rely on the observer listening to OnBrowserSetLastActive in this |
| 268 // case, as you could manually activate an incorrect browser and trigger | 269 // case, as you could manually activate an incorrect browser and trigger |
| 269 // a false positive. | 270 // a false positive. |
| 270 if (!always_create) { | 271 if (!always_create) { |
| 271 Browser* browser = chrome::FindTabbedBrowser(profile, false); | 272 Browser* browser = chrome::FindTabbedBrowser(profile, false); |
| 272 if (browser) { | 273 if (browser) { |
| 273 browser->window()->Activate(); | 274 browser->window()->Activate(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 } | 378 } |
| 378 | 379 |
| 379 void LockBrowserCloseSuccess(const base::FilePath& profile_path) { | 380 void LockBrowserCloseSuccess(const base::FilePath& profile_path) { |
| 380 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 381 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 381 ProfileAttributesEntry* entry; | 382 ProfileAttributesEntry* entry; |
| 382 bool has_entry = profile_manager->GetProfileAttributesStorage(). | 383 bool has_entry = profile_manager->GetProfileAttributesStorage(). |
| 383 GetProfileAttributesWithPath(profile_path, &entry); | 384 GetProfileAttributesWithPath(profile_path, &entry); |
| 384 DCHECK(has_entry); | 385 DCHECK(has_entry); |
| 385 entry->SetIsSigninRequired(true); | 386 entry->SetIsSigninRequired(true); |
| 386 | 387 |
| 387 #if defined(ENABLE_EXTENSIONS) | 388 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 388 // Profile guaranteed to exist for it to have been locked. | 389 // Profile guaranteed to exist for it to have been locked. |
| 389 BlockExtensions(profile_manager->GetProfileByPath(profile_path)); | 390 BlockExtensions(profile_manager->GetProfileByPath(profile_path)); |
| 390 #endif // defined(ENABLE_EXTENSIONS) | 391 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 391 | 392 |
| 392 chrome::HideTaskManager(); | 393 chrome::HideTaskManager(); |
| 393 UserManager::Show(profile_path, | 394 UserManager::Show(profile_path, |
| 394 profiles::USER_MANAGER_NO_TUTORIAL, | 395 profiles::USER_MANAGER_NO_TUTORIAL, |
| 395 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 396 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 396 } | 397 } |
| 397 | 398 |
| 398 void LockProfile(Profile* profile) { | 399 void LockProfile(Profile* profile) { |
| 399 DCHECK(profile); | 400 DCHECK(profile); |
| 400 if (profile) { | 401 if (profile) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 PrefService* local_state = g_browser_process->local_state(); | 531 PrefService* local_state = g_browser_process->local_state(); |
| 531 const bool dismissed = local_state->GetBoolean( | 532 const bool dismissed = local_state->GetBoolean( |
| 532 prefs::kProfileAvatarRightClickTutorialDismissed); | 533 prefs::kProfileAvatarRightClickTutorialDismissed); |
| 533 | 534 |
| 534 // Don't show the tutorial if it's already been dismissed or if right-clicking | 535 // Don't show the tutorial if it's already been dismissed or if right-clicking |
| 535 // wouldn't show any targets. | 536 // wouldn't show any targets. |
| 536 return !dismissed && HasProfileSwitchTargets(profile); | 537 return !dismissed && HasProfileSwitchTargets(profile); |
| 537 } | 538 } |
| 538 | 539 |
| 539 } // namespace profiles | 540 } // namespace profiles |
| OLD | NEW |