| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/browser_main.h" | 5 #include "chrome/browser/browser_main.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 // However, ProcessSingleton needs a real user_data_dir on Mac/Linux, | 343 // However, ProcessSingleton needs a real user_data_dir on Mac/Linux, |
| 344 // so it's better to fail here than fail mysteriously elsewhere. | 344 // so it's better to fail here than fail mysteriously elsewhere. |
| 345 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) | 345 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) |
| 346 << "Must be able to get user data directory!"; | 346 << "Must be able to get user data directory!"; |
| 347 #endif | 347 #endif |
| 348 | 348 |
| 349 ProcessSingleton process_singleton(user_data_dir); | 349 ProcessSingleton process_singleton(user_data_dir); |
| 350 | 350 |
| 351 bool is_first_run = FirstRun::IsChromeFirstRun() || | 351 bool is_first_run = FirstRun::IsChromeFirstRun() || |
| 352 parsed_command_line.HasSwitch(switches::kFirstRun); | 352 parsed_command_line.HasSwitch(switches::kFirstRun); |
| 353 bool first_run_ui_bypass = false; | |
| 354 | 353 |
| 355 scoped_ptr<BrowserProcess> browser_process; | 354 scoped_ptr<BrowserProcess> browser_process; |
| 356 if (parsed_command_line.HasSwitch(switches::kImport)) { | 355 if (parsed_command_line.HasSwitch(switches::kImport)) { |
| 357 // We use different BrowserProcess when importing so no GoogleURLTracker is | 356 // We use different BrowserProcess when importing so no GoogleURLTracker is |
| 358 // instantiated (as it makes a URLRequest and we don't have an IO thread, | 357 // instantiated (as it makes a URLRequest and we don't have an IO thread, |
| 359 // see bug #1292702). | 358 // see bug #1292702). |
| 360 browser_process.reset(new FirstRunBrowserProcess(parsed_command_line)); | 359 browser_process.reset(new FirstRunBrowserProcess(parsed_command_line)); |
| 361 is_first_run = false; | 360 is_first_run = false; |
| 362 } else { | 361 } else { |
| 363 browser_process.reset(new BrowserProcessImpl(parsed_command_line)); | 362 browser_process.reset(new BrowserProcessImpl(parsed_command_line)); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 Upgrade::ShowTryChromeDialog(StringToInt(try_chrome)); | 483 Upgrade::ShowTryChromeDialog(StringToInt(try_chrome)); |
| 485 if (answer == Upgrade::TD_NOT_NOW) | 484 if (answer == Upgrade::TD_NOT_NOW) |
| 486 return ResultCodes::NORMAL_EXIT_EXP1; | 485 return ResultCodes::NORMAL_EXIT_EXP1; |
| 487 if (answer == Upgrade::TD_UNINSTALL_CHROME) | 486 if (answer == Upgrade::TD_UNINSTALL_CHROME) |
| 488 return ResultCodes::NORMAL_EXIT_EXP2; | 487 return ResultCodes::NORMAL_EXIT_EXP2; |
| 489 } | 488 } |
| 490 #endif // OS_WIN | 489 #endif // OS_WIN |
| 491 | 490 |
| 492 BrowserInit browser_init; | 491 BrowserInit browser_init; |
| 493 | 492 |
| 493 #if defined(OS_WIN) |
| 494 int rlz_ping_delay = 0; | 494 int rlz_ping_delay = 0; |
| 495 #endif |
| 495 bool homepage_defined = false; | 496 bool homepage_defined = false; |
| 496 int import_items = 0; | 497 int import_items = 0; |
| 497 int dont_import_items = 0; | 498 int dont_import_items = 0; |
| 499 bool first_run_ui_bypass = false; |
| 498 if (is_first_run) { | 500 if (is_first_run) { |
| 501 #if defined(OS_WIN) |
| 499 // On first run, we need to process the master preferences before the | 502 // On first run, we need to process the master preferences before the |
| 500 // browser's profile_manager object is created, but after ResourceBundle | 503 // browser's profile_manager object is created, but after ResourceBundle |
| 501 // is initialized. | 504 // is initialized. |
| 502 std::vector<std::wstring> first_run_tabs; | 505 std::vector<std::wstring> first_run_tabs; |
| 503 first_run_ui_bypass = !FirstRun::ProcessMasterPreferences(user_data_dir, | 506 first_run_ui_bypass = !FirstRun::ProcessMasterPreferences(user_data_dir, |
| 504 FilePath(), &first_run_tabs, &rlz_ping_delay, &homepage_defined, | 507 FilePath(), &first_run_tabs, &rlz_ping_delay, &homepage_defined, |
| 505 &import_items, &dont_import_items); | 508 &import_items, &dont_import_items); |
| 506 // The master prefs might specify a set of urls to display. | 509 // The master prefs might specify a set of urls to display. |
| 507 if (first_run_tabs.size()) | 510 if (first_run_tabs.size()) |
| 508 AddFirstRunNewTabs(&browser_init, first_run_tabs); | 511 AddFirstRunNewTabs(&browser_init, first_run_tabs); |
| 512 #endif // OS_WIN |
| 509 | 513 |
| 510 // If we are running in App mode, we do not want to show the importer | 514 // If we are running in App mode, we do not want to show the importer |
| 511 // (first run) UI. | 515 // (first run) UI. |
| 512 if (!first_run_ui_bypass && | 516 if (!first_run_ui_bypass && |
| 513 (parsed_command_line.HasSwitch(switches::kApp) || | 517 (parsed_command_line.HasSwitch(switches::kApp) || |
| 514 parsed_command_line.HasSwitch(switches::kNoFirstRun))) { | 518 parsed_command_line.HasSwitch(switches::kNoFirstRun))) { |
| 515 first_run_ui_bypass = true; | 519 first_run_ui_bypass = true; |
| 516 } | 520 } |
| 517 } | 521 } |
| 518 | 522 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 } else if (parsed_command_line.HasSwitch(switches::kMakeDefaultBrowser)) { | 635 } else if (parsed_command_line.HasSwitch(switches::kMakeDefaultBrowser)) { |
| 632 if (ShellIntegration::SetAsDefaultBrowser()) { | 636 if (ShellIntegration::SetAsDefaultBrowser()) { |
| 633 return ResultCodes::NORMAL_EXIT; | 637 return ResultCodes::NORMAL_EXIT; |
| 634 } else { | 638 } else { |
| 635 return ResultCodes::SHELL_INTEGRATION_FAILED; | 639 return ResultCodes::SHELL_INTEGRATION_FAILED; |
| 636 } | 640 } |
| 637 } | 641 } |
| 638 | 642 |
| 639 // Importing other browser settings is done in a browser-like process | 643 // Importing other browser settings is done in a browser-like process |
| 640 // that exits when this task has finished. | 644 // that exits when this task has finished. |
| 645 #if defined(OS_WIN) |
| 641 if (parsed_command_line.HasSwitch(switches::kImport)) | 646 if (parsed_command_line.HasSwitch(switches::kImport)) |
| 642 return FirstRun::ImportNow(profile, parsed_command_line); | 647 return FirstRun::ImportNow(profile, parsed_command_line); |
| 648 #endif |
| 643 | 649 |
| 644 // When another process is running, use it instead of starting us. | 650 // When another process is running, use it instead of starting us. |
| 645 switch (process_singleton.NotifyOtherProcess()) { | 651 switch (process_singleton.NotifyOtherProcess()) { |
| 646 case ProcessSingleton::PROCESS_NONE: | 652 case ProcessSingleton::PROCESS_NONE: |
| 647 // No process already running, fall through to starting a new one. | 653 // No process already running, fall through to starting a new one. |
| 648 break; | 654 break; |
| 649 | 655 |
| 650 case ProcessSingleton::PROCESS_NOTIFIED: | 656 case ProcessSingleton::PROCESS_NOTIFIED: |
| 651 #if defined(OS_LINUX) | 657 #if defined(OS_LINUX) |
| 652 printf("%s\n", base::SysWideToNativeMB( | 658 printf("%s\n", base::SysWideToNativeMB( |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 if (metrics) | 898 if (metrics) |
| 893 metrics->Stop(); | 899 metrics->Stop(); |
| 894 | 900 |
| 895 // browser_shutdown takes care of deleting browser_process, so we need to | 901 // browser_shutdown takes care of deleting browser_process, so we need to |
| 896 // release it. | 902 // release it. |
| 897 browser_process.release(); | 903 browser_process.release(); |
| 898 browser_shutdown::Shutdown(); | 904 browser_shutdown::Shutdown(); |
| 899 | 905 |
| 900 return result_code; | 906 return result_code; |
| 901 } | 907 } |
| OLD | NEW |