| Index: chrome/browser/translate/translate_tab_helper.h
|
| diff --git a/chrome/browser/translate/translate_tab_helper.h b/chrome/browser/translate/translate_tab_helper.h
|
| index ed5054d7c17fae2487c5e9c12f2388ba765ab0ad..745b30705f82235d78a19ca9ba2ac8895ae995f0 100644
|
| --- a/chrome/browser/translate/translate_tab_helper.h
|
| +++ b/chrome/browser/translate/translate_tab_helper.h
|
| @@ -8,6 +8,7 @@
|
| #include <string>
|
|
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/weak_ptr.h"
|
| #include "chrome/browser/ui/translate/translate_bubble_model.h"
|
| #include "components/translate/content/browser/content_translate_driver.h"
|
| #include "components/translate/core/browser/translate_client.h"
|
| @@ -19,7 +20,6 @@
|
| #if defined(CLD2_DYNAMIC_MODE)
|
| #include "base/basictypes.h"
|
| #include "base/lazy_instance.h"
|
| -#include "base/memory/weak_ptr.h"
|
| #include "base/synchronization/lock.h"
|
| #include "base/task_runner.h"
|
| #endif
|
| @@ -78,6 +78,11 @@ class TranslateTabHelper
|
| // destroyed.
|
| content::WebContents* GetWebContents();
|
|
|
| + // Number of attempts before waiting for a page to be fully reloaded.
|
| + void set_translate_max_reload_attempts(int attempts) {
|
| + max_reload_check_attempts_ = attempts;
|
| + }
|
| +
|
| // TranslateClient implementation.
|
| virtual TranslateDriver* GetTranslateDriver() OVERRIDE;
|
| virtual PrefService* GetPrefs() OVERRIDE;
|
| @@ -94,6 +99,8 @@ class TranslateTabHelper
|
| friend class content::WebContentsUserData<TranslateTabHelper>;
|
|
|
| // content::WebContentsObserver implementation.
|
| + virtual void NavigationEntryCommitted(
|
| + const content::LoadCommittedDetails& load_details) OVERRIDE;
|
| virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
| virtual void DidNavigateAnyFrame(
|
| const content::LoadCommittedDetails& details,
|
| @@ -101,6 +108,8 @@ class TranslateTabHelper
|
| virtual void WebContentsDestroyed(
|
| content::WebContents* web_contents) OVERRIDE;
|
|
|
| + // Initiates translation once the page is finished loading.
|
| + void InitiateTranslation(const std::string& page_lang, int attempt);
|
| void OnLanguageDetermined(const LanguageDetectionDetails& details,
|
| bool page_needs_translation);
|
| void OnPageTranslated(int32 page_id,
|
| @@ -132,10 +141,6 @@ class TranslateTabHelper
|
| const uint64 data_offset,
|
| const uint64 data_length);
|
|
|
| - // Necessary for binding the callback to HandleCLDDataRequest on the blocking
|
| - // pool.
|
| - base::WeakPtrFactory<TranslateTabHelper> weak_pointer_factory_;
|
| -
|
| // The data file, cached as long as the process stays alive.
|
| // We also track the offset at which the data starts, and its length.
|
| static base::File* s_cached_file_; // guarded by file_lock_
|
| @@ -151,9 +156,17 @@ class TranslateTabHelper
|
| void ShowBubble(translate::TranslateStep step,
|
| TranslateErrors::Type error_type);
|
|
|
| + // Max number of attempts before checking if a page has been reloaded.
|
| + int max_reload_check_attempts_;
|
| +
|
| ContentTranslateDriver translate_driver_;
|
| scoped_ptr<TranslateManager> translate_manager_;
|
|
|
| + // Necessary for binding the callback to HandleCLDDataRequest on the blocking
|
| + // pool and for delaying translation initialization until the page has
|
| + // finished loading on a reload.
|
| + base::WeakPtrFactory<TranslateTabHelper> weak_pointer_factory_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(TranslateTabHelper);
|
| };
|
|
|
|
|