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/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_browser_main.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 #if defined(TOUCH_UI) | 194 #if defined(TOUCH_UI) |
195 #include "ui/base/touch/touch_factory.h" | 195 #include "ui/base/touch/touch_factory.h" |
196 #endif | 196 #endif |
197 | 197 |
198 #if defined(USE_X11) | 198 #if defined(USE_X11) |
199 #include "chrome/browser/chrome_browser_main_x11.h" | 199 #include "chrome/browser/chrome_browser_main_x11.h" |
200 #endif | 200 #endif |
201 | 201 |
202 #if defined(USE_AURA) | 202 #if defined(USE_AURA) |
| 203 #include "chrome/browser/chrome_browser_parts_aura.h" |
203 #include "ui/aura/desktop.h" | 204 #include "ui/aura/desktop.h" |
204 #endif | 205 #endif |
205 | 206 |
206 using content::BrowserThread; | 207 using content::BrowserThread; |
207 | 208 |
208 namespace net { | 209 namespace net { |
209 class NetLog; | 210 class NetLog; |
210 } // namespace net | 211 } // namespace net |
211 | 212 |
212 namespace { | 213 namespace { |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 } else { | 552 } else { |
552 if (!parsed_command_line.HasSwitch(switches::kTestName)) { | 553 if (!parsed_command_line.HasSwitch(switches::kTestName)) { |
553 // We did not log in (we crashed or are debugging), so we need to | 554 // We did not log in (we crashed or are debugging), so we need to |
554 // set the user name for sync. | 555 // set the user name for sync. |
555 chromeos::LoginUtils::Get()->RestoreAuthenticationSession( | 556 chromeos::LoginUtils::Get()->RestoreAuthenticationSession( |
556 chromeos::UserManager::Get()->logged_in_user().email(), profile); | 557 chromeos::UserManager::Get()->logged_in_user().email(), profile); |
557 } | 558 } |
558 } | 559 } |
559 } | 560 } |
560 | 561 |
561 #else | |
562 | |
563 void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line, | |
564 Profile* profile) { | |
565 // Dummy empty function for non-ChromeOS builds to avoid extra ifdefs below. | |
566 } | |
567 | |
568 #endif // defined(OS_CHROMEOS) | 562 #endif // defined(OS_CHROMEOS) |
569 | 563 |
570 #if defined(OS_MACOSX) | 564 #if defined(OS_MACOSX) |
571 OSStatus KeychainCallback(SecKeychainEvent keychain_event, | 565 OSStatus KeychainCallback(SecKeychainEvent keychain_event, |
572 SecKeychainCallbackInfo *info, void *context) { | 566 SecKeychainCallbackInfo *info, void *context) { |
573 return noErr; | 567 return noErr; |
574 } | 568 } |
575 #endif | 569 #endif |
576 | 570 |
577 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) | 571 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 NOTREACHED(); | 1492 NOTREACHED(); |
1499 } | 1493 } |
1500 #if !defined(OS_MACOSX) // closing brace for if | 1494 #if !defined(OS_MACOSX) // closing brace for if |
1501 } | 1495 } |
1502 #endif | 1496 #endif |
1503 | 1497 |
1504 #if defined(USE_X11) | 1498 #if defined(USE_X11) |
1505 SetBrowserX11ErrorHandlers(); | 1499 SetBrowserX11ErrorHandlers(); |
1506 #endif | 1500 #endif |
1507 | 1501 |
| 1502 // TODO(stevenjb): Move this into a chrome specific stage. |
| 1503 #if defined(USE_AURA) |
| 1504 ChromeBrowserPartsAura::SetupDesktop(); |
| 1505 #elif defined(TOOLKIT_VIEWS) |
| 1506 ChromeBrowserPartsViews::SetupDesktop(); |
| 1507 #endif |
| 1508 |
1508 // Profile creation ---------------------------------------------------------- | 1509 // Profile creation ---------------------------------------------------------- |
1509 | 1510 |
1510 #if defined(OS_CHROMEOS) | 1511 #if defined(OS_CHROMEOS) |
1511 // Initialize the screen locker now so that it can receive | 1512 // Initialize the screen locker now so that it can receive |
1512 // LOGIN_USER_CHANGED notification from UserManager. | 1513 // LOGIN_USER_CHANGED notification from UserManager. |
1513 chromeos::ScreenLocker::InitClass(); | 1514 chromeos::ScreenLocker::InitClass(); |
1514 | 1515 |
1515 // This forces the ProfileManager to be created and register for the | 1516 // This forces the ProfileManager to be created and register for the |
1516 // notification it needs to track the logged in user. | 1517 // notification it needs to track the logged in user. |
1517 g_browser_process->profile_manager(); | 1518 g_browser_process->profile_manager(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1563 | 1564 |
1564 #if defined(OS_CHROMEOS) | 1565 #if defined(OS_CHROMEOS) |
1565 // Pass the TokenService pointer to the policy connector so user policy can | 1566 // Pass the TokenService pointer to the policy connector so user policy can |
1566 // grab a token and register with the policy server. | 1567 // grab a token and register with the policy server. |
1567 // TODO(mnissler): Remove once OAuth is the only authentication mechanism. | 1568 // TODO(mnissler): Remove once OAuth is the only authentication mechanism. |
1568 if (parsed_command_line().HasSwitch(switches::kLoginUser) && | 1569 if (parsed_command_line().HasSwitch(switches::kLoginUser) && |
1569 !parsed_command_line().HasSwitch(switches::kLoginPassword)) { | 1570 !parsed_command_line().HasSwitch(switches::kLoginPassword)) { |
1570 g_browser_process->browser_policy_connector()->SetUserPolicyTokenService( | 1571 g_browser_process->browser_policy_connector()->SetUserPolicyTokenService( |
1571 profile_->GetTokenService()); | 1572 profile_->GetTokenService()); |
1572 } | 1573 } |
| 1574 |
| 1575 // Tests should be able to tune login manager before showing it. |
| 1576 // Thus only show login manager in normal (non-testing) mode. |
| 1577 if (!parameters().ui_task) |
| 1578 OptionallyRunChromeOSLoginManager(parsed_command_line(), profile_); |
1573 #endif | 1579 #endif |
1574 | 1580 |
1575 #if !defined(OS_MACOSX) | 1581 #if !defined(OS_MACOSX) |
1576 // Importing other browser settings is done in a browser-like process | 1582 // Importing other browser settings is done in a browser-like process |
1577 // that exits when this task has finished. | 1583 // that exits when this task has finished. |
1578 // TODO(port): Port the Mac's IPC-based implementation to other platforms to | 1584 // TODO(port): Port the Mac's IPC-based implementation to other platforms to |
1579 // replace this implementation. http://crbug.com/22142 | 1585 // replace this implementation. http://crbug.com/22142 |
1580 if (parsed_command_line().HasSwitch(switches::kImport) || | 1586 if (parsed_command_line().HasSwitch(switches::kImport) || |
1581 parsed_command_line().HasSwitch(switches::kImportFromFile)) { | 1587 parsed_command_line().HasSwitch(switches::kImportFromFile)) { |
1582 return FirstRun::ImportNow(profile_, parsed_command_line()); | 1588 return FirstRun::ImportNow(profile_, parsed_command_line()); |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 | 1851 |
1846 run_message_loop_ = true; | 1852 run_message_loop_ = true; |
1847 return content::RESULT_CODE_NORMAL_EXIT; | 1853 return content::RESULT_CODE_NORMAL_EXIT; |
1848 } | 1854 } |
1849 | 1855 |
1850 // Called from MainMessageLoopRun(). | 1856 // Called from MainMessageLoopRun(). |
1851 void ChromeBrowserMainParts::StartBrowserOrUITask() { | 1857 void ChromeBrowserMainParts::StartBrowserOrUITask() { |
1852 // Still initializing, so need to allow IO. | 1858 // Still initializing, so need to allow IO. |
1853 base::ThreadRestrictions::ScopedAllowIO allow_io; | 1859 base::ThreadRestrictions::ScopedAllowIO allow_io; |
1854 | 1860 |
1855 // Set the notification UI manager after any desktop initialization in | |
1856 // PreMainMessageLoopRun() is complete, and before starting the browser. | |
1857 DesktopNotificationServiceFactory::GetForProfile(profile_)->SetUIManager( | |
1858 g_browser_process->notification_ui_manager()); | |
1859 | |
1860 // Tests should be able to tune login manager before showing it. | |
1861 // Thus only show login manager in normal (non-testing) mode. | |
1862 if (!parameters().ui_task) | |
1863 OptionallyRunChromeOSLoginManager(parsed_command_line(), profile_); | |
1864 | |
1865 if (parameters().ui_task) { | 1861 if (parameters().ui_task) { |
1866 // We are in test mode. Run one task and enter the main message loop. | 1862 // We are in test mode. Run one task and enter the main message loop. |
1867 #if defined(OS_MACOSX) | 1863 #if defined(OS_MACOSX) |
1868 if (parameters().autorelease_pool) | 1864 if (parameters().autorelease_pool) |
1869 parameters().autorelease_pool->Recycle(); | 1865 parameters().autorelease_pool->Recycle(); |
1870 #endif | 1866 #endif |
1871 parameters().ui_task->Run(); | 1867 parameters().ui_task->Run(); |
1872 delete parameters().ui_task; | 1868 delete parameters().ui_task; |
1873 run_message_loop_ = false; | 1869 run_message_loop_ = false; |
1874 } else { | 1870 } else { |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2086 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && | 2082 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && |
2087 (pre_read == "0" || pre_read == "1")) { | 2083 (pre_read == "0" || pre_read == "1")) { |
2088 std::string uma_name(name); | 2084 std::string uma_name(name); |
2089 uma_name += "_PreRead"; | 2085 uma_name += "_PreRead"; |
2090 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; | 2086 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
2091 AddPreReadHistogramTime(uma_name.c_str(), time); | 2087 AddPreReadHistogramTime(uma_name.c_str(), time); |
2092 } | 2088 } |
2093 #endif | 2089 #endif |
2094 #endif | 2090 #endif |
2095 } | 2091 } |
OLD | NEW |