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 PrefService* prefs = g_browser_process->local_state(); | |
jam
2012/04/04 00:44:44
nit: this isn't used
erikwright (departed)
2012/04/04 02:51:48
This is migrated here from process_singleton_linux
erikwright (departed)
2012/04/04 14:51:28
Actually, it was in both the linux and windows ver
| |
549 DCHECK(prefs); | |
550 | |
551 // Handle the --uninstall-extension startup action. This needs to done here | |
552 // in the process that is running with the target profile, otherwise the | |
553 // uninstall will fail to unload and remove all components. | |
554 if (command_line.HasSwitch(switches::kUninstallExtension)) { | |
555 // The uninstall extension switch can't be combined with the profile | |
556 // directory switch. | |
557 DCHECK(!command_line.HasSwitch(switches::kProfileDirectory)); | |
558 | |
559 Profile* profile = ProfileManager::GetLastUsedProfile(); | |
560 if (!profile) { | |
561 // We should only be able to get here if the profile already exists and | |
562 // has been created. | |
robertshield
2012/04/04 01:07:15
I'm curious about this comment: does the profile a
erikwright (departed)
2012/04/04 02:51:48
This comment may be misleading. I believe "here" r
| |
563 NOTREACHED(); | |
564 return true; | |
565 } | |
566 | |
567 ExtensionsStartupUtil ext_startup_util; | |
568 ext_startup_util.UninstallExtension(command_line, profile); | |
569 return true; | |
570 } | |
571 | |
572 // Ignore the request if the process was passed the --product-version flag. | |
573 // Normally we wouldn't get here if that flag had been passed, but it can | |
574 // happen if it is passed to an older version of chrome. Since newer versions | |
575 // of chrome do this in the background, we want to avoid spawning extra | |
576 // windows. | |
577 if (command_line.HasSwitch(switches::kProductVersion)) { | |
578 DLOG(WARNING) << "Remote process was passed product version flag, " | |
579 << "but ignored it. Doing nothing."; | |
580 return true; | |
581 } | |
582 | |
583 BrowserInit::ProcessCommandLineAlreadyRunning( | |
584 command_line, current_directory); | |
585 return true; | |
586 } | |
587 | |
541 } // namespace | 588 } // namespace |
542 | 589 |
543 namespace chrome_browser { | 590 namespace chrome_browser { |
544 // This error message is not localized because we failed to load the | 591 // This error message is not localized because we failed to load the |
545 // localization data files. | 592 // localization data files. |
546 const char kMissingLocaleDataTitle[] = "Missing File Error"; | 593 const char kMissingLocaleDataTitle[] = "Missing File Error"; |
547 const char kMissingLocaleDataMessage[] = | 594 const char kMissingLocaleDataMessage[] = |
548 "Unable to find locale data files. Please reinstall."; | 595 "Unable to find locale data files. Please reinstall."; |
549 } // namespace chrome_browser | 596 } // namespace chrome_browser |
550 | 597 |
(...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" | 1505 // from other browsers. In case this process is a short-lived "import" |
1459 // process that another browser runs just to import the settings, we | 1506 // process that another browser runs just to import the settings, we |
1460 // don't want to be checking for another browser process, by design. | 1507 // don't want to be checking for another browser process, by design. |
1461 if (!(parsed_command_line().HasSwitch(switches::kImport) || | 1508 if (!(parsed_command_line().HasSwitch(switches::kImport) || |
1462 parsed_command_line().HasSwitch(switches::kImportFromFile))) { | 1509 parsed_command_line().HasSwitch(switches::kImportFromFile))) { |
1463 #endif | 1510 #endif |
1464 // When another process is running, use that process instead of starting a | 1511 // When another process is running, use that process instead of starting a |
1465 // new one. NotifyOtherProcess will currently give the other process up to | 1512 // 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 | 1513 // 20 seconds to respond. Note that this needs to be done before we attempt |
1467 // to read the profile. | 1514 // to read the profile. |
1468 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); | 1515 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate( |
1516 base::Bind(&ProcessSingletonNotificationCallback)); | |
1469 switch (notify_result_) { | 1517 switch (notify_result_) { |
1470 case ProcessSingleton::PROCESS_NONE: | 1518 case ProcessSingleton::PROCESS_NONE: |
1471 // No process already running, fall through to starting a new one. | 1519 // No process already running, fall through to starting a new one. |
1472 break; | 1520 break; |
1473 | 1521 |
1474 case ProcessSingleton::PROCESS_NOTIFIED: | 1522 case ProcessSingleton::PROCESS_NOTIFIED: |
1475 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 1523 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
1476 printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( | 1524 printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( |
1477 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); | 1525 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); |
1478 #endif | 1526 #endif |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1963 if (base::win::GetVersion() <= base::win::VERSION_XP) | 2011 if (base::win::GetVersion() <= base::win::VERSION_XP) |
1964 uma_name += "_XP"; | 2012 uma_name += "_XP"; |
1965 | 2013 |
1966 uma_name += "_PreRead_"; | 2014 uma_name += "_PreRead_"; |
1967 uma_name += pre_read_percentage; | 2015 uma_name += pre_read_percentage; |
1968 AddPreReadHistogramTime(uma_name.c_str(), time); | 2016 AddPreReadHistogramTime(uma_name.c_str(), time); |
1969 } | 2017 } |
1970 #endif | 2018 #endif |
1971 #endif | 2019 #endif |
1972 } | 2020 } |
OLD | NEW |