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 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 | 1548 |
1549 // If the command line specifies --pack-extension, attempt the pack extension | 1549 // If the command line specifies --pack-extension, attempt the pack extension |
1550 // startup action and exit. | 1550 // startup action and exit. |
1551 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { | 1551 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { |
1552 ExtensionsStartupUtil extension_startup_util; | 1552 ExtensionsStartupUtil extension_startup_util; |
1553 if (extension_startup_util.PackExtension(parsed_command_line())) | 1553 if (extension_startup_util.PackExtension(parsed_command_line())) |
1554 return content::RESULT_CODE_NORMAL_EXIT; | 1554 return content::RESULT_CODE_NORMAL_EXIT; |
1555 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; | 1555 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; |
1556 } | 1556 } |
1557 | 1557 |
| 1558 bool pass_command_line = true; |
| 1559 |
1558 #if !defined(OS_MACOSX) | 1560 #if !defined(OS_MACOSX) |
1559 // In environments other than Mac OS X we support import of settings | 1561 // In environments other than Mac OS X we support import of settings |
1560 // from other browsers. In case this process is a short-lived "import" | 1562 // from other browsers. In case this process is a short-lived "import" |
1561 // process that another browser runs just to import the settings, we | 1563 // process that another browser runs just to import the settings, we |
1562 // don't want to be checking for another browser process, by design. | 1564 // don't want to be checking for another browser process, by design. |
1563 if (!HasImportSwitch(parsed_command_line())) { | 1565 pass_command_line = !HasImportSwitch(parsed_command_line()); |
1564 #endif | 1566 #endif |
| 1567 |
| 1568 // If we're being launched just to check the connector policy, we are |
| 1569 // short-lived and don't want to be passing that switch off. |
| 1570 pass_command_line = pass_command_line && !parsed_command_line().HasSwitch( |
| 1571 switches::kCheckCloudPrintConnectorPolicy); |
| 1572 |
| 1573 if (pass_command_line) { |
1565 // When another process is running, use that process instead of starting a | 1574 // When another process is running, use that process instead of starting a |
1566 // new one. NotifyOtherProcess will currently give the other process up to | 1575 // new one. NotifyOtherProcess will currently give the other process up to |
1567 // 20 seconds to respond. Note that this needs to be done before we attempt | 1576 // 20 seconds to respond. Note that this needs to be done before we attempt |
1568 // to read the profile. | 1577 // to read the profile. |
1569 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate( | 1578 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate( |
1570 base::Bind(&ProcessSingletonNotificationCallback)); | 1579 base::Bind(&ProcessSingletonNotificationCallback)); |
1571 switch (notify_result_) { | 1580 switch (notify_result_) { |
1572 case ProcessSingleton::PROCESS_NONE: | 1581 case ProcessSingleton::PROCESS_NONE: |
1573 // No process already running, fall through to starting a new one. | 1582 // No process already running, fall through to starting a new one. |
1574 break; | 1583 break; |
1575 | 1584 |
1576 case ProcessSingleton::PROCESS_NOTIFIED: | 1585 case ProcessSingleton::PROCESS_NOTIFIED: |
1577 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 1586 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
1578 printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( | 1587 printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( |
1579 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); | 1588 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); |
1580 #endif | 1589 #endif |
1581 return content::RESULT_CODE_NORMAL_EXIT; | 1590 return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED; |
1582 | 1591 |
1583 case ProcessSingleton::PROFILE_IN_USE: | 1592 case ProcessSingleton::PROFILE_IN_USE: |
1584 return chrome::RESULT_CODE_PROFILE_IN_USE; | 1593 return chrome::RESULT_CODE_PROFILE_IN_USE; |
1585 | 1594 |
1586 case ProcessSingleton::LOCK_ERROR: | 1595 case ProcessSingleton::LOCK_ERROR: |
1587 LOG(ERROR) << "Failed to create a ProcessSingleton for your profile " | 1596 LOG(ERROR) << "Failed to create a ProcessSingleton for your profile " |
1588 "directory. This means that running multiple instances " | 1597 "directory. This means that running multiple instances " |
1589 "would start multiple browser processes rather than " | 1598 "would start multiple browser processes rather than " |
1590 "opening a new window in the existing process. Aborting " | 1599 "opening a new window in the existing process. Aborting " |
1591 "now to avoid profile corruption."; | 1600 "now to avoid profile corruption."; |
1592 return chrome::RESULT_CODE_PROFILE_IN_USE; | 1601 return chrome::RESULT_CODE_PROFILE_IN_USE; |
1593 | 1602 |
1594 default: | 1603 default: |
1595 NOTREACHED(); | 1604 NOTREACHED(); |
1596 } | 1605 } |
1597 #if !defined(OS_MACOSX) // closing brace for if | |
1598 } | 1606 } |
1599 #endif | |
1600 | 1607 |
1601 #if defined(USE_X11) | 1608 #if defined(USE_X11) |
1602 SetBrowserX11ErrorHandlers(); | 1609 SetBrowserX11ErrorHandlers(); |
1603 #endif | 1610 #endif |
1604 | 1611 |
1605 // Desktop construction occurs here, (required before profile creation). | 1612 // Desktop construction occurs here, (required before profile creation). |
1606 PreProfileInit(); | 1613 PreProfileInit(); |
1607 | 1614 |
1608 // Profile creation ---------------------------------------------------------- | 1615 // Profile creation ---------------------------------------------------------- |
1609 | 1616 |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 if (base::win::GetVersion() <= base::win::VERSION_XP) | 2086 if (base::win::GetVersion() <= base::win::VERSION_XP) |
2080 uma_name += "_XP"; | 2087 uma_name += "_XP"; |
2081 | 2088 |
2082 uma_name += "_PreRead_"; | 2089 uma_name += "_PreRead_"; |
2083 uma_name += pre_read_percentage; | 2090 uma_name += pre_read_percentage; |
2084 AddPreReadHistogramTime(uma_name.c_str(), time); | 2091 AddPreReadHistogramTime(uma_name.c_str(), time); |
2085 } | 2092 } |
2086 #endif | 2093 #endif |
2087 #endif | 2094 #endif |
2088 } | 2095 } |
OLD | NEW |