| 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the | 243 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the |
| 244 // profile directory. We should eventually be able to run in this | 244 // profile directory. We should eventually be able to run in this |
| 245 // situation. | 245 // situation. |
| 246 if (!file_util::CreateDirectory(path)) | 246 if (!file_util::CreateDirectory(path)) |
| 247 return NULL; | 247 return NULL; |
| 248 } | 248 } |
| 249 return new ProfileImpl(path, NULL); | 249 return new ProfileImpl(path, NULL); |
| 250 } | 250 } |
| 251 | 251 |
| 252 // static | 252 // static |
| 253 Profile* Profile::CreateProfileAsync(const FilePath&path, | 253 Profile* Profile::CreateProfileAsync(const FilePath& path, |
| 254 Profile::Delegate* delegate) { | 254 Profile::Delegate* delegate) { |
| 255 DCHECK(delegate); | 255 DCHECK(delegate); |
| 256 // This is safe while all file operations are done on the FILE thread. | 256 // This is safe while all file operations are done on the FILE thread. |
| 257 BrowserThread::PostTask(BrowserThread::FILE, | 257 BrowserThread::PostTask(BrowserThread::FILE, |
| 258 FROM_HERE, | 258 FROM_HERE, |
| 259 NewRunnableFunction(&file_util::CreateDirectory, | 259 NewRunnableFunction(&file_util::CreateDirectory, |
| 260 path)); | 260 path)); |
| 261 // Async version. | 261 // Async version. |
| 262 return new ProfileImpl(path, delegate); | 262 return new ProfileImpl(path, delegate); |
| 263 } | 263 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 428 |
| 429 // Make sure we initialize the ProfileIOData after everything else has been | 429 // Make sure we initialize the ProfileIOData after everything else has been |
| 430 // initialized that we might be reading from the IO thread. | 430 // initialized that we might be reading from the IO thread. |
| 431 io_data_.Init(cookie_path, cache_path, cache_max_size, | 431 io_data_.Init(cookie_path, cache_path, cache_max_size, |
| 432 media_cache_path, media_cache_max_size, extensions_cookie_path, | 432 media_cache_path, media_cache_max_size, extensions_cookie_path, |
| 433 app_path); | 433 app_path); |
| 434 | 434 |
| 435 // Creation has been finished. | 435 // Creation has been finished. |
| 436 if (delegate_) | 436 if (delegate_) |
| 437 delegate_->OnProfileCreated(this, true); | 437 delegate_->OnProfileCreated(this, true); |
| 438 |
| 439 NotificationService::current()->Notify( |
| 440 chrome::NOTIFICATION_PROFILE_CREATED, |
| 441 Source<Profile>(this), |
| 442 NotificationService::NoDetails()); |
| 438 } | 443 } |
| 439 | 444 |
| 440 void ProfileImpl::InitExtensions(bool extensions_enabled) { | 445 void ProfileImpl::InitExtensions(bool extensions_enabled) { |
| 441 if (user_script_master_ || extension_service_.get()) | 446 if (user_script_master_ || extension_service_.get()) |
| 442 return; // Already initialized. | 447 return; // Already initialized. |
| 443 | 448 |
| 444 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 449 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 445 if (command_line->HasSwitch( | 450 if (command_line->HasSwitch( |
| 446 switches::kEnableExtensionTimelineApi)) { | 451 switches::kEnableExtensionTimelineApi)) { |
| 447 extension_devtools_manager_ = new ExtensionDevToolsManager(this); | 452 extension_devtools_manager_ = new ExtensionDevToolsManager(this); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 bool ProfileImpl::IsOffTheRecord() { | 734 bool ProfileImpl::IsOffTheRecord() { |
| 730 return false; | 735 return false; |
| 731 } | 736 } |
| 732 | 737 |
| 733 Profile* ProfileImpl::GetOffTheRecordProfile() { | 738 Profile* ProfileImpl::GetOffTheRecordProfile() { |
| 734 if (!off_the_record_profile_.get()) { | 739 if (!off_the_record_profile_.get()) { |
| 735 scoped_ptr<Profile> p(CreateOffTheRecordProfile()); | 740 scoped_ptr<Profile> p(CreateOffTheRecordProfile()); |
| 736 off_the_record_profile_.swap(p); | 741 off_the_record_profile_.swap(p); |
| 737 | 742 |
| 738 NotificationService::current()->Notify( | 743 NotificationService::current()->Notify( |
| 739 chrome::NOTIFICATION_OTR_PROFILE_CREATED, | 744 chrome::NOTIFICATION_PROFILE_CREATED, |
| 740 Source<Profile>(off_the_record_profile_.get()), | 745 Source<Profile>(off_the_record_profile_.get()), |
| 741 NotificationService::NoDetails()); | 746 NotificationService::NoDetails()); |
| 742 } | 747 } |
| 743 return off_the_record_profile_.get(); | 748 return off_the_record_profile_.get(); |
| 744 } | 749 } |
| 745 | 750 |
| 746 void ProfileImpl::DestroyOffTheRecordProfile() { | 751 void ProfileImpl::DestroyOffTheRecordProfile() { |
| 747 off_the_record_profile_.reset(); | 752 off_the_record_profile_.reset(); |
| 748 extension_pref_value_map_->ClearAllIncognitoSessionOnlyPreferences(); | 753 extension_pref_value_map_->ClearAllIncognitoSessionOnlyPreferences(); |
| 749 } | 754 } |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 if (!prerender::PrerenderManager::IsPrerenderingPossible()) | 1717 if (!prerender::PrerenderManager::IsPrerenderingPossible()) |
| 1713 return NULL; | 1718 return NULL; |
| 1714 if (!prerender_manager_.get()) { | 1719 if (!prerender_manager_.get()) { |
| 1715 CHECK(g_browser_process->prerender_tracker()); | 1720 CHECK(g_browser_process->prerender_tracker()); |
| 1716 prerender_manager_.reset( | 1721 prerender_manager_.reset( |
| 1717 new prerender::PrerenderManager( | 1722 new prerender::PrerenderManager( |
| 1718 this, g_browser_process->prerender_tracker())); | 1723 this, g_browser_process->prerender_tracker())); |
| 1719 } | 1724 } |
| 1720 return prerender_manager_.get(); | 1725 return prerender_manager_.get(); |
| 1721 } | 1726 } |
| OLD | NEW |