OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/profiles/profile_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 *max_size = 0; | 211 *max_size = 0; |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 FilePath GetCachePath(const FilePath& base) { | 215 FilePath GetCachePath(const FilePath& base) { |
216 return base.Append(chrome::kCacheDirname); | 216 return base.Append(chrome::kCacheDirname); |
217 } | 217 } |
218 | 218 |
219 FilePath GetMediaCachePath(const FilePath& base) { | 219 FilePath GetMediaCachePath(const FilePath& base) { |
220 return base.Append(chrome::kMediaCacheDirname); | 220 return base.Append(chrome::kMediaCacheDirname); |
221 } | 221 } |
Mattias Nissler (ping if slow)
2011/10/07 11:02:57
unrelated?
pastarmovj
2011/10/13 11:25:06
Yes. Cleared.
| |
222 | 222 |
223 void DoInstallDefaultAppsOnUIThread(const FilePath& profile_path, | |
224 const std::list<FilePath>& crx_path_list) { | |
225 Profile* profile = | |
226 g_browser_process->profile_manager()->GetProfileByPath(profile_path); | |
227 if (profile) { | |
228 ExtensionService* extension_service = profile->GetExtensionService(); | |
229 for (std::list<FilePath>::const_iterator iter = crx_path_list.begin(); | |
230 iter != crx_path_list.end(); ++iter) { | |
231 scoped_refptr<CrxInstaller> crx_installer = | |
232 extension_service->MakeCrxInstaller(NULL); | |
233 crx_installer->set_allow_silent_install(true); | |
234 crx_installer->set_delete_source(false); | |
235 crx_installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); | |
236 crx_installer->InstallCrx(*iter); | |
237 } | |
238 } | |
239 } | |
240 | |
241 void InstallDefaultApps(const FilePath& profile_path) { | |
242 FilePath apps_dir; | |
243 FilePath file; | |
244 std::list<FilePath> crx_path_list; | |
245 | |
246 if (PathService::Get(chrome::DIR_DEFAULT_APPS, &apps_dir)) { | |
247 file_util::FileEnumerator file_enumerator(apps_dir, false, | |
248 file_util::FileEnumerator::FILES); | |
249 while (!(file = file_enumerator.Next()).value().empty()) { | |
250 if (LowerCaseEqualsASCII(file.Extension(), ".crx")) | |
251 crx_path_list.push_back(file); | |
252 } | |
253 } | |
254 // No need to post the task if nothing was there to install. | |
255 if (!crx_path_list.size()) | |
256 return; | |
257 | |
258 // Finish the install on the UI thread. | |
259 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | |
260 base::Bind(&DoInstallDefaultAppsOnUIThread, | |
261 profile_path, crx_path_list)); | |
262 } | |
263 | |
264 // Simple task to log the size of the current profile. | 223 // Simple task to log the size of the current profile. |
265 class ProfileSizeTask : public Task { | 224 class ProfileSizeTask : public Task { |
266 public: | 225 public: |
267 explicit ProfileSizeTask(const FilePath& path) : path_(path) {} | 226 explicit ProfileSizeTask(const FilePath& path) : path_(path) {} |
268 virtual ~ProfileSizeTask() {} | 227 virtual ~ProfileSizeTask() {} |
269 | 228 |
270 virtual void Run(); | 229 virtual void Run(); |
271 private: | 230 private: |
272 FilePath path_; | 231 FilePath path_; |
273 }; | 232 }; |
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1821 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { | 1780 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { |
1822 if (!spellcheck_profile_.get()) | 1781 if (!spellcheck_profile_.get()) |
1823 spellcheck_profile_.reset(new SpellCheckProfile()); | 1782 spellcheck_profile_.reset(new SpellCheckProfile()); |
1824 return spellcheck_profile_.get(); | 1783 return spellcheck_profile_.get(); |
1825 } | 1784 } |
1826 | 1785 |
1827 void ProfileImpl::SetDownloadManagerDelegate( | 1786 void ProfileImpl::SetDownloadManagerDelegate( |
1828 ChromeDownloadManagerDelegate* delegate) { | 1787 ChromeDownloadManagerDelegate* delegate) { |
1829 download_manager_delegate_ = delegate; | 1788 download_manager_delegate_ = delegate; |
1830 } | 1789 } |
OLD | NEW |