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

Side by Side Diff: chrome/browser/ui/app_list/app_list_service_impl.cc

Issue 856733004: Loading the Launcher with a Locked Profile launched UserManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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 unified diff | Download patch
OLDNEW
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/ui/app_list/app_list_service_impl.h" 5 #include "chrome/browser/ui/app_list/app_list_service_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/browser_shutdown.h" 16 #include "chrome/browser/browser_shutdown.h"
17 #include "chrome/browser/profiles/profile_manager.h" 17 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" 18 #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
19 #include "chrome/browser/ui/app_list/profile_loader.h" 19 #include "chrome/browser/ui/app_list/profile_loader.h"
20 #include "chrome/browser/ui/app_list/profile_store.h" 20 #include "chrome/browser/ui/app_list/profile_store.h"
21 #include "chrome/browser/ui/user_manager.h"
tapted 2015/01/27 02:52:55 nit: unsued I think
Mike Lerman 2015/01/27 14:59:49 Done.
21 #include "chrome/common/chrome_constants.h" 22 #include "chrome/common/chrome_constants.h"
22 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
24 #include "ui/app_list/app_list_model.h" 25 #include "ui/app_list/app_list_model.h"
25 26
26 namespace { 27 namespace {
27 28
28 const int kDiscoverabilityTimeoutMinutes = 60; 29 const int kDiscoverabilityTimeoutMinutes = 60;
29 30
30 void SendAppListAppLaunch(int count) { 31 void SendAppListAppLaunch(int count) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 case Profile::CREATE_STATUS_REMOTE_FAIL: 117 case Profile::CREATE_STATUS_REMOTE_FAIL:
117 case Profile::CREATE_STATUS_CANCELED: 118 case Profile::CREATE_STATUS_CANCELED:
118 break; 119 break;
119 case Profile::MAX_CREATE_STATUS: 120 case Profile::MAX_CREATE_STATUS:
120 NOTREACHED(); 121 NOTREACHED();
121 break; 122 break;
122 } 123 }
123 } 124 }
124 125
125 Profile* GetProfileByPath(const base::FilePath& path) override { 126 Profile* GetProfileByPath(const base::FilePath& path) override {
127 DCHECK(!IsProfileLocked(path));
126 return profile_manager_->GetProfileByPath(path); 128 return profile_manager_->GetProfileByPath(path);
127 } 129 }
128 130
129 base::FilePath GetUserDataDir() override { 131 base::FilePath GetUserDataDir() override {
130 return profile_manager_->user_data_dir(); 132 return profile_manager_->user_data_dir();
131 } 133 }
132 134
133 bool IsProfileSupervised(const base::FilePath& profile_path) override { 135 bool IsProfileSupervised(const base::FilePath& profile_path) override {
134 ProfileInfoCache& profile_info = 136 ProfileInfoCache& profile_info =
135 g_browser_process->profile_manager()->GetProfileInfoCache(); 137 g_browser_process->profile_manager()->GetProfileInfoCache();
136 size_t profile_index = profile_info.GetIndexOfProfileWithPath(profile_path); 138 size_t profile_index = profile_info.GetIndexOfProfileWithPath(profile_path);
137 return profile_index != std::string::npos && 139 return profile_index != std::string::npos &&
138 profile_info.ProfileIsSupervisedAtIndex(profile_index); 140 profile_info.ProfileIsSupervisedAtIndex(profile_index);
139 } 141 }
140 142
143 bool IsProfileLocked(const base::FilePath& profile_path) override {
144 ProfileInfoCache& profile_info =
145 g_browser_process->profile_manager()->GetProfileInfoCache();
146 size_t profile_index = profile_info.GetIndexOfProfileWithPath(profile_path);
147 return profile_index != std::string::npos &&
148 profile_info.ProfileIsSigninRequiredAtIndex(profile_index);
149 }
150
141 private: 151 private:
142 ProfileManager* profile_manager_; 152 ProfileManager* profile_manager_;
143 base::WeakPtrFactory<ProfileStoreImpl> weak_factory_; 153 base::WeakPtrFactory<ProfileStoreImpl> weak_factory_;
144 }; 154 };
145 155
146 void RecordAppListDiscoverability(PrefService* local_state, 156 void RecordAppListDiscoverability(PrefService* local_state,
147 bool is_startup_check) { 157 bool is_startup_check) {
148 // Since this task may be delayed, ensure it does not interfere with shutdown 158 // Since this task may be delayed, ensure it does not interfere with shutdown
149 // when they unluckily coincide. 159 // when they unluckily coincide.
150 if (browser_shutdown::IsTryingToQuit()) 160 if (browser_shutdown::IsTryingToQuit())
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 if (!base::MessageLoop::current()) 417 if (!base::MessageLoop::current())
408 return; // In a unit test. 418 return; // In a unit test.
409 419
410 // Send app list usage stats after a delay. 420 // Send app list usage stats after a delay.
411 const int kSendUsageStatsDelay = 5; 421 const int kSendUsageStatsDelay = 5;
412 base::MessageLoop::current()->PostDelayedTask( 422 base::MessageLoop::current()->PostDelayedTask(
413 FROM_HERE, 423 FROM_HERE,
414 base::Bind(&AppListServiceImpl::SendAppListStats), 424 base::Bind(&AppListServiceImpl::SendAppListStats),
415 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); 425 base::TimeDelta::FromSeconds(kSendUsageStatsDelay));
416 } 426 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698