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 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 | 1502 |
1503 // If the command line specifies --pack-extension, attempt the pack extension | 1503 // If the command line specifies --pack-extension, attempt the pack extension |
1504 // startup action and exit. | 1504 // startup action and exit. |
1505 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { | 1505 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { |
1506 ExtensionsStartupUtil extension_startup_util; | 1506 ExtensionsStartupUtil extension_startup_util; |
1507 if (extension_startup_util.PackExtension(parsed_command_line())) | 1507 if (extension_startup_util.PackExtension(parsed_command_line())) |
1508 return content::RESULT_CODE_NORMAL_EXIT; | 1508 return content::RESULT_CODE_NORMAL_EXIT; |
1509 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; | 1509 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; |
1510 } | 1510 } |
1511 | 1511 |
| 1512 bool pass_command_line = true; |
| 1513 |
1512 #if !defined(OS_MACOSX) | 1514 #if !defined(OS_MACOSX) |
1513 // In environments other than Mac OS X we support import of settings | 1515 // In environments other than Mac OS X we support import of settings |
1514 // from other browsers. In case this process is a short-lived "import" | 1516 // from other browsers. In case this process is a short-lived "import" |
1515 // process that another browser runs just to import the settings, we | 1517 // process that another browser runs just to import the settings, we |
1516 // don't want to be checking for another browser process, by design. | 1518 // don't want to be checking for another browser process, by design. |
1517 if (!HasImportSwitch(parsed_command_line())) { | 1519 pass_command_line = !HasImportSwitch(parsed_command_line()); |
1518 #endif | 1520 #endif |
| 1521 |
| 1522 // If we're being launched just to check the connector policy, we are |
| 1523 // short-lived and don't want to be passing that switch off. |
| 1524 pass_command_line = pass_command_line && !parsed_command_line().HasSwitch( |
| 1525 switches::kCheckCloudPrintConnectorPolicy); |
| 1526 |
| 1527 if (pass_command_line) { |
1519 // When another process is running, use that process instead of starting a | 1528 // When another process is running, use that process instead of starting a |
1520 // new one. NotifyOtherProcess will currently give the other process up to | 1529 // new one. NotifyOtherProcess will currently give the other process up to |
1521 // 20 seconds to respond. Note that this needs to be done before we attempt | 1530 // 20 seconds to respond. Note that this needs to be done before we attempt |
1522 // to read the profile. | 1531 // to read the profile. |
1523 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate( | 1532 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate( |
1524 base::Bind(&ProcessSingletonNotificationCallback)); | 1533 base::Bind(&ProcessSingletonNotificationCallback)); |
1525 switch (notify_result_) { | 1534 switch (notify_result_) { |
1526 case ProcessSingleton::PROCESS_NONE: | 1535 case ProcessSingleton::PROCESS_NONE: |
1527 // No process already running, fall through to starting a new one. | 1536 // No process already running, fall through to starting a new one. |
1528 break; | 1537 break; |
1529 | 1538 |
1530 case ProcessSingleton::PROCESS_NOTIFIED: | 1539 case ProcessSingleton::PROCESS_NOTIFIED: |
1531 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 1540 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
1532 printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( | 1541 printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( |
1533 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); | 1542 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); |
1534 #endif | 1543 #endif |
1535 return content::RESULT_CODE_NORMAL_EXIT; | 1544 return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED; |
1536 | 1545 |
1537 case ProcessSingleton::PROFILE_IN_USE: | 1546 case ProcessSingleton::PROFILE_IN_USE: |
1538 return chrome::RESULT_CODE_PROFILE_IN_USE; | 1547 return chrome::RESULT_CODE_PROFILE_IN_USE; |
1539 | 1548 |
1540 case ProcessSingleton::LOCK_ERROR: | 1549 case ProcessSingleton::LOCK_ERROR: |
1541 LOG(ERROR) << "Failed to create a ProcessSingleton for your profile " | 1550 LOG(ERROR) << "Failed to create a ProcessSingleton for your profile " |
1542 "directory. This means that running multiple instances " | 1551 "directory. This means that running multiple instances " |
1543 "would start multiple browser processes rather than " | 1552 "would start multiple browser processes rather than " |
1544 "opening a new window in the existing process. Aborting " | 1553 "opening a new window in the existing process. Aborting " |
1545 "now to avoid profile corruption."; | 1554 "now to avoid profile corruption."; |
1546 return chrome::RESULT_CODE_PROFILE_IN_USE; | 1555 return chrome::RESULT_CODE_PROFILE_IN_USE; |
1547 | 1556 |
1548 default: | 1557 default: |
1549 NOTREACHED(); | 1558 NOTREACHED(); |
1550 } | 1559 } |
1551 #if !defined(OS_MACOSX) // closing brace for if | |
1552 } | 1560 } |
1553 #endif | |
1554 | 1561 |
1555 #if defined(USE_X11) | 1562 #if defined(USE_X11) |
1556 SetBrowserX11ErrorHandlers(); | 1563 SetBrowserX11ErrorHandlers(); |
1557 #endif | 1564 #endif |
1558 | 1565 |
1559 // Desktop construction occurs here, (required before profile creation). | 1566 // Desktop construction occurs here, (required before profile creation). |
1560 PreProfileInit(); | 1567 PreProfileInit(); |
1561 | 1568 |
1562 // Profile creation ---------------------------------------------------------- | 1569 // Profile creation ---------------------------------------------------------- |
1563 | 1570 |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2028 if (base::win::GetVersion() <= base::win::VERSION_XP) | 2035 if (base::win::GetVersion() <= base::win::VERSION_XP) |
2029 uma_name += "_XP"; | 2036 uma_name += "_XP"; |
2030 | 2037 |
2031 uma_name += "_PreRead_"; | 2038 uma_name += "_PreRead_"; |
2032 uma_name += pre_read_percentage; | 2039 uma_name += pre_read_percentage; |
2033 AddPreReadHistogramTime(uma_name.c_str(), time); | 2040 AddPreReadHistogramTime(uma_name.c_str(), time); |
2034 } | 2041 } |
2035 #endif | 2042 #endif |
2036 #endif | 2043 #endif |
2037 } | 2044 } |
OLD | NEW |