Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 145023015: Introduce TranslateService and TranslateDownloadManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unittest Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #if defined(TOOLKIT_GTK) 7 #if defined(TOOLKIT_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" 85 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
86 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" 86 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h"
87 #include "chrome/browser/process_singleton.h" 87 #include "chrome/browser/process_singleton.h"
88 #include "chrome/browser/profiles/profile.h" 88 #include "chrome/browser/profiles/profile.h"
89 #include "chrome/browser/profiles/profile_impl.h" 89 #include "chrome/browser/profiles/profile_impl.h"
90 #include "chrome/browser/profiles/profile_manager.h" 90 #include "chrome/browser/profiles/profile_manager.h"
91 #include "chrome/browser/profiles/profiles_state.h" 91 #include "chrome/browser/profiles/profiles_state.h"
92 #include "chrome/browser/shell_integration.h" 92 #include "chrome/browser/shell_integration.h"
93 #include "chrome/browser/three_d_api_observer.h" 93 #include "chrome/browser/three_d_api_observer.h"
94 #include "chrome/browser/translate/translate_manager.h" 94 #include "chrome/browser/translate/translate_manager.h"
95 #include "chrome/browser/translate/translate_service.h"
95 #include "chrome/browser/ui/app_list/app_list_service.h" 96 #include "chrome/browser/ui/app_list/app_list_service.h"
96 #include "chrome/browser/ui/browser.h" 97 #include "chrome/browser/ui/browser.h"
97 #include "chrome/browser/ui/browser_finder.h" 98 #include "chrome/browser/ui/browser_finder.h"
98 #include "chrome/browser/ui/host_desktop.h" 99 #include "chrome/browser/ui/host_desktop.h"
99 #include "chrome/browser/ui/startup/default_browser_prompt.h" 100 #include "chrome/browser/ui/startup/default_browser_prompt.h"
100 #include "chrome/browser/ui/startup/startup_browser_creator.h" 101 #include "chrome/browser/ui/startup/startup_browser_creator.h"
101 #include "chrome/browser/ui/uma_browsing_activity_observer.h" 102 #include "chrome/browser/ui/uma_browsing_activity_observer.h"
102 #include "chrome/browser/ui/user_data_dir_dialog.h" 103 #include "chrome/browser/ui/user_data_dir_dialog.h"
103 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" 104 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
104 #include "chrome/browser/user_data_dir_extractor.h" 105 #include "chrome/browser/user_data_dir_extractor.h"
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 540
540 ChromeBrowserMainParts::ChromeBrowserMainParts( 541 ChromeBrowserMainParts::ChromeBrowserMainParts(
541 const content::MainFunctionParams& parameters) 542 const content::MainFunctionParams& parameters)
542 : parameters_(parameters), 543 : parameters_(parameters),
543 parsed_command_line_(parameters.command_line), 544 parsed_command_line_(parameters.command_line),
544 result_code_(content::RESULT_CODE_NORMAL_EXIT), 545 result_code_(content::RESULT_CODE_NORMAL_EXIT),
545 startup_watcher_(new StartupTimeBomb()), 546 startup_watcher_(new StartupTimeBomb()),
546 shutdown_watcher_(new ShutdownWatcherHelper()), 547 shutdown_watcher_(new ShutdownWatcherHelper()),
547 startup_timer_(new performance_monitor::StartupTimer()), 548 startup_timer_(new performance_monitor::StartupTimer()),
548 browser_field_trials_(parameters.command_line), 549 browser_field_trials_(parameters.command_line),
549 translate_manager_(NULL),
550 profile_(NULL), 550 profile_(NULL),
551 run_message_loop_(true), 551 run_message_loop_(true),
552 notify_result_(ProcessSingleton::PROCESS_NONE), 552 notify_result_(ProcessSingleton::PROCESS_NONE),
553 local_state_(NULL), 553 local_state_(NULL),
554 restart_last_session_(false) { 554 restart_last_session_(false) {
555 // If we're running tests (ui_task is non-null). 555 // If we're running tests (ui_task is non-null).
556 if (parameters.ui_task) 556 if (parameters.ui_task)
557 browser_defaults::enable_help_app = false; 557 browser_defaults::enable_help_app = false;
558 558
559 // Chrome disallows cookies by default. All code paths that want to use 559 // Chrome disallows cookies by default. All code paths that want to use
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 // machine. If yes and the current Chrome process is user level, we do not 1270 // machine. If yes and the current Chrome process is user level, we do not
1271 // allow the user level Chrome to run. So we notify the user and uninstall 1271 // allow the user level Chrome to run. So we notify the user and uninstall
1272 // user level Chrome. 1272 // user level Chrome.
1273 // Note this check should only happen here, after all the checks above 1273 // Note this check should only happen here, after all the checks above
1274 // (uninstall, resource bundle initialization, other chrome browser 1274 // (uninstall, resource bundle initialization, other chrome browser
1275 // processes etc). 1275 // processes etc).
1276 if (ChromeBrowserMainPartsWin::CheckMachineLevelInstall()) 1276 if (ChromeBrowserMainPartsWin::CheckMachineLevelInstall())
1277 return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS; 1277 return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS;
1278 #endif 1278 #endif
1279 1279
1280 // Create the TranslateManager singleton. 1280 TranslateService::Initialize();
1281 translate_manager_ = TranslateManager::GetInstance();
1282 DCHECK(translate_manager_ != NULL);
1283 1281
1284 // Needs to be done before PostProfileInit, since login manager on CrOS is 1282 // Needs to be done before PostProfileInit, since login manager on CrOS is
1285 // called inside PostProfileInit. 1283 // called inside PostProfileInit.
1286 content::WebUIControllerFactory::RegisterFactory( 1284 content::WebUIControllerFactory::RegisterFactory(
1287 ChromeWebUIControllerFactory::GetInstance()); 1285 ChromeWebUIControllerFactory::GetInstance());
1288 1286
1289 // NaClBrowserDelegateImpl is accessed inside PostProfileInit(). 1287 // NaClBrowserDelegateImpl is accessed inside PostProfileInit().
1290 // So make sure to create it before that. 1288 // So make sure to create it before that.
1291 #if !defined(DISABLE_NACL) 1289 #if !defined(DISABLE_NACL)
1292 NaClBrowserDelegateImpl* delegate = new NaClBrowserDelegateImpl( 1290 NaClBrowserDelegateImpl* delegate = new NaClBrowserDelegateImpl(
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 chrome_variations::VariationsService* variations_service = 1551 chrome_variations::VariationsService* variations_service =
1554 browser_process_->variations_service(); 1552 browser_process_->variations_service();
1555 if (variations_service) { 1553 if (variations_service) {
1556 variations_service->StartRepeatedVariationsSeedFetch(); 1554 variations_service->StartRepeatedVariationsSeedFetch();
1557 1555
1558 #if defined(OS_WIN) 1556 #if defined(OS_WIN)
1559 variations_service->StartGoogleUpdateRegistrySync(); 1557 variations_service->StartGoogleUpdateRegistrySync();
1560 #endif 1558 #endif
1561 } 1559 }
1562 1560
1563 if (translate_manager_ != NULL) { 1561 TranslateManager::GetInstance()->FetchLanguageListFromTranslateServer(
1564 translate_manager_->FetchLanguageListFromTranslateServer( 1562 profile_->GetPrefs());
1565 profile_->GetPrefs());
1566 }
1567 } 1563 }
1568 1564
1569 run_message_loop_ = true; 1565 run_message_loop_ = true;
1570 } else { 1566 } else {
1571 run_message_loop_ = false; 1567 run_message_loop_ = false;
1572 } 1568 }
1573 browser_creator_.reset(); 1569 browser_creator_.reset();
1574 #endif // !defined(OS_ANDROID) 1570 #endif // !defined(OS_ANDROID)
1575 1571
1576 performance_monitor::PerformanceMonitor::GetInstance()->Initialize(); 1572 performance_monitor::PerformanceMonitor::GetInstance()->Initialize();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1653 1649
1654 // Disarm the startup hang detector time bomb if it is still Arm'ed. 1650 // Disarm the startup hang detector time bomb if it is still Arm'ed.
1655 startup_watcher_->Disarm(); 1651 startup_watcher_->Disarm();
1656 1652
1657 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) 1653 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1658 chrome_extra_parts_[i]->PostMainMessageLoopRun(); 1654 chrome_extra_parts_[i]->PostMainMessageLoopRun();
1659 1655
1660 // Some tests don't set parameters.ui_task, so they started translate 1656 // Some tests don't set parameters.ui_task, so they started translate
1661 // language fetch that was never completed so we need to cleanup here 1657 // language fetch that was never completed so we need to cleanup here
1662 // otherwise it will be done by the destructor in a wrong thread. 1658 // otherwise it will be done by the destructor in a wrong thread.
1663 if (parameters().ui_task == NULL && translate_manager_ != NULL) 1659 TranslateService::Shutdown(parameters().ui_task == NULL);
1664 translate_manager_->CleanupPendingUlrFetcher();
1665 1660
1666 if (notify_result_ == ProcessSingleton::PROCESS_NONE) 1661 if (notify_result_ == ProcessSingleton::PROCESS_NONE)
1667 process_singleton_->Cleanup(); 1662 process_singleton_->Cleanup();
1668 1663
1669 // Stop all tasks that might run on WatchDogThread. 1664 // Stop all tasks that might run on WatchDogThread.
1670 ThreadWatcherList::StopWatchingAll(); 1665 ThreadWatcherList::StopWatchingAll();
1671 1666
1672 browser_process_->metrics_service()->Stop(); 1667 browser_process_->metrics_service()->Stop();
1673 1668
1674 restart_last_session_ = browser_shutdown::ShutdownPreThreadsStop(); 1669 restart_last_session_ = browser_shutdown::ShutdownPreThreadsStop();
(...skipping 26 matching lines...) Expand all
1701 chromeos::CrosSettings::Shutdown(); 1696 chromeos::CrosSettings::Shutdown();
1702 #endif 1697 #endif
1703 #endif 1698 #endif
1704 } 1699 }
1705 1700
1706 // Public members: 1701 // Public members:
1707 1702
1708 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { 1703 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
1709 chrome_extra_parts_.push_back(parts); 1704 chrome_extra_parts_.push_back(parts);
1710 } 1705 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.h ('k') | chrome/browser/translate/chrome_translate_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698