| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/translate/translate_service.h" | 5 #include "chrome/browser/translate/translate_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/translate/translate_manager.h" | |
| 10 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 11 #include "components/translate/core/browser/translate_download_manager.h" | 10 #include "components/translate/core/browser/translate_download_manager.h" |
| 12 | 11 |
| 13 namespace { | 12 namespace { |
| 14 // The singleton instance of TranslateService. | 13 // The singleton instance of TranslateService. |
| 15 TranslateService* g_translate_service = NULL; | 14 TranslateService* g_translate_service = NULL; |
| 16 } | 15 } |
| 17 | 16 |
| 18 TranslateService::TranslateService() : use_infobar_(false) { | 17 TranslateService::TranslateService() : use_infobar_(false) { |
| 19 resource_request_allowed_notifier_.Init(this); | 18 resource_request_allowed_notifier_.Init(this); |
| 20 } | 19 } |
| 21 | 20 |
| 22 TranslateService::~TranslateService() {} | 21 TranslateService::~TranslateService() {} |
| 23 | 22 |
| 24 // static | 23 // static |
| 25 void TranslateService::Initialize() { | 24 void TranslateService::Initialize() { |
| 26 if (g_translate_service) | 25 if (g_translate_service) |
| 27 return; | 26 return; |
| 28 | 27 |
| 29 g_translate_service = new TranslateService; | 28 g_translate_service = new TranslateService; |
| 30 // Initialize the allowed state for resource requests. | 29 // Initialize the allowed state for resource requests. |
| 31 g_translate_service->OnResourceRequestsAllowed(); | 30 g_translate_service->OnResourceRequestsAllowed(); |
| 32 // Create the TranslateManager singleton. | |
| 33 TranslateManager::GetInstance(); | |
| 34 TranslateDownloadManager* download_manager = | 31 TranslateDownloadManager* download_manager = |
| 35 TranslateDownloadManager::GetInstance(); | 32 TranslateDownloadManager::GetInstance(); |
| 36 download_manager->set_request_context( | 33 download_manager->set_request_context( |
| 37 g_browser_process->system_request_context()); | 34 g_browser_process->system_request_context()); |
| 38 download_manager->set_application_locale( | 35 download_manager->set_application_locale( |
| 39 g_browser_process->GetApplicationLocale()); | 36 g_browser_process->GetApplicationLocale()); |
| 40 } | 37 } |
| 41 | 38 |
| 42 // static | 39 // static |
| 43 void TranslateService::Shutdown(bool cleanup_pending_fetcher) { | 40 void TranslateService::Shutdown(bool cleanup_pending_fetcher) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // The bubble UX is not implemented on the non-Aura platforms. | 73 // The bubble UX is not implemented on the non-Aura platforms. |
| 77 return false; | 74 return false; |
| 78 #endif | 75 #endif |
| 79 } | 76 } |
| 80 | 77 |
| 81 // static | 78 // static |
| 82 void TranslateService::SetUseInfobar(bool value) { | 79 void TranslateService::SetUseInfobar(bool value) { |
| 83 Initialize(); | 80 Initialize(); |
| 84 g_translate_service->use_infobar_ = value; | 81 g_translate_service->use_infobar_ = value; |
| 85 } | 82 } |
| OLD | NEW |