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

Side by Side Diff: chrome/browser/translate/translate_manager.cc

Issue 9233018: Convert use of int ms to TimeDelta in files owned by brettw. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase onto master. Created 8 years, 11 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
« no previous file with comments | « chrome/browser/translate/translate_manager.h ('k') | chrome/browser/unload_uitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/translate/translate_manager.h" 5 #include "chrome/browser/translate/translate_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 const char* const kTranslateScriptURL = 152 const char* const kTranslateScriptURL =
153 "http://translate.google.com/translate_a/element.js?" 153 "http://translate.google.com/translate_a/element.js?"
154 "cb=cr.googleTranslate.onTranslateElementLoad"; 154 "cb=cr.googleTranslate.onTranslateElementLoad";
155 const char* const kTranslateScriptHeader = 155 const char* const kTranslateScriptHeader =
156 "Google-Translate-Element-Mode: library"; 156 "Google-Translate-Element-Mode: library";
157 const char* const kReportLanguageDetectionErrorURL = 157 const char* const kReportLanguageDetectionErrorURL =
158 "http://translate.google.com/translate_error"; 158 "http://translate.google.com/translate_error";
159 const char* const kLanguageListFetchURL = 159 const char* const kLanguageListFetchURL =
160 "http://translate.googleapis.com/translate_a/l?client=chrome&cb=sl"; 160 "http://translate.googleapis.com/translate_a/l?client=chrome&cb=sl";
161 const int kMaxRetryLanguageListFetch = 5; 161 const int kMaxRetryLanguageListFetch = 5;
162 const int kTranslateScriptExpirationDelayMS = 24 * 60 * 60 * 1000; // 1 day. 162 const int kTranslateScriptExpirationDelayDays = 1;
163 163
164 } // namespace 164 } // namespace
165 165
166 // This must be kept in sync with the &cb= value in the kLanguageListFetchURL. 166 // This must be kept in sync with the &cb= value in the kLanguageListFetchURL.
167 const char* const TranslateManager::kLanguageListCallbackName = "sl("; 167 const char* const TranslateManager::kLanguageListCallbackName = "sl(";
168 const char* const TranslateManager::kTargetLanguagesKey = "tl"; 168 const char* const TranslateManager::kTargetLanguagesKey = "tl";
169 169
170 // static 170 // static
171 base::LazyInstance<std::set<std::string> > 171 base::LazyInstance<std::set<std::string> >
172 TranslateManager::supported_languages_ = LAZY_INSTANCE_INITIALIZER; 172 TranslateManager::supported_languages_ = LAZY_INSTANCE_INITIALIZER;
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 } 480 }
481 } 481 }
482 482
483 // static 483 // static
484 bool TranslateManager::IsShowingTranslateInfobar(WebContents* tab) { 484 bool TranslateManager::IsShowingTranslateInfobar(WebContents* tab) {
485 return GetTranslateInfoBarDelegate(tab) != NULL; 485 return GetTranslateInfoBarDelegate(tab) != NULL;
486 } 486 }
487 487
488 TranslateManager::TranslateManager() 488 TranslateManager::TranslateManager()
489 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_method_factory_(this)), 489 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_method_factory_(this)),
490 translate_script_expiration_delay_(kTranslateScriptExpirationDelayMS) { 490 translate_script_expiration_delay_(
491 base::TimeDelta::FromDays(kTranslateScriptExpirationDelayDays)) {
491 notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 492 notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
492 content::NotificationService::AllSources()); 493 content::NotificationService::AllSources());
493 notification_registrar_.Add(this, 494 notification_registrar_.Add(this,
494 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 495 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
495 content::NotificationService::AllSources()); 496 content::NotificationService::AllSources());
496 notification_registrar_.Add(this, chrome::NOTIFICATION_PAGE_TRANSLATED, 497 notification_registrar_.Add(this, chrome::NOTIFICATION_PAGE_TRANSLATED,
497 content::NotificationService::AllSources()); 498 content::NotificationService::AllSources());
498 } 499 }
499 500
500 void TranslateManager::InitiateTranslation(WebContents* tab, 501 void TranslateManager::InitiateTranslation(WebContents* tab,
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); 873 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper();
873 874
874 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { 875 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) {
875 TranslateInfoBarDelegate* delegate = 876 TranslateInfoBarDelegate* delegate =
876 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); 877 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate();
877 if (delegate) 878 if (delegate)
878 return delegate; 879 return delegate;
879 } 880 }
880 return NULL; 881 return NULL;
881 } 882 }
OLDNEW
« no previous file with comments | « chrome/browser/translate/translate_manager.h ('k') | chrome/browser/unload_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698