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

Side by Side Diff: components/translate/core/browser/translate_download_manager.cc

Issue 2819813002: Translate: remove --disable-translate flag (Closed)
Patch Set: Merge branch 'master' into translate_remove_disable_flag Created 3 years, 8 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 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 "components/translate/core/browser/translate_download_manager.h" 5 #include "components/translate/core/browser/translate_download_manager.h"
6 6
7 #include "base/command_line.h"
8 #include "base/logging.h" 7 #include "base/logging.h"
9 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
10 #include "components/prefs/pref_service.h" 9 #include "components/prefs/pref_service.h"
11 #include "components/translate/core/browser/translate_pref_names.h" 10 #include "components/translate/core/browser/translate_pref_names.h"
12 #include "components/translate/core/common/translate_switches.h" 11 #include "components/translate/core/common/translate_switches.h"
13 12
14 namespace translate { 13 namespace translate {
15 14
16 // static 15 // static
17 TranslateDownloadManager* TranslateDownloadManager::GetInstance() { 16 TranslateDownloadManager* TranslateDownloadManager::GetInstance() {
18 return base::Singleton<TranslateDownloadManager>::get(); 17 return base::Singleton<TranslateDownloadManager>::get();
19 } 18 }
20 19
21 TranslateDownloadManager::TranslateDownloadManager() 20 TranslateDownloadManager::TranslateDownloadManager()
22 : language_list_(new TranslateLanguageList), 21 : language_list_(new TranslateLanguageList),
23 script_(new TranslateScript) {} 22 script_(new TranslateScript) {}
24 23
25 TranslateDownloadManager::~TranslateDownloadManager() {} 24 TranslateDownloadManager::~TranslateDownloadManager() {}
26 25
27 void TranslateDownloadManager::Shutdown() { 26 void TranslateDownloadManager::Shutdown() {
28 language_list_.reset(); 27 language_list_.reset();
29 script_.reset(); 28 script_.reset();
30 request_context_ = NULL; 29 request_context_ = NULL;
31 } 30 }
32 31
33 // static 32 // static
34 void TranslateDownloadManager::RequestLanguageList() {
35 TranslateLanguageList* language_list = GetInstance()->language_list();
36 if (!language_list) {
37 NOTREACHED();
38 return;
39 }
40
41 language_list->RequestLanguageList();
42 }
43
44 // static
45 void TranslateDownloadManager::RequestLanguageList(PrefService* prefs) { 33 void TranslateDownloadManager::RequestLanguageList(PrefService* prefs) {
46 // We don't want to do this when translate is disabled. 34 // We don't want to do this when translate is disabled.
47 DCHECK(prefs != NULL); 35 DCHECK(prefs != NULL);
48 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 36 if (!prefs->GetBoolean(prefs::kEnableTranslate))
49 translate::switches::kDisableTranslate) || 37 return;
50 !prefs->GetBoolean(prefs::kEnableTranslate)) { 38
39 TranslateLanguageList* language_list = GetInstance()->language_list();
40 if (!language_list) {
41 NOTREACHED();
51 return; 42 return;
52 } 43 }
53 44 language_list->RequestLanguageList();
54 RequestLanguageList();
55 } 45 }
56 46
57 // static 47 // static
58 void TranslateDownloadManager::GetSupportedLanguages( 48 void TranslateDownloadManager::GetSupportedLanguages(
59 std::vector<std::string>* languages) { 49 std::vector<std::string>* languages) {
60 TranslateLanguageList* language_list = GetInstance()->language_list(); 50 TranslateLanguageList* language_list = GetInstance()->language_list();
61 if (!language_list) { 51 if (!language_list) {
62 NOTREACHED(); 52 NOTREACHED();
63 return; 53 return;
64 } 54 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 105
116 void TranslateDownloadManager::SetTranslateScriptExpirationDelay(int delay_ms) { 106 void TranslateDownloadManager::SetTranslateScriptExpirationDelay(int delay_ms) {
117 if (script_.get() == NULL) { 107 if (script_.get() == NULL) {
118 NOTREACHED(); 108 NOTREACHED();
119 return; 109 return;
120 } 110 }
121 script_->set_expiration_delay(delay_ms); 111 script_->set_expiration_delay(delay_ms);
122 } 112 }
123 113
124 } // namespace translate 114 } // namespace translate
OLDNEW
« no previous file with comments | « components/translate/core/browser/translate_download_manager.h ('k') | components/translate/core/browser/translate_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698