OLD | NEW |
---|---|
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" | |
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 Loading... | |
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 if (IsProfileLocked(path)) | |
tapted
2015/01/21 22:47:20
nit: I'm pretty sure this can this be DCHECK(!IsPr
Mike Lerman
2015/01/23 16:58:33
Oop, thanks! I had meant to remove this completely
| |
128 return nullptr; | |
126 return profile_manager_->GetProfileByPath(path); | 129 return profile_manager_->GetProfileByPath(path); |
127 } | 130 } |
128 | 131 |
129 base::FilePath GetUserDataDir() override { | 132 base::FilePath GetUserDataDir() override { |
130 return profile_manager_->user_data_dir(); | 133 return profile_manager_->user_data_dir(); |
131 } | 134 } |
132 | 135 |
133 bool IsProfileSupervised(const base::FilePath& profile_path) override { | 136 bool IsProfileSupervised(const base::FilePath& profile_path) override { |
134 ProfileInfoCache& profile_info = | 137 ProfileInfoCache& profile_info = |
135 g_browser_process->profile_manager()->GetProfileInfoCache(); | 138 g_browser_process->profile_manager()->GetProfileInfoCache(); |
136 size_t profile_index = profile_info.GetIndexOfProfileWithPath(profile_path); | 139 size_t profile_index = profile_info.GetIndexOfProfileWithPath(profile_path); |
137 return profile_index != std::string::npos && | 140 return profile_index != std::string::npos && |
138 profile_info.ProfileIsSupervisedAtIndex(profile_index); | 141 profile_info.ProfileIsSupervisedAtIndex(profile_index); |
139 } | 142 } |
140 | 143 |
144 bool IsProfileLocked(const base::FilePath& profile_path) override { | |
145 ProfileInfoCache& profile_info = | |
146 g_browser_process->profile_manager()->GetProfileInfoCache(); | |
147 size_t profile_index = profile_info.GetIndexOfProfileWithPath(profile_path); | |
148 return profile_index != std::string::npos && | |
149 profile_info.ProfileIsSigninRequiredAtIndex(profile_index); | |
150 } | |
151 | |
141 private: | 152 private: |
142 ProfileManager* profile_manager_; | 153 ProfileManager* profile_manager_; |
143 base::WeakPtrFactory<ProfileStoreImpl> weak_factory_; | 154 base::WeakPtrFactory<ProfileStoreImpl> weak_factory_; |
144 }; | 155 }; |
145 | 156 |
146 void RecordAppListDiscoverability(PrefService* local_state, | 157 void RecordAppListDiscoverability(PrefService* local_state, |
147 bool is_startup_check) { | 158 bool is_startup_check) { |
148 // Since this task may be delayed, ensure it does not interfere with shutdown | 159 // Since this task may be delayed, ensure it does not interfere with shutdown |
149 // when they unluckily coincide. | 160 // when they unluckily coincide. |
150 if (browser_shutdown::IsTryingToQuit()) | 161 if (browser_shutdown::IsTryingToQuit()) |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 if (!base::MessageLoop::current()) | 418 if (!base::MessageLoop::current()) |
408 return; // In a unit test. | 419 return; // In a unit test. |
409 | 420 |
410 // Send app list usage stats after a delay. | 421 // Send app list usage stats after a delay. |
411 const int kSendUsageStatsDelay = 5; | 422 const int kSendUsageStatsDelay = 5; |
412 base::MessageLoop::current()->PostDelayedTask( | 423 base::MessageLoop::current()->PostDelayedTask( |
413 FROM_HERE, | 424 FROM_HERE, |
414 base::Bind(&AppListServiceImpl::SendAppListStats), | 425 base::Bind(&AppListServiceImpl::SendAppListStats), |
415 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); | 426 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); |
416 } | 427 } |
OLD | NEW |