| 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 13 matching lines...) Expand all Loading... |
| 24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
| 25 #include "base/sys_string_conversions.h" | 25 #include "base/sys_string_conversions.h" |
| 26 #include "base/threading/platform_thread.h" | 26 #include "base/threading/platform_thread.h" |
| 27 #include "base/time.h" | 27 #include "base/time.h" |
| 28 #include "base/utf_string_conversions.h" | 28 #include "base/utf_string_conversions.h" |
| 29 #include "base/values.h" | 29 #include "base/values.h" |
| 30 #include "build/build_config.h" | 30 #include "build/build_config.h" |
| 31 #include "chrome/browser/about_flags.h" | 31 #include "chrome/browser/about_flags.h" |
| 32 #include "chrome/browser/auto_launch_trial.h" | 32 #include "chrome/browser/auto_launch_trial.h" |
| 33 #include "chrome/browser/autocomplete/autocomplete_field_trial.h" | 33 #include "chrome/browser/autocomplete/autocomplete_field_trial.h" |
| 34 #include "chrome/browser/browser_process.h" |
| 34 #include "chrome/browser/browser_process_impl.h" | 35 #include "chrome/browser/browser_process_impl.h" |
| 35 #include "chrome/browser/browser_shutdown.h" | 36 #include "chrome/browser/browser_shutdown.h" |
| 36 #include "chrome/browser/chrome_browser_main_extra_parts.h" | 37 #include "chrome/browser/chrome_browser_main_extra_parts.h" |
| 37 #include "chrome/browser/defaults.h" | 38 #include "chrome/browser/defaults.h" |
| 38 #include "chrome/browser/extensions/default_apps_trial.h" | 39 #include "chrome/browser/extensions/default_apps_trial.h" |
| 39 #include "chrome/browser/extensions/extension_protocols.h" | 40 #include "chrome/browser/extensions/extension_protocols.h" |
| 40 #include "chrome/browser/extensions/extension_service.h" | 41 #include "chrome/browser/extensions/extension_service.h" |
| 41 #include "chrome/browser/extensions/extensions_startup.h" | 42 #include "chrome/browser/extensions/extensions_startup.h" |
| 42 #include "chrome/browser/first_run/upgrade_util.h" | 43 #include "chrome/browser/first_run/upgrade_util.h" |
| 43 #include "chrome/browser/google/google_search_counter.h" | 44 #include "chrome/browser/google/google_search_counter.h" |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 static const size_t kBuckets(100); | 532 static const size_t kBuckets(100); |
| 532 | 533 |
| 533 // FactoryTimeGet will always return a pointer to the same histogram object, | 534 // FactoryTimeGet will always return a pointer to the same histogram object, |
| 534 // keyed on its name. There's no need for us to store it explicitly anywhere. | 535 // keyed on its name. There's no need for us to store it explicitly anywhere. |
| 535 base::Histogram* counter = base::Histogram::FactoryTimeGet( | 536 base::Histogram* counter = base::Histogram::FactoryTimeGet( |
| 536 name, kMin, kMax, kBuckets, base::Histogram::kUmaTargetedHistogramFlag); | 537 name, kMin, kMax, kBuckets, base::Histogram::kUmaTargetedHistogramFlag); |
| 537 | 538 |
| 538 counter->AddTime(time); | 539 counter->AddTime(time); |
| 539 } | 540 } |
| 540 | 541 |
| 542 bool ProcessSingletonNotificationCallback(const CommandLine& command_line, |
| 543 const FilePath& current_directory) { |
| 544 // Drop the request if the browser process is already in shutdown path. |
| 545 if (!g_browser_process || g_browser_process->IsShuttingDown()) |
| 546 return false; |
| 547 |
| 548 // TODO(erikwright): Consider removing this - AFAIK it is no longer used. |
| 549 // Handle the --uninstall-extension startup action. This needs to done here |
| 550 // in the process that is running with the target profile, otherwise the |
| 551 // uninstall will fail to unload and remove all components. |
| 552 if (command_line.HasSwitch(switches::kUninstallExtension)) { |
| 553 // The uninstall extension switch can't be combined with the profile |
| 554 // directory switch. |
| 555 DCHECK(!command_line.HasSwitch(switches::kProfileDirectory)); |
| 556 |
| 557 Profile* profile = ProfileManager::GetLastUsedProfile(); |
| 558 if (!profile) { |
| 559 // We should never be called before the profile has been created. |
| 560 NOTREACHED(); |
| 561 return true; |
| 562 } |
| 563 |
| 564 ExtensionsStartupUtil ext_startup_util; |
| 565 ext_startup_util.UninstallExtension(command_line, profile); |
| 566 return true; |
| 567 } |
| 568 |
| 569 BrowserInit::ProcessCommandLineAlreadyRunning( |
| 570 command_line, current_directory); |
| 571 return true; |
| 572 } |
| 573 |
| 541 } // namespace | 574 } // namespace |
| 542 | 575 |
| 543 namespace chrome_browser { | 576 namespace chrome_browser { |
| 544 // This error message is not localized because we failed to load the | 577 // This error message is not localized because we failed to load the |
| 545 // localization data files. | 578 // localization data files. |
| 546 const char kMissingLocaleDataTitle[] = "Missing File Error"; | 579 const char kMissingLocaleDataTitle[] = "Missing File Error"; |
| 547 const char kMissingLocaleDataMessage[] = | 580 const char kMissingLocaleDataMessage[] = |
| 548 "Unable to find locale data files. Please reinstall."; | 581 "Unable to find locale data files. Please reinstall."; |
| 549 } // namespace chrome_browser | 582 } // namespace chrome_browser |
| 550 | 583 |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 // from other browsers. In case this process is a short-lived "import" | 1491 // from other browsers. In case this process is a short-lived "import" |
| 1459 // process that another browser runs just to import the settings, we | 1492 // process that another browser runs just to import the settings, we |
| 1460 // don't want to be checking for another browser process, by design. | 1493 // don't want to be checking for another browser process, by design. |
| 1461 if (!(parsed_command_line().HasSwitch(switches::kImport) || | 1494 if (!(parsed_command_line().HasSwitch(switches::kImport) || |
| 1462 parsed_command_line().HasSwitch(switches::kImportFromFile))) { | 1495 parsed_command_line().HasSwitch(switches::kImportFromFile))) { |
| 1463 #endif | 1496 #endif |
| 1464 // When another process is running, use that process instead of starting a | 1497 // When another process is running, use that process instead of starting a |
| 1465 // new one. NotifyOtherProcess will currently give the other process up to | 1498 // new one. NotifyOtherProcess will currently give the other process up to |
| 1466 // 20 seconds to respond. Note that this needs to be done before we attempt | 1499 // 20 seconds to respond. Note that this needs to be done before we attempt |
| 1467 // to read the profile. | 1500 // to read the profile. |
| 1468 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); | 1501 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate( |
| 1502 base::Bind(&ProcessSingletonNotificationCallback)); |
| 1469 switch (notify_result_) { | 1503 switch (notify_result_) { |
| 1470 case ProcessSingleton::PROCESS_NONE: | 1504 case ProcessSingleton::PROCESS_NONE: |
| 1471 // No process already running, fall through to starting a new one. | 1505 // No process already running, fall through to starting a new one. |
| 1472 break; | 1506 break; |
| 1473 | 1507 |
| 1474 case ProcessSingleton::PROCESS_NOTIFIED: | 1508 case ProcessSingleton::PROCESS_NOTIFIED: |
| 1475 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 1509 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 1476 printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( | 1510 printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( |
| 1477 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); | 1511 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); |
| 1478 #endif | 1512 #endif |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1963 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1997 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 1964 uma_name += "_XP"; | 1998 uma_name += "_XP"; |
| 1965 | 1999 |
| 1966 uma_name += "_PreRead_"; | 2000 uma_name += "_PreRead_"; |
| 1967 uma_name += pre_read_percentage; | 2001 uma_name += pre_read_percentage; |
| 1968 AddPreReadHistogramTime(uma_name.c_str(), time); | 2002 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 1969 } | 2003 } |
| 1970 #endif | 2004 #endif |
| 1971 #endif | 2005 #endif |
| 1972 } | 2006 } |
| OLD | NEW |