| 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 "apps/pref_names.h" | 9 #include "apps/pref_names.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } | 123 } |
| 124 | 124 |
| 125 virtual Profile* GetProfileByPath(const base::FilePath& path) OVERRIDE { | 125 virtual Profile* GetProfileByPath(const base::FilePath& path) OVERRIDE { |
| 126 return profile_manager_->GetProfileByPath(path); | 126 return profile_manager_->GetProfileByPath(path); |
| 127 } | 127 } |
| 128 | 128 |
| 129 virtual base::FilePath GetUserDataDir() OVERRIDE { | 129 virtual base::FilePath GetUserDataDir() OVERRIDE { |
| 130 return profile_manager_->user_data_dir(); | 130 return profile_manager_->user_data_dir(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 virtual bool IsProfileManaged(const base::FilePath& profile_path) OVERRIDE { | 133 virtual bool IsProfileSupervised( |
| 134 const base::FilePath& profile_path) OVERRIDE { |
| 134 ProfileInfoCache& profile_info = | 135 ProfileInfoCache& profile_info = |
| 135 g_browser_process->profile_manager()->GetProfileInfoCache(); | 136 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 136 size_t profile_index = profile_info.GetIndexOfProfileWithPath(profile_path); | 137 size_t profile_index = profile_info.GetIndexOfProfileWithPath(profile_path); |
| 137 return profile_index != std::string::npos && | 138 return profile_index != std::string::npos && |
| 138 profile_info.ProfileIsManagedAtIndex(profile_index); | 139 profile_info.ProfileIsSupervisedAtIndex(profile_index); |
| 139 } | 140 } |
| 140 | 141 |
| 141 private: | 142 private: |
| 142 ProfileManager* profile_manager_; | 143 ProfileManager* profile_manager_; |
| 143 base::WeakPtrFactory<ProfileStoreImpl> weak_factory_; | 144 base::WeakPtrFactory<ProfileStoreImpl> weak_factory_; |
| 144 }; | 145 }; |
| 145 | 146 |
| 146 void RecordAppListDiscoverability(PrefService* local_state, | 147 void RecordAppListDiscoverability(PrefService* local_state, |
| 147 bool is_startup_check) { | 148 bool is_startup_check) { |
| 148 // Since this task may be delayed, ensure it does not interfere with shutdown | 149 // Since this task may be delayed, ensure it does not interfere with shutdown |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 270 } |
| 270 | 271 |
| 271 // If there is no last used profile recorded, use the initial profile. | 272 // If there is no last used profile recorded, use the initial profile. |
| 272 if (app_list_profile.empty()) | 273 if (app_list_profile.empty()) |
| 273 app_list_profile = chrome::kInitialProfile; | 274 app_list_profile = chrome::kInitialProfile; |
| 274 | 275 |
| 275 return user_data_dir.AppendASCII(app_list_profile); | 276 return user_data_dir.AppendASCII(app_list_profile); |
| 276 } | 277 } |
| 277 | 278 |
| 278 void AppListServiceImpl::SetProfilePath(const base::FilePath& profile_path) { | 279 void AppListServiceImpl::SetProfilePath(const base::FilePath& profile_path) { |
| 279 // Ensure we don't set the pref to a managed user's profile path. | 280 // Ensure we don't set the pref to a supervised user's profile path. |
| 280 // TODO(calamity): Filter out managed profiles from the settings app so this | 281 // TODO(calamity): Filter out supervised profiles from the settings app so |
| 281 // can't get hit, so we can remove it. | 282 // this can't get hit, so we can remove it. |
| 282 if (profile_store_->IsProfileManaged(profile_path)) | 283 if (profile_store_->IsProfileSupervised(profile_path)) |
| 283 return; | 284 return; |
| 284 | 285 |
| 285 local_state_->SetString( | 286 local_state_->SetString( |
| 286 prefs::kAppListProfile, | 287 prefs::kAppListProfile, |
| 287 profile_path.BaseName().MaybeAsASCII()); | 288 profile_path.BaseName().MaybeAsASCII()); |
| 288 } | 289 } |
| 289 | 290 |
| 290 void AppListServiceImpl::CreateShortcut() {} | 291 void AppListServiceImpl::CreateShortcut() {} |
| 291 | 292 |
| 292 // We need to watch for profile removal to keep kAppListProfile updated. | 293 // We need to watch for profile removal to keep kAppListProfile updated. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 if (!base::MessageLoop::current()) | 366 if (!base::MessageLoop::current()) |
| 366 return; // In a unit test. | 367 return; // In a unit test. |
| 367 | 368 |
| 368 // Send app list usage stats after a delay. | 369 // Send app list usage stats after a delay. |
| 369 const int kSendUsageStatsDelay = 5; | 370 const int kSendUsageStatsDelay = 5; |
| 370 base::MessageLoop::current()->PostDelayedTask( | 371 base::MessageLoop::current()->PostDelayedTask( |
| 371 FROM_HERE, | 372 FROM_HERE, |
| 372 base::Bind(&AppListServiceImpl::SendAppListStats), | 373 base::Bind(&AppListServiceImpl::SendAppListStats), |
| 373 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); | 374 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); |
| 374 } | 375 } |
| OLD | NEW |