Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3115)

Unified Diff: chrome/browser/ui/views/app_list/app_list_controller_win.cc

Issue 14783011: Merge 199372 "Make AppListController::InitView() act on the righ..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1500/src/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/app_list/app_list_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/app_list/app_list_controller_win.cc
===================================================================
--- chrome/browser/ui/views/app_list/app_list_controller_win.cc (revision 199485)
+++ chrome/browser/ui/views/app_list/app_list_controller_win.cc (working copy)
@@ -290,10 +290,6 @@
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);
@@ -378,6 +374,16 @@
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_;
@@ -604,7 +610,6 @@
DecrementPendingProfileLoads();
break;
}
-
}
void AppListController::IncrementPendingProfileLoads() {
@@ -661,14 +666,6 @@
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);
@@ -981,10 +978,49 @@
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) {
@@ -1009,9 +1045,16 @@
const int kInitWindowDelay = 5;
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(
« no previous file with comments | « chrome/browser/ui/app_list/app_list_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698