| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ |
| 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ | 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/singleton.h" | |
| 16 #include "base/task.h" | 15 #include "base/task.h" |
| 17 #include "chrome/browser/prefs/pref_change_registrar.h" | 16 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 18 #include "chrome/common/net/url_fetcher.h" | 17 #include "chrome/common/net/url_fetcher.h" |
| 19 #include "chrome/common/notification_observer.h" | 18 #include "chrome/common/notification_observer.h" |
| 20 #include "chrome/common/notification_registrar.h" | 19 #include "chrome/common/notification_registrar.h" |
| 21 #include "chrome/common/translate_errors.h" | 20 #include "chrome/common/translate_errors.h" |
| 22 | 21 |
| 22 template <typename T> struct DefaultSingletonTraits; |
| 23 class GURL; | 23 class GURL; |
| 24 struct PageTranslatedDetails; | 24 struct PageTranslatedDetails; |
| 25 class PrefService; | 25 class PrefService; |
| 26 class TabContents; | 26 class TabContents; |
| 27 class TranslateInfoBarDelegate; | 27 class TranslateInfoBarDelegate; |
| 28 | 28 |
| 29 // The TranslateManager class is responsible for showing an info-bar when a page | 29 // The TranslateManager class is responsible for showing an info-bar when a page |
| 30 // in a language different than the user language is loaded. It triggers the | 30 // in a language different than the user language is loaded. It triggers the |
| 31 // page translation the user requests. | 31 // page translation the user requests. |
| 32 // It is a singleton. | 32 // It is a singleton. |
| 33 | 33 |
| 34 class TranslateManager : public NotificationObserver, | 34 class TranslateManager : public NotificationObserver, |
| 35 public URLFetcher::Delegate { | 35 public URLFetcher::Delegate { |
| 36 public: | 36 public: |
| 37 // Returns the singleton instance. |
| 38 static TranslateManager* GetInstance(); |
| 39 |
| 37 virtual ~TranslateManager(); | 40 virtual ~TranslateManager(); |
| 38 | 41 |
| 39 // Translates the page contents from |source_lang| to |target_lang|. | 42 // Translates the page contents from |source_lang| to |target_lang|. |
| 40 // The actual translation might be performed asynchronously if the translate | 43 // The actual translation might be performed asynchronously if the translate |
| 41 // script is not yet available. | 44 // script is not yet available. |
| 42 void TranslatePage(TabContents* tab_contents, | 45 void TranslatePage(TabContents* tab_contents, |
| 43 const std::string& source_lang, | 46 const std::string& source_lang, |
| 44 const std::string& target_lang); | 47 const std::string& target_lang); |
| 45 | 48 |
| 46 // Reverts the contents of the page in |tab_contents| to its original | 49 // Reverts the contents of the page in |tab_contents| to its original |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // server. | 182 // server. |
| 180 std::vector<PendingRequest> pending_requests_; | 183 std::vector<PendingRequest> pending_requests_; |
| 181 | 184 |
| 182 // The languages supported by the translation server. | 185 // The languages supported by the translation server. |
| 183 static base::LazyInstance<std::set<std::string> > supported_languages_; | 186 static base::LazyInstance<std::set<std::string> > supported_languages_; |
| 184 | 187 |
| 185 DISALLOW_COPY_AND_ASSIGN(TranslateManager); | 188 DISALLOW_COPY_AND_ASSIGN(TranslateManager); |
| 186 }; | 189 }; |
| 187 | 190 |
| 188 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ | 191 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ |
| OLD | NEW |