| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 class ProfileStoreImpl : public ProfileStore { | 82 class ProfileStoreImpl : public ProfileStore { |
| 83 public: | 83 public: |
| 84 explicit ProfileStoreImpl(ProfileManager* profile_manager) | 84 explicit ProfileStoreImpl(ProfileManager* profile_manager) |
| 85 : profile_manager_(profile_manager), | 85 : profile_manager_(profile_manager), |
| 86 weak_factory_(this) { | 86 weak_factory_(this) { |
| 87 } | 87 } |
| 88 | 88 |
| 89 virtual void AddProfileObserver(ProfileInfoCacheObserver* observer) OVERRIDE { | 89 virtual void AddProfileObserver(ProfileInfoCacheObserver* observer) override { |
| 90 profile_manager_->GetProfileInfoCache().AddObserver(observer); | 90 profile_manager_->GetProfileInfoCache().AddObserver(observer); |
| 91 } | 91 } |
| 92 | 92 |
| 93 virtual void LoadProfileAsync( | 93 virtual void LoadProfileAsync( |
| 94 const base::FilePath& path, | 94 const base::FilePath& path, |
| 95 base::Callback<void(Profile*)> callback) OVERRIDE { | 95 base::Callback<void(Profile*)> callback) override { |
| 96 profile_manager_->CreateProfileAsync( | 96 profile_manager_->CreateProfileAsync( |
| 97 path, | 97 path, |
| 98 base::Bind(&ProfileStoreImpl::OnProfileCreated, | 98 base::Bind(&ProfileStoreImpl::OnProfileCreated, |
| 99 weak_factory_.GetWeakPtr(), | 99 weak_factory_.GetWeakPtr(), |
| 100 callback), | 100 callback), |
| 101 base::string16(), | 101 base::string16(), |
| 102 base::string16(), | 102 base::string16(), |
| 103 std::string()); | 103 std::string()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void OnProfileCreated(base::Callback<void(Profile*)> callback, | 106 void OnProfileCreated(base::Callback<void(Profile*)> callback, |
| 107 Profile* profile, | 107 Profile* profile, |
| 108 Profile::CreateStatus status) { | 108 Profile::CreateStatus status) { |
| 109 switch (status) { | 109 switch (status) { |
| 110 case Profile::CREATE_STATUS_CREATED: | 110 case Profile::CREATE_STATUS_CREATED: |
| 111 break; | 111 break; |
| 112 case Profile::CREATE_STATUS_INITIALIZED: | 112 case Profile::CREATE_STATUS_INITIALIZED: |
| 113 callback.Run(profile); | 113 callback.Run(profile); |
| 114 break; | 114 break; |
| 115 case Profile::CREATE_STATUS_LOCAL_FAIL: | 115 case Profile::CREATE_STATUS_LOCAL_FAIL: |
| 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 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 IsProfileSupervised( | 133 virtual bool IsProfileSupervised( |
| 134 const base::FilePath& profile_path) OVERRIDE { | 134 const base::FilePath& profile_path) override { |
| 135 ProfileInfoCache& profile_info = | 135 ProfileInfoCache& profile_info = |
| 136 g_browser_process->profile_manager()->GetProfileInfoCache(); | 136 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 137 size_t profile_index = profile_info.GetIndexOfProfileWithPath(profile_path); | 137 size_t profile_index = profile_info.GetIndexOfProfileWithPath(profile_path); |
| 138 return profile_index != std::string::npos && | 138 return profile_index != std::string::npos && |
| 139 profile_info.ProfileIsSupervisedAtIndex(profile_index); | 139 profile_info.ProfileIsSupervisedAtIndex(profile_index); |
| 140 } | 140 } |
| 141 | 141 |
| 142 private: | 142 private: |
| 143 ProfileManager* profile_manager_; | 143 ProfileManager* profile_manager_; |
| 144 base::WeakPtrFactory<ProfileStoreImpl> weak_factory_; | 144 base::WeakPtrFactory<ProfileStoreImpl> weak_factory_; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 if (!base::MessageLoop::current()) | 386 if (!base::MessageLoop::current()) |
| 387 return; // In a unit test. | 387 return; // In a unit test. |
| 388 | 388 |
| 389 // Send app list usage stats after a delay. | 389 // Send app list usage stats after a delay. |
| 390 const int kSendUsageStatsDelay = 5; | 390 const int kSendUsageStatsDelay = 5; |
| 391 base::MessageLoop::current()->PostDelayedTask( | 391 base::MessageLoop::current()->PostDelayedTask( |
| 392 FROM_HERE, | 392 FROM_HERE, |
| 393 base::Bind(&AppListServiceImpl::SendAppListStats), | 393 base::Bind(&AppListServiceImpl::SendAppListStats), |
| 394 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); | 394 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); |
| 395 } | 395 } |
| OLD | NEW |