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