OLD | NEW |
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/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 #ifdef FILE_MANAGER_EXTENSION | 55 #ifdef FILE_MANAGER_EXTENSION |
56 #include "chrome/browser/chromeos/file_manager/app_id.h" | 56 #include "chrome/browser/chromeos/file_manager/app_id.h" |
57 #include "extensions/common/constants.h" | 57 #include "extensions/common/constants.h" |
58 #endif | 58 #endif |
59 | 59 |
60 using content::NavigationController; | 60 using content::NavigationController; |
61 using content::NavigationEntry; | 61 using content::NavigationEntry; |
62 using content::WebContents; | 62 using content::WebContents; |
63 | 63 |
64 namespace { | |
65 | |
66 const char kReportLanguageDetectionErrorURL[] = | 64 const char kReportLanguageDetectionErrorURL[] = |
67 "https://translate.google.com/translate_error?client=cr&action=langidc"; | 65 "https://translate.google.com/translate_error?client=cr&action=langidc"; |
68 | 66 |
69 // Used in kReportLanguageDetectionErrorURL to specify the original page | 67 // Used in kReportLanguageDetectionErrorURL to specify the original page |
70 // language. | 68 // language. |
71 const char kSourceLanguageQueryName[] = "sl"; | 69 const char kSourceLanguageQueryName[] = "sl"; |
72 | 70 |
73 // Used in kReportLanguageDetectionErrorURL to specify the page URL. | 71 // Used in kReportLanguageDetectionErrorURL to specify the page URL. |
74 const char kUrlQueryName[] = "u"; | 72 const char kUrlQueryName[] = "u"; |
75 | 73 |
76 // The delay in ms that we'll wait to check if a page has finished loading | |
77 // before attempting a translation. | |
78 const int kTranslateLoadCheckDelayMs = 150; | |
79 | |
80 // The maximum number of attempts we'll do to see if the page has finshed | 74 // The maximum number of attempts we'll do to see if the page has finshed |
81 // loading before giving up the translation | 75 // loading before giving up the translation |
82 const int kMaxTranslateLoadCheckAttempts = 20; | 76 const int kMaxTranslateLoadCheckAttempts = 20; |
83 | 77 |
84 } // namespace | |
85 | |
86 TranslateManager::~TranslateManager() { | 78 TranslateManager::~TranslateManager() { |
87 weak_method_factory_.InvalidateWeakPtrs(); | 79 weak_method_factory_.InvalidateWeakPtrs(); |
88 } | 80 } |
89 | 81 |
90 // static | 82 // static |
91 TranslateManager* TranslateManager::GetInstance() { | 83 TranslateManager* TranslateManager::GetInstance() { |
92 return Singleton<TranslateManager>::get(); | 84 return Singleton<TranslateManager>::get(); |
93 } | 85 } |
94 | 86 |
95 // static | 87 // static |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 // so we are more aggressive about showing the shortcut to never translate. | 704 // so we are more aggressive about showing the shortcut to never translate. |
713 #if defined(OS_ANDROID) | 705 #if defined(OS_ANDROID) |
714 config.never_translate_min_count = 1; | 706 config.never_translate_min_count = 1; |
715 #else | 707 #else |
716 config.never_translate_min_count = 3; | 708 config.never_translate_min_count = 3; |
717 #endif // defined(OS_ANDROID) | 709 #endif // defined(OS_ANDROID) |
718 | 710 |
719 config.always_translate_min_count = 3; | 711 config.always_translate_min_count = 3; |
720 return config; | 712 return config; |
721 } | 713 } |
OLD | NEW |