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

Unified Diff: chrome/browser/ui/app_list/app_list_service_impl.cc

Issue 1106453002: Fixed app launcher crashing trying to load guest profile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows compile. Created 5 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 | « no previous file | chrome/browser/ui/app_list/app_list_service_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/app_list_service_impl.cc
diff --git a/chrome/browser/ui/app_list/app_list_service_impl.cc b/chrome/browser/ui/app_list/app_list_service_impl.cc
index 9913d15bc09b48f09ecbce11a7ef5559928d7239..3ed976e2c30f0c9b0fe7a0c95b15e73968743156 100644
--- a/chrome/browser/ui/app_list/app_list_service_impl.cc
+++ b/chrome/browser/ui/app_list/app_list_service_impl.cc
@@ -210,6 +210,16 @@ void RecordAppListDiscoverability(PrefService* local_state,
AppListService::ENABLE_NUM_ENABLE_SOURCES);
}
+// Checks whether a profile name is valid for the app list. Returns false if the
+// name is empty, or represents a guest profile.
+bool IsValidProfileName(const std::string& profile_name) {
+ if (profile_name.empty())
+ return false;
+
+ return profile_name !=
+ base::FilePath(chrome::kGuestProfileDir).AsUTF8Unsafe();
+}
+
} // namespace
void AppListServiceImpl::RecordAppListLaunch() {
@@ -301,14 +311,20 @@ void AppListServiceImpl::SetProfilePath(const base::FilePath& profile_path) {
void AppListServiceImpl::CreateShortcut() {}
std::string AppListServiceImpl::GetProfileName() {
- const std::string app_list_profile =
+ std::string app_list_profile =
local_state_->GetString(prefs::kAppListProfile);
- if (!app_list_profile.empty())
+ if (IsValidProfileName(app_list_profile))
return app_list_profile;
// If the user has no profile preference for the app launcher, default to the
// last browser profile used.
- return profile_store_->GetLastUsedProfileName();
+ app_list_profile = profile_store_->GetLastUsedProfileName();
+ if (IsValidProfileName(app_list_profile))
+ return app_list_profile;
+
+ // If the last profile used was invalid (ie, guest profile), use the initial
+ // profile.
+ return chrome::kInitialProfile;
}
void AppListServiceImpl::OnProfileWillBeRemoved(
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698