Commit a312cec5 authored by mlerman's avatar mlerman Committed by Commit bot

Loading the Launcher with a Locked Profile launched UserManager.

On Mac, the --show-app-list flag causes the AppLauncher to start loading before the Profile is loaded. For this, the profile_path is sent to AppListService::InitAll(), so that this load can be aborted if it would point to a Locked Profile.

The AppListService will no longer permit loading a locked profile, and will direct to the UserManager instead. StartupBrowserCreator has a similar flow.

BUG=421308
TEST=Try to load the App Launcher for a locked profile in any possible way the Launcher can be launched ;) It should always direct to the UserManager, upon Profile Selection which then directs to the AppLauncher. Opening the AppLauncher for a non-locked profile should always work smoothly.

Review URL: https://codereview.chromium.org/856733004

Cr-Commit-Position: refs/heads/master@{#313583}
parent 8624637f
...@@ -87,6 +87,9 @@ class ChromeBrowserMainParts : public content::BrowserMainParts { ...@@ -87,6 +87,9 @@ class ChromeBrowserMainParts : public content::BrowserMainParts {
const base::CommandLine& parsed_command_line() const { const base::CommandLine& parsed_command_line() const {
return parsed_command_line_; return parsed_command_line_;
} }
const base::FilePath& user_data_dir() const {
return user_data_dir_;
}
Profile* profile() { return profile_; } Profile* profile() { return profile_; }
......
...@@ -273,10 +273,12 @@ void ChromeBrowserMainPartsMac::PreProfileInit() { ...@@ -273,10 +273,12 @@ void ChromeBrowserMainPartsMac::PreProfileInit() {
MacStartupProfiler::GetInstance()->Profile( MacStartupProfiler::GetInstance()->Profile(
MacStartupProfiler::PRE_PROFILE_INIT); MacStartupProfiler::PRE_PROFILE_INIT);
ChromeBrowserMainPartsPosix::PreProfileInit(); ChromeBrowserMainPartsPosix::PreProfileInit();
// This is called here so that the app shim socket is only created after // This is called here so that the app shim socket is only created after
// taking the singleton lock. // taking the singleton lock.
g_browser_process->platform_part()->app_shim_host_manager()->Init(); g_browser_process->platform_part()->app_shim_host_manager()->Init();
AppListService::InitAll(NULL); AppListService::InitAll(NULL,
GetStartupProfilePath(user_data_dir(), parsed_command_line()));
} }
void ChromeBrowserMainPartsMac::PostProfileInit() { void ChromeBrowserMainPartsMac::PostProfileInit() {
......
...@@ -213,6 +213,9 @@ void OnUserManagerSystemProfileCreated( ...@@ -213,6 +213,9 @@ void OnUserManagerSystemProfileCreated(
} else if (profile_open_action == } else if (profile_open_action ==
profiles::USER_MANAGER_SELECT_PROFILE_CHROME_MEMORY) { profiles::USER_MANAGER_SELECT_PROFILE_CHROME_MEMORY) {
page += profiles::kUserManagerSelectProfileChromeMemory; page += profiles::kUserManagerSelectProfileChromeMemory;
} else if (profile_open_action ==
profiles::USER_MANAGER_SELECT_PROFILE_APP_LAUNCHER) {
page += profiles::kUserManagerSelectProfileAppLauncher;
} }
callback.Run(system_profile, page); callback.Run(system_profile, page);
} }
...@@ -236,6 +239,7 @@ const char kUserManagerSelectProfileTaskManager[] = "#task-manager"; ...@@ -236,6 +239,7 @@ const char kUserManagerSelectProfileTaskManager[] = "#task-manager";
const char kUserManagerSelectProfileAboutChrome[] = "#about-chrome"; const char kUserManagerSelectProfileAboutChrome[] = "#about-chrome";
const char kUserManagerSelectProfileChromeSettings[] = "#chrome-settings"; const char kUserManagerSelectProfileChromeSettings[] = "#chrome-settings";
const char kUserManagerSelectProfileChromeMemory[] = "#chrome-memory"; const char kUserManagerSelectProfileChromeMemory[] = "#chrome-memory";
const char kUserManagerSelectProfileAppLauncher[] = "#app-launcher";
void FindOrCreateNewWindowForProfile( void FindOrCreateNewWindowForProfile(
Profile* profile, Profile* profile,
......
...@@ -32,6 +32,7 @@ enum UserManagerProfileSelected { ...@@ -32,6 +32,7 @@ enum UserManagerProfileSelected {
USER_MANAGER_SELECT_PROFILE_ABOUT_CHROME, USER_MANAGER_SELECT_PROFILE_ABOUT_CHROME,
USER_MANAGER_SELECT_PROFILE_CHROME_SETTINGS, USER_MANAGER_SELECT_PROFILE_CHROME_SETTINGS,
USER_MANAGER_SELECT_PROFILE_CHROME_MEMORY, USER_MANAGER_SELECT_PROFILE_CHROME_MEMORY,
USER_MANAGER_SELECT_PROFILE_APP_LAUNCHER,
}; };
extern const char kUserManagerDisplayTutorial[]; extern const char kUserManagerDisplayTutorial[];
...@@ -39,6 +40,7 @@ extern const char kUserManagerSelectProfileTaskManager[]; ...@@ -39,6 +40,7 @@ extern const char kUserManagerSelectProfileTaskManager[];
extern const char kUserManagerSelectProfileAboutChrome[]; extern const char kUserManagerSelectProfileAboutChrome[];
extern const char kUserManagerSelectProfileChromeSettings[]; extern const char kUserManagerSelectProfileChromeSettings[];
extern const char kUserManagerSelectProfileChromeMemory[]; extern const char kUserManagerSelectProfileChromeMemory[];
extern const char kUserManagerSelectProfileAppLauncher[];
// Activates a window for |profile| on the desktop specified by // Activates a window for |profile| on the desktop specified by
// |desktop_type|. If no such window yet exists, or if |always_create| is // |desktop_type|. If no such window yet exists, or if |always_create| is
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/process/process_info.h" #include "base/process/process_info.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
...@@ -160,7 +161,7 @@ void AppListService::RegisterPrefs(PrefRegistrySimple* registry) { ...@@ -160,7 +161,7 @@ void AppListService::RegisterPrefs(PrefRegistrySimple* registry) {
bool AppListService::HandleLaunchCommandLine( bool AppListService::HandleLaunchCommandLine(
const base::CommandLine& command_line, const base::CommandLine& command_line,
Profile* launch_profile) { Profile* launch_profile) {
InitAll(launch_profile); InitAll(launch_profile, launch_profile->GetPath());
if (!command_line.HasSwitch(switches::kShowAppList)) if (!command_line.HasSwitch(switches::kShowAppList))
return false; return false;
......
...@@ -54,7 +54,8 @@ class AppListService { ...@@ -54,7 +54,8 @@ class AppListService {
static AppListService* Get(chrome::HostDesktopType desktop_type); static AppListService* Get(chrome::HostDesktopType desktop_type);
// Call Init for all AppListService instances on this platform. // Call Init for all AppListService instances on this platform.
static void InitAll(Profile* initial_profile); static void InitAll(Profile* initial_profile,
const base::FilePath& profile_path);
static void RegisterPrefs(PrefRegistrySimple* registry); static void RegisterPrefs(PrefRegistrySimple* registry);
......
...@@ -62,7 +62,8 @@ AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) { ...@@ -62,7 +62,8 @@ AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) {
} }
// static // static
void AppListService::InitAll(Profile* initial_profile) {} void AppListService::InitAll(Profile* initial_profile,
const base::FilePath& profile_path) {}
// static // static
void AppListService::RegisterPrefs(PrefRegistrySimple* registry) {} void AppListService::RegisterPrefs(PrefRegistrySimple* registry) {}
......
...@@ -123,6 +123,7 @@ class ProfileStoreImpl : public ProfileStore { ...@@ -123,6 +123,7 @@ class ProfileStoreImpl : public ProfileStore {
} }
Profile* GetProfileByPath(const base::FilePath& path) override { Profile* GetProfileByPath(const base::FilePath& path) override {
DCHECK(!IsProfileLocked(path));
return profile_manager_->GetProfileByPath(path); return profile_manager_->GetProfileByPath(path);
} }
...@@ -138,6 +139,14 @@ class ProfileStoreImpl : public ProfileStore { ...@@ -138,6 +139,14 @@ class ProfileStoreImpl : public ProfileStore {
profile_info.ProfileIsSupervisedAtIndex(profile_index); profile_info.ProfileIsSupervisedAtIndex(profile_index);
} }
bool IsProfileLocked(const base::FilePath& profile_path) override {
ProfileInfoCache& profile_info =
g_browser_process->profile_manager()->GetProfileInfoCache();
size_t profile_index = profile_info.GetIndexOfProfileWithPath(profile_path);
return profile_index != std::string::npos &&
profile_info.ProfileIsSigninRequiredAtIndex(profile_index);
}
private: private:
ProfileManager* profile_manager_; ProfileManager* profile_manager_;
base::WeakPtrFactory<ProfileStoreImpl> weak_factory_; base::WeakPtrFactory<ProfileStoreImpl> weak_factory_;
......
...@@ -12,17 +12,21 @@ ...@@ -12,17 +12,21 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/app_list/app_list_controller_delegate.h" #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
#include "chrome/browser/ui/app_list/test/chrome_app_list_test_support.h" #include "chrome/browser/ui/app_list/test/chrome_app_list_test_support.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h" #include "chrome/browser/ui/startup/startup_browser_creator.h"
#include "chrome/browser/ui/user_manager.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "ui/app_list/app_list_model.h" #include "ui/app_list/app_list_model.h"
#include "ui/app_list/search_box_model.h" #include "ui/app_list/search_box_model.h"
...@@ -39,6 +43,9 @@ class AppListServiceInteractiveTest : public InProcessBrowserTest { ...@@ -39,6 +43,9 @@ class AppListServiceInteractiveTest : public InProcessBrowserTest {
protected: protected:
Profile* profile2_; Profile* profile2_;
ProfileInfoCache* profile_info_cache() {
return &(g_browser_process->profile_manager()->GetProfileInfoCache());
}
private: private:
DISALLOW_COPY_AND_ASSIGN(AppListServiceInteractiveTest); DISALLOW_COPY_AND_ASSIGN(AppListServiceInteractiveTest);
...@@ -49,6 +56,7 @@ class AppListServiceInteractiveTest : public InProcessBrowserTest { ...@@ -49,6 +56,7 @@ class AppListServiceInteractiveTest : public InProcessBrowserTest {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#define MAYBE_ShowAndDismiss DISABLED_ShowAndDismiss #define MAYBE_ShowAndDismiss DISABLED_ShowAndDismiss
#define MAYBE_SwitchAppListProfiles DISABLED_SwitchAppListProfiles #define MAYBE_SwitchAppListProfiles DISABLED_SwitchAppListProfiles
#define MAYBE_SwitchAppListLockedProfile DISABLED_SwitchAppListLockedProfile
#define MAYBE_SwitchAppListProfilesDuringSearch \ #define MAYBE_SwitchAppListProfilesDuringSearch \
DISABLED_SwitchAppListProfilesDuringSearch DISABLED_SwitchAppListProfilesDuringSearch
#define MAYBE_ShowAppListNonDefaultProfile \ #define MAYBE_ShowAppListNonDefaultProfile \
...@@ -57,6 +65,7 @@ class AppListServiceInteractiveTest : public InProcessBrowserTest { ...@@ -57,6 +65,7 @@ class AppListServiceInteractiveTest : public InProcessBrowserTest {
#else #else
#define MAYBE_ShowAndDismiss ShowAndDismiss #define MAYBE_ShowAndDismiss ShowAndDismiss
#define MAYBE_SwitchAppListProfiles SwitchAppListProfiles #define MAYBE_SwitchAppListProfiles SwitchAppListProfiles
#define MAYBE_SwitchAppListLockedProfile SwitchAppListLockedProfile
#define MAYBE_SwitchAppListProfilesDuringSearch \ #define MAYBE_SwitchAppListProfilesDuringSearch \
SwitchAppListProfilesDuringSearch SwitchAppListProfilesDuringSearch
#define MAYBE_ShowAppListNonDefaultProfile ShowAppListNonDefaultProfile #define MAYBE_ShowAppListNonDefaultProfile ShowAppListNonDefaultProfile
...@@ -107,6 +116,63 @@ IN_PROC_BROWSER_TEST_F(AppListServiceInteractiveTest, ...@@ -107,6 +116,63 @@ IN_PROC_BROWSER_TEST_F(AppListServiceInteractiveTest,
controller->DismissView(); controller->DismissView();
} }
// Switch profiles on the app list while it is showing.
IN_PROC_BROWSER_TEST_F(AppListServiceInteractiveTest,
MAYBE_SwitchAppListLockedProfile) {
InitSecondProfile();
AppListService* service = test::GetAppListService();
ASSERT_TRUE(service);
AppListControllerDelegate* controller(service->GetControllerDelegate());
ASSERT_TRUE(controller);
// Open the app list with the browser's profile.
EXPECT_FALSE(service->IsAppListVisible());
controller->ShowForProfileByPath(browser()->profile()->GetPath());
app_list::AppListModel* model = test::GetAppListModel(service);
ASSERT_TRUE(model);
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(service->IsAppListVisible());
EXPECT_EQ(browser()->profile(), service->GetCurrentAppListProfile());
EXPECT_FALSE(UserManager::IsShowing());
// App list, go away, come against some other day.
service->DismissAppList();
ASSERT_FALSE(service->IsAppListVisible());
// If the System Profile is not loaded here then it will be created
// asycnhronously by the User Maanger. Forcing the Profile* to be created here
// ensure it is accessed synchronously later.
g_browser_process->profile_manager()->GetProfile(
ProfileManager::GetSystemProfilePath());
// Lock the second profile.
profile_info_cache()->SetProfileSigninRequiredAtIndex(
profile_info_cache()->GetIndexOfProfileWithPath(profile2_->GetPath()),
true);
// Attempt to open the app list with the second profile.
controller->ShowForProfileByPath(profile2_->GetPath());
// Model isn't affected by the failed attempt to show the other profile.
model = test::GetAppListModel(service);
ASSERT_TRUE(model);
// Ensure the app list is still in a valid state, using the original profile.
EXPECT_TRUE(service->GetCurrentAppListProfile());
EXPECT_EQ(browser()->profile(), service->GetCurrentAppListProfile());
base::RunLoop().RunUntilIdle();
// App list stays hidden; the UserManager shows instead.
EXPECT_FALSE(service->IsAppListVisible());
EXPECT_TRUE(UserManager::IsShowing());
controller->DismissView();
// We need to hide the User Manager or else the process can't die.
UserManager::Hide();
}
// Test switching app list profiles while search results are visibile. // Test switching app list profiles while search results are visibile.
IN_PROC_BROWSER_TEST_F(AppListServiceInteractiveTest, IN_PROC_BROWSER_TEST_F(AppListServiceInteractiveTest,
MAYBE_SwitchAppListProfilesDuringSearch) { MAYBE_SwitchAppListProfilesDuringSearch) {
......
...@@ -54,6 +54,8 @@ class AppListServiceMac : public AppListServiceImpl, ...@@ -54,6 +54,8 @@ class AppListServiceMac : public AppListServiceImpl,
void ShowWindowNearDock(); void ShowWindowNearDock();
void WindowAnimationDidEnd(); void WindowAnimationDidEnd();
void InitWithProfilePath(Profile* initial_profile,
const base::FilePath& profile_path);
// AppListService overrides: // AppListService overrides:
void Init(Profile* initial_profile) override; void Init(Profile* initial_profile) override;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#import "chrome/browser/app_controller_mac.h" #import "chrome/browser/app_controller_mac.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/app_list/app_list_controller_delegate_impl.h" #include "chrome/browser/ui/app_list/app_list_controller_delegate_impl.h"
#include "chrome/browser/ui/app_list/app_list_positioner.h" #include "chrome/browser/ui/app_list/app_list_positioner.h"
...@@ -337,6 +338,12 @@ void AppListServiceMac::FindAnchorPoint(const gfx::Size& window_size, ...@@ -337,6 +338,12 @@ void AppListServiceMac::FindAnchorPoint(const gfx::Size& window_size,
} }
void AppListServiceMac::Init(Profile* initial_profile) { void AppListServiceMac::Init(Profile* initial_profile) {
InitWithProfilePath(initial_profile, initial_profile->GetPath());
}
void AppListServiceMac::InitWithProfilePath(
Profile* initial_profile,
const base::FilePath& profile_path) {
// On Mac, Init() is called multiple times for a process: any time there is no // On Mac, Init() is called multiple times for a process: any time there is no
// browser window open and a new window is opened, and during process startup // browser window open and a new window is opened, and during process startup
// to handle the silent launch case (e.g. for app shims). In the startup case, // to handle the silent launch case (e.g. for app shims). In the startup case,
...@@ -371,8 +378,17 @@ void AppListServiceMac::Init(Profile* initial_profile) { ...@@ -371,8 +378,17 @@ void AppListServiceMac::Init(Profile* initial_profile) {
// OnShimLaunch(). Note that if --silent-launch is not also passed, the window // OnShimLaunch(). Note that if --silent-launch is not also passed, the window
// will instead populate via StartupBrowserCreator::Launch(). Shim-initiated // will instead populate via StartupBrowserCreator::Launch(). Shim-initiated
// launches will always have --silent-launch. // launches will always have --silent-launch.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowAppList)) if (base::CommandLine::ForCurrentProcess()->
ShowWindowNearDock(); HasSwitch(switches::kShowAppList)) {
// Do not show the launcher window when the profile is locked.
const ProfileInfoCache& profile_info_cache =
g_browser_process->profile_manager()->GetProfileInfoCache();
size_t profile_index = profile_info_cache.
GetIndexOfProfileWithPath(profile_path);
if (profile_index != std::string::npos &&
!profile_info_cache.ProfileIsSigninRequiredAtIndex(profile_index))
ShowWindowNearDock();
}
} }
Profile* AppListServiceMac::GetCurrentAppListProfile() { Profile* AppListServiceMac::GetCurrentAppListProfile() {
...@@ -530,8 +546,10 @@ AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) { ...@@ -530,8 +546,10 @@ AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) {
} }
// static // static
void AppListService::InitAll(Profile* initial_profile) { void AppListService::InitAll(Profile* initial_profile,
AppListServiceMac::GetInstance()->Init(initial_profile); const base::FilePath& profile_path) {
AppListServiceMac::GetInstance()->InitWithProfilePath(initial_profile,
profile_path);
} }
@implementation AppListAnimationController @implementation AppListAnimationController
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "chrome/browser/apps/scoped_keep_alive.h" #include "chrome/browser/apps/scoped_keep_alive.h"
#include "chrome/browser/ui/app_list/profile_store.h" #include "chrome/browser/ui/app_list/profile_store.h"
#include "chrome/browser/ui/user_manager.h"
ProfileLoader::ProfileLoader(ProfileStore* profile_store) ProfileLoader::ProfileLoader(ProfileStore* profile_store)
: profile_store_(profile_store), : profile_store_(profile_store),
...@@ -32,6 +33,13 @@ void ProfileLoader::LoadProfileInvalidatingOtherLoads( ...@@ -32,6 +33,13 @@ void ProfileLoader::LoadProfileInvalidatingOtherLoads(
base::Callback<void(Profile*)> callback) { base::Callback<void(Profile*)> callback) {
InvalidatePendingProfileLoads(); InvalidatePendingProfileLoads();
if (profile_store_->IsProfileLocked(profile_file_path)) {
UserManager::Show(base::FilePath(),
profiles::USER_MANAGER_NO_TUTORIAL,
profiles::USER_MANAGER_SELECT_PROFILE_APP_LAUNCHER);
return;
}
Profile* profile = profile_store_->GetProfileByPath(profile_file_path); Profile* profile = profile_store_->GetProfileByPath(profile_file_path);
if (profile) { if (profile) {
callback.Run(profile); callback.Run(profile);
......
...@@ -31,6 +31,9 @@ class ProfileStore { ...@@ -31,6 +31,9 @@ class ProfileStore {
// Returns true if the profile at |path| is supervised. // Returns true if the profile at |path| is supervised.
virtual bool IsProfileSupervised(const base::FilePath& path) = 0; virtual bool IsProfileSupervised(const base::FilePath& path) = 0;
// Returns true if the profile at |path| is locked.
virtual bool IsProfileLocked(const base::FilePath& path) = 0;
}; };
#endif // CHROME_BROWSER_UI_APP_LIST_PROFILE_STORE_H_ #endif // CHROME_BROWSER_UI_APP_LIST_PROFILE_STORE_H_
...@@ -62,3 +62,7 @@ base::FilePath FakeProfileStore::GetUserDataDir() { ...@@ -62,3 +62,7 @@ base::FilePath FakeProfileStore::GetUserDataDir() {
bool FakeProfileStore::IsProfileSupervised(const base::FilePath& path) { bool FakeProfileStore::IsProfileSupervised(const base::FilePath& path) {
return false; return false;
} }
bool FakeProfileStore::IsProfileLocked(const base::FilePath& path) {
return false;
}
...@@ -26,6 +26,7 @@ class FakeProfileStore : public ProfileStore { ...@@ -26,6 +26,7 @@ class FakeProfileStore : public ProfileStore {
Profile* GetProfileByPath(const base::FilePath& path) override; Profile* GetProfileByPath(const base::FilePath& path) override;
base::FilePath GetUserDataDir() override; base::FilePath GetUserDataDir() override;
bool IsProfileSupervised(const base::FilePath& path) override; bool IsProfileSupervised(const base::FilePath& path) override;
bool IsProfileLocked(const base::FilePath& path) override;
private: private:
base::FilePath user_data_dir_; base::FilePath user_data_dir_;
......
...@@ -122,7 +122,8 @@ AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) { ...@@ -122,7 +122,8 @@ AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) {
} }
// static // static
void AppListService::InitAll(Profile* initial_profile) { void AppListService::InitAll(Profile* initial_profile,
const base::FilePath& profile_path) {
AppListServiceAsh::GetInstance()->Init(initial_profile); AppListServiceAsh::GetInstance()->Init(initial_profile);
} }
......
...@@ -697,9 +697,12 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( ...@@ -697,9 +697,12 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
last_used_profile->GetOffTheRecordProfile()) > 0; last_used_profile->GetOffTheRecordProfile()) > 0;
if (signin_required || if (signin_required ||
(last_used_profile->IsGuestSession() && !has_guest_browsers)) { (last_used_profile->IsGuestSession() && !has_guest_browsers)) {
UserManager::Show(base::FilePath(), profiles::UserManagerProfileSelected action =
profiles::USER_MANAGER_NO_TUTORIAL, command_line.HasSwitch(switches::kShowAppList) ?
profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); profiles::USER_MANAGER_SELECT_PROFILE_APP_LAUNCHER :
profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION;
UserManager::Show(
base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL, action);
return true; return true;
} }
} }
......
...@@ -95,7 +95,8 @@ AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) { ...@@ -95,7 +95,8 @@ AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) {
} }
// static // static
void AppListService::InitAll(Profile* initial_profile) { void AppListService::InitAll(Profile* initial_profile,
const base::FilePath& profile_path) {
AppListServiceAsh::GetInstance()->Init(initial_profile); AppListServiceAsh::GetInstance()->Init(initial_profile);
AppListServiceLinux::GetInstance()->Init(initial_profile); AppListServiceLinux::GetInstance()->Init(initial_profile);
} }
...@@ -60,7 +60,8 @@ AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) { ...@@ -60,7 +60,8 @@ AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) {
} }
// static // static
void AppListService::InitAll(Profile* initial_profile) { void AppListService::InitAll(Profile* initial_profile,
const base::FilePath& profile_path) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kViewerConnect)) switches::kViewerConnect))
AppListServiceAsh::GetInstance()->Init(initial_profile); AppListServiceAsh::GetInstance()->Init(initial_profile);
......
...@@ -21,10 +21,12 @@ ...@@ -21,10 +21,12 @@
#include "chrome/browser/profiles/profile_window.h" #include "chrome/browser/profiles/profile_window.h"
#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/signin/local_auth.h" #include "chrome/browser/signin/local_auth.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/singleton_tabs.h" #include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/browser/ui/user_manager.h" #include "chrome/browser/ui/user_manager.h"
...@@ -147,6 +149,68 @@ bool IsAddPersonEnabled() { ...@@ -147,6 +149,68 @@ bool IsAddPersonEnabled() {
return service->GetBoolean(prefs::kBrowserAddPersonEnabled); return service->GetBoolean(prefs::kBrowserAddPersonEnabled);
} }
// Executes the action specified by the URL's Hash parameter, if any. Deletes
// itself after the action would be performed.
class UrlHashHelper : public chrome::BrowserListObserver {
public:
UrlHashHelper(Browser* browser, const std::string& hash);
~UrlHashHelper() override;
void ExecuteUrlHash();
// chrome::BrowserListObserver overrides:
void OnBrowserRemoved(Browser* browser) override;
private:
Browser* browser_;
Profile* profile_;
chrome::HostDesktopType desktop_type_;
std::string hash_;
DISALLOW_COPY_AND_ASSIGN(UrlHashHelper);
};
UrlHashHelper::UrlHashHelper(Browser* browser, const std::string& hash)
: browser_(browser),
profile_(browser->profile()),
desktop_type_(browser->host_desktop_type()),
hash_(hash) {
BrowserList::AddObserver(this);
}
UrlHashHelper::~UrlHashHelper() {
BrowserList::RemoveObserver(this);
}
void UrlHashHelper::OnBrowserRemoved(Browser* browser) {
if (browser == browser_)
browser_ = nullptr;
}
void UrlHashHelper::ExecuteUrlHash() {
if (hash_ == profiles::kUserManagerSelectProfileAppLauncher) {
AppListService* app_list_service = AppListService::Get(desktop_type_);
app_list_service->ShowForProfile(profile_);
return;
}
Browser* target_browser = browser_;
if (!target_browser) {
target_browser = chrome::FindLastActiveWithProfile(profile_, desktop_type_);
if (!target_browser)
return;
}
if (hash_ == profiles::kUserManagerSelectProfileTaskManager)
chrome::OpenTaskManager(target_browser);
else if (hash_ == profiles::kUserManagerSelectProfileAboutChrome)
chrome::ShowAboutChrome(target_browser);
else if (hash_ == profiles::kUserManagerSelectProfileChromeSettings)
chrome::ShowSettings(target_browser);
else if (hash_ == profiles::kUserManagerSelectProfileChromeMemory)
chrome::ShowMemory(target_browser);
}
} // namespace } // namespace
// ProfileUpdateObserver ------------------------------------------------------ // ProfileUpdateObserver ------------------------------------------------------
...@@ -723,18 +787,11 @@ void UserManagerScreenHandler::OnBrowserWindowReady(Browser* browser) { ...@@ -723,18 +787,11 @@ void UserManagerScreenHandler::OnBrowserWindowReady(Browser* browser) {
info_cache.SetProfileSigninRequiredAtIndex(index, false); info_cache.SetProfileSigninRequiredAtIndex(index, false);
} }
if (url_hash_ == profiles::kUserManagerSelectProfileTaskManager) { if (!url_hash_.empty()) {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&chrome::OpenTaskManager, browser));
} else if (url_hash_ == profiles::kUserManagerSelectProfileAboutChrome) {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&chrome::ShowAboutChrome, browser));
} else if (url_hash_ == profiles::kUserManagerSelectProfileChromeSettings) {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&chrome::ShowSettings, browser));
} else if (url_hash_ == profiles::kUserManagerSelectProfileChromeMemory) {
base::MessageLoop::current()->PostTask( base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&chrome::ShowMemory, browser)); FROM_HERE,
base::Bind(&UrlHashHelper::ExecuteUrlHash,
base::Owned(new UrlHashHelper(browser, url_hash_))));
} }
// This call is last as it deletes this object. // This call is last as it deletes this object.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment