| 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" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 case Profile::CREATE_STATUS_REMOTE_FAIL: | 116 case Profile::CREATE_STATUS_REMOTE_FAIL: |
| 117 case Profile::CREATE_STATUS_CANCELED: | 117 case Profile::CREATE_STATUS_CANCELED: |
| 118 break; | 118 break; |
| 119 case Profile::MAX_CREATE_STATUS: | 119 case Profile::MAX_CREATE_STATUS: |
| 120 NOTREACHED(); | 120 NOTREACHED(); |
| 121 break; | 121 break; |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 Profile* GetProfileByPath(const base::FilePath& path) override { | 125 Profile* GetProfileByPath(const base::FilePath& path) override { |
| 126 DCHECK(!IsProfileLocked(path)); |
| 126 return profile_manager_->GetProfileByPath(path); | 127 return profile_manager_->GetProfileByPath(path); |
| 127 } | 128 } |
| 128 | 129 |
| 129 base::FilePath GetUserDataDir() override { | 130 base::FilePath GetUserDataDir() override { |
| 130 return profile_manager_->user_data_dir(); | 131 return profile_manager_->user_data_dir(); |
| 131 } | 132 } |
| 132 | 133 |
| 133 bool IsProfileSupervised(const base::FilePath& profile_path) override { | 134 bool IsProfileSupervised(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.ProfileIsSupervisedAtIndex(profile_index); | 139 profile_info.ProfileIsSupervisedAtIndex(profile_index); |
| 139 } | 140 } |
| 140 | 141 |
| 142 bool IsProfileLocked(const base::FilePath& profile_path) override { |
| 143 ProfileInfoCache& profile_info = |
| 144 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 145 size_t profile_index = profile_info.GetIndexOfProfileWithPath(profile_path); |
| 146 return profile_index != std::string::npos && |
| 147 profile_info.ProfileIsSigninRequiredAtIndex(profile_index); |
| 148 } |
| 149 |
| 141 private: | 150 private: |
| 142 ProfileManager* profile_manager_; | 151 ProfileManager* profile_manager_; |
| 143 base::WeakPtrFactory<ProfileStoreImpl> weak_factory_; | 152 base::WeakPtrFactory<ProfileStoreImpl> weak_factory_; |
| 144 }; | 153 }; |
| 145 | 154 |
| 146 void RecordAppListDiscoverability(PrefService* local_state, | 155 void RecordAppListDiscoverability(PrefService* local_state, |
| 147 bool is_startup_check) { | 156 bool is_startup_check) { |
| 148 // Since this task may be delayed, ensure it does not interfere with shutdown | 157 // Since this task may be delayed, ensure it does not interfere with shutdown |
| 149 // when they unluckily coincide. | 158 // when they unluckily coincide. |
| 150 if (browser_shutdown::IsTryingToQuit()) | 159 if (browser_shutdown::IsTryingToQuit()) |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 if (!base::MessageLoop::current()) | 416 if (!base::MessageLoop::current()) |
| 408 return; // In a unit test. | 417 return; // In a unit test. |
| 409 | 418 |
| 410 // Send app list usage stats after a delay. | 419 // Send app list usage stats after a delay. |
| 411 const int kSendUsageStatsDelay = 5; | 420 const int kSendUsageStatsDelay = 5; |
| 412 base::MessageLoop::current()->PostDelayedTask( | 421 base::MessageLoop::current()->PostDelayedTask( |
| 413 FROM_HERE, | 422 FROM_HERE, |
| 414 base::Bind(&AppListServiceImpl::SendAppListStats), | 423 base::Bind(&AppListServiceImpl::SendAppListStats), |
| 415 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); | 424 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); |
| 416 } | 425 } |
| OLD | NEW |