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/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 #include "components/translate/core/browser/translate_download_manager.h" | 10 #include "components/translate/core/browser/translate_download_manager.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 g_browser_process->GetApplicationLocale()); | 36 g_browser_process->GetApplicationLocale()); |
37 } | 37 } |
38 | 38 |
39 // static | 39 // static |
40 void TranslateService::Shutdown(bool cleanup_pending_fetcher) { | 40 void TranslateService::Shutdown(bool cleanup_pending_fetcher) { |
41 TranslateDownloadManager* download_manager = | 41 TranslateDownloadManager* download_manager = |
42 TranslateDownloadManager::GetInstance(); | 42 TranslateDownloadManager::GetInstance(); |
43 if (cleanup_pending_fetcher) { | 43 if (cleanup_pending_fetcher) { |
44 download_manager->Shutdown(); | 44 download_manager->Shutdown(); |
45 } else { | 45 } else { |
46 // This path is only used by tests. | 46 // This path is only used by browser tests. |
47 download_manager->set_request_context(NULL); | 47 download_manager->set_request_context(NULL); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
| 51 // static |
| 52 void TranslateService::InitializeForTesting() { |
| 53 if (!g_translate_service) { |
| 54 TranslateService::Initialize(); |
| 55 } else { |
| 56 TranslateDownloadManager::GetInstance()->ResetForTesting(); |
| 57 g_translate_service->OnResourceRequestsAllowed(); |
| 58 } |
| 59 } |
| 60 |
| 61 // static |
| 62 void TranslateService::ShutdownForTesting() { |
| 63 TranslateDownloadManager::GetInstance()->Shutdown(); |
| 64 } |
| 65 |
51 void TranslateService::OnResourceRequestsAllowed() { | 66 void TranslateService::OnResourceRequestsAllowed() { |
52 TranslateLanguageList* language_list = | 67 TranslateLanguageList* language_list = |
53 TranslateDownloadManager::GetInstance()->language_list(); | 68 TranslateDownloadManager::GetInstance()->language_list(); |
54 if (!language_list) { | 69 if (!language_list) { |
55 NOTREACHED(); | 70 NOTREACHED(); |
56 return; | 71 return; |
57 } | 72 } |
58 | 73 |
59 language_list->SetResourceRequestsAllowed( | 74 language_list->SetResourceRequestsAllowed( |
60 resource_request_allowed_notifier_.ResourceRequestsAllowed()); | 75 resource_request_allowed_notifier_.ResourceRequestsAllowed()); |
(...skipping 12 matching lines...) Expand all Loading... |
73 // The bubble UX is not implemented on the non-Aura platforms. | 88 // The bubble UX is not implemented on the non-Aura platforms. |
74 return false; | 89 return false; |
75 #endif | 90 #endif |
76 } | 91 } |
77 | 92 |
78 // static | 93 // static |
79 void TranslateService::SetUseInfobar(bool value) { | 94 void TranslateService::SetUseInfobar(bool value) { |
80 Initialize(); | 95 Initialize(); |
81 g_translate_service->use_infobar_ = value; | 96 g_translate_service->use_infobar_ = value; |
82 } | 97 } |
OLD | NEW |