| Index: chrome/browser/ui/views/app_list/app_list_controller_win.cc
|
| diff --git a/chrome/browser/ui/views/app_list/app_list_controller_win.cc b/chrome/browser/ui/views/app_list/app_list_controller_win.cc
|
| index 9ab258dbee0af3b4eae00873ddcb1d49a09157ca..2d91c86851220956a149ca63dec6e532a1718323 100644
|
| --- a/chrome/browser/ui/views/app_list/app_list_controller_win.cc
|
| +++ b/chrome/browser/ui/views/app_list/app_list_controller_win.cc
|
| @@ -304,10 +304,6 @@ class AppListController : public AppListService,
|
| bool can_close() { return can_close_app_list_; }
|
| Profile* profile() const { return profile_; }
|
|
|
| - // Creates the app list view and populates it from |profile|, but doesn't
|
| - // show it. Does nothing if the view already exists.
|
| - void InitView(Profile* profile);
|
| -
|
| void AppListClosing();
|
| void AppListActivationChanged(bool active);
|
| void ShowAppListDuringModeSwitch(Profile* profile);
|
| @@ -392,6 +388,16 @@ class AppListController : public AppListService,
|
| void EnsureHaveKeepAliveForView();
|
| void FreeAnyKeepAliveForView();
|
|
|
| + // Loads the profile last used with the app list and populates the view from
|
| + // it without showing it so that the next show is faster. Does nothing if the
|
| + // view already exists, or another profile is in the middle of being loaded to
|
| + // be shown.
|
| + void InitView();
|
| + bool IsInitViewNeeded();
|
| + void InitViewFromProfile(int profile_load_sequence_id,
|
| + Profile* profile,
|
| + Profile::CreateStatus status);
|
| +
|
| // Weak pointer. The view manages its own lifetime.
|
| app_list::AppListView* current_view_;
|
|
|
| @@ -618,7 +624,6 @@ void AppListController::OnProfileLoaded(int profile_load_sequence_id,
|
| DecrementPendingProfileLoads();
|
| break;
|
| }
|
| -
|
| }
|
|
|
| void AppListController::IncrementPendingProfileLoads() {
|
| @@ -675,14 +680,6 @@ void AppListController::ShowAppList(Profile* profile) {
|
| RecordAppListLaunch();
|
| }
|
|
|
| -void AppListController::InitView(Profile* profile) {
|
| - if (current_view_)
|
| - return;
|
| - AppListService::SendAppListStats();
|
| - PopulateViewFromProfile(profile);
|
| - current_view_->Prerender();
|
| -}
|
| -
|
| void AppListController::ShowAppListDuringModeSwitch(Profile* profile) {
|
| regain_first_lost_focus_ = true;
|
| ShowAppList(profile);
|
| @@ -995,10 +992,49 @@ void AppListController::FreeAnyKeepAliveForView() {
|
| keep_alive_.reset(NULL);
|
| }
|
|
|
| -void InitView(Profile* profile) {
|
| +void AppListController::InitView() {
|
| + if (!IsInitViewNeeded())
|
| + return;
|
| +
|
| + base::FilePath user_data_dir(
|
| + g_browser_process->profile_manager()->user_data_dir());
|
| + base::FilePath profile_file_path(GetAppListProfilePath(user_data_dir));
|
| +
|
| + ProfileManager* profile_manager = g_browser_process->profile_manager();
|
| + Profile* profile = profile_manager->GetProfileByPath(profile_file_path);
|
| +
|
| + if (!profile) {
|
| + profile_manager->CreateProfileAsync(
|
| + profile_file_path,
|
| + base::Bind(&AppListController::InitViewFromProfile,
|
| + weak_factory_.GetWeakPtr(), profile_load_sequence_id_),
|
| + string16(), string16(), false);
|
| + return;
|
| + }
|
| + InitViewFromProfile(
|
| + profile_load_sequence_id_, profile, Profile::CREATE_STATUS_INITIALIZED);
|
| +}
|
| +
|
| +bool AppListController::IsInitViewNeeded() {
|
| if (!g_browser_process || g_browser_process->IsShuttingDown())
|
| + return false;
|
| +
|
| + // We only need to initialize the view if there's no view already created and
|
| + // there's no profile loading to be shown.
|
| + return !current_view_ && profile_load_sequence_id_ == 0;
|
| +}
|
| +
|
| +void AppListController::InitViewFromProfile(int profile_load_sequence_id,
|
| + Profile* profile,
|
| + Profile::CreateStatus status) {
|
| + if (!IsInitViewNeeded())
|
| return;
|
| - AppListController::GetInstance()->InitView(profile);
|
| +
|
| + if (status != Profile::CREATE_STATUS_INITIALIZED)
|
| + return;
|
| +
|
| + PopulateViewFromProfile(profile);
|
| + current_view_->Prerender();
|
| }
|
|
|
| void AppListController::Init(Profile* initial_profile) {
|
| @@ -1023,9 +1059,16 @@ void AppListController::Init(Profile* initial_profile) {
|
| const int kInitWindowDelay = 5;
|
| base::MessageLoop::current()->PostDelayedTask(
|
| FROM_HERE,
|
| - base::Bind(&::InitView, initial_profile),
|
| + base::Bind(&AppListController::InitView, weak_factory_.GetWeakPtr()),
|
| base::TimeDelta::FromSeconds(kInitWindowDelay));
|
|
|
| + // Send app list usage stats after a delay.
|
| + const int kSendUsageStatsDelay = 5;
|
| + MessageLoop::current()->PostDelayedTask(
|
| + FROM_HERE,
|
| + base::Bind(&AppListService::SendAppListStats),
|
| + base::TimeDelta::FromSeconds(kSendUsageStatsDelay));
|
| +
|
| MigrateAppLauncherEnabledPref();
|
|
|
| if (CommandLine::ForCurrentProcess()->HasSwitch(
|
|
|