| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_browser_main.h" |
| 6 | 6 |
| 7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 // ... additional setup | 1034 // ... additional setup |
| 1035 // PreBrowserStart() | 1035 // PreBrowserStart() |
| 1036 // ... browser_creator_->Start (OR parameters().ui_task->Run()) | 1036 // ... browser_creator_->Start (OR parameters().ui_task->Run()) |
| 1037 // PostBrowserStart() | 1037 // PostBrowserStart() |
| 1038 | 1038 |
| 1039 void ChromeBrowserMainParts::PreProfileInit() { | 1039 void ChromeBrowserMainParts::PreProfileInit() { |
| 1040 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreProfileInit"); | 1040 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreProfileInit"); |
| 1041 | 1041 |
| 1042 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1042 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 1043 chrome_extra_parts_[i]->PreProfileInit(); | 1043 chrome_extra_parts_[i]->PreProfileInit(); |
| 1044 | |
| 1045 #if !defined(OS_ANDROID) | |
| 1046 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 1047 | |
| 1048 // First check if any ephemeral profiles are left behind because of browser | |
| 1049 // crash and schedule them for deletion and then proceed with getting the set | |
| 1050 // of profiles to open. | |
| 1051 ProfileInfoCache& profile_cache = profile_manager->GetProfileInfoCache(); | |
| 1052 size_t profiles_count = profile_cache.GetNumberOfProfiles(); | |
| 1053 std::vector<base::FilePath> profiles_to_delete; | |
| 1054 for (size_t i = 0;i < profiles_count; ++i) { | |
| 1055 if (profile_cache.ProfileIsEphemeralAtIndex(i)) | |
| 1056 profiles_to_delete.push_back(profile_cache.GetPathOfProfileAtIndex(i)); | |
| 1057 } | |
| 1058 | |
| 1059 if (profiles_to_delete.size()) { | |
| 1060 for (size_t i = 0;i < profiles_to_delete.size(); ++i) { | |
| 1061 profile_manager->ScheduleProfileForDeletion( | |
| 1062 profiles_to_delete[i], ProfileManager::CreateCallback()); | |
| 1063 } | |
| 1064 // Clean up stale profiles immediately after browser start. | |
| 1065 BrowserThread::PostTask( | |
| 1066 BrowserThread::FILE, FROM_HERE, | |
| 1067 base::Bind(&ProfileManager::CleanUpStaleProfiles, profiles_to_delete)); | |
| 1068 } | |
| 1069 #endif // OS_ANDROID | |
| 1070 } | 1044 } |
| 1071 | 1045 |
| 1072 void ChromeBrowserMainParts::PostProfileInit() { | 1046 void ChromeBrowserMainParts::PostProfileInit() { |
| 1073 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostProfileInit"); | 1047 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostProfileInit"); |
| 1074 LaunchDevToolsHandlerIfNeeded(parsed_command_line()); | 1048 LaunchDevToolsHandlerIfNeeded(parsed_command_line()); |
| 1075 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1049 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 1076 chrome_extra_parts_[i]->PostProfileInit(); | 1050 chrome_extra_parts_[i]->PostProfileInit(); |
| 1077 } | 1051 } |
| 1078 | 1052 |
| 1079 void ChromeBrowserMainParts::PreBrowserStart() { | 1053 void ChromeBrowserMainParts::PreBrowserStart() { |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 chromeos::CrosSettings::Shutdown(); | 1663 chromeos::CrosSettings::Shutdown(); |
| 1690 #endif | 1664 #endif |
| 1691 #endif | 1665 #endif |
| 1692 } | 1666 } |
| 1693 | 1667 |
| 1694 // Public members: | 1668 // Public members: |
| 1695 | 1669 |
| 1696 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1670 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 1697 chrome_extra_parts_.push_back(parts); | 1671 chrome_extra_parts_.push_back(parts); |
| 1698 } | 1672 } |
| OLD | NEW |