| Index: components/translate/core/browser/language_state.h
|
| diff --git a/chrome/browser/tab_contents/language_state.h b/components/translate/core/browser/language_state.h
|
| similarity index 74%
|
| rename from chrome/browser/tab_contents/language_state.h
|
| rename to components/translate/core/browser/language_state.h
|
| index 79a3f3b2bed2472a82514099ca7c1943d1ae6a1d..daaaa54169273d375e503c31812ee09ddb1ac134 100644
|
| --- a/chrome/browser/tab_contents/language_state.h
|
| +++ b/components/translate/core/browser/language_state.h
|
| @@ -1,39 +1,32 @@
|
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Copyright 2011 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CHROME_BROWSER_TAB_CONTENTS_LANGUAGE_STATE_H_
|
| -#define CHROME_BROWSER_TAB_CONTENTS_LANGUAGE_STATE_H_
|
| +#ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_LANGUAGE_STATE_H_
|
| +#define COMPONENTS_TRANSLATE_CORE_BROWSER_LANGUAGE_STATE_H_
|
|
|
| #include <string>
|
|
|
| #include "base/basictypes.h"
|
|
|
| -class LanguageStateObserver;
|
| -
|
| -namespace content {
|
| -struct LoadCommittedDetails;
|
| -class NavigationController;
|
| -class WebContents;
|
| -}
|
| +class TranslateDriver;
|
|
|
| // This class holds the language state of the current page.
|
| -// There is one LanguageState instance per WebContents.
|
| +// There is one LanguageState instance per tab.
|
| // It is used to determine when navigating to a new page whether it should
|
| // automatically be translated.
|
| // This auto-translate behavior is the expected behavior when:
|
| // - user is on page in language A that they had translated to language B.
|
| // - user clicks a link in that page that takes them to a page also in language
|
| // A.
|
| -
|
| class LanguageState {
|
| public:
|
| - explicit LanguageState(content::NavigationController* nav_controller);
|
| + explicit LanguageState(TranslateDriver* driver);
|
| ~LanguageState();
|
|
|
| // Should be called when the page did a new navigation (whether it is a main
|
| // frame or sub-frame navigation).
|
| - void DidNavigate(const content::LoadCommittedDetails& details);
|
| + void DidNavigate(bool in_page_navigation, bool is_main_frame, bool reload);
|
|
|
| // Should be called when the language of the page has been determined.
|
| // |page_needs_translation| when false indicates that the browser should not
|
| @@ -72,8 +65,7 @@ class LanguageState {
|
| // navigation.
|
| bool in_page_navigation() const { return in_page_navigation_; }
|
|
|
| - // Whether the translate is enabled. This value is supposed to be used for the
|
| - // Translate icon on the Omnibox.
|
| + // Whether the translate is enabled.
|
| bool translate_enabled() const { return translate_enabled_; }
|
| void SetTranslateEnabled(bool value);
|
|
|
| @@ -81,8 +73,6 @@ class LanguageState {
|
| // language.
|
| bool HasLanguageChanged() const;
|
|
|
| - void set_observer(LanguageStateObserver* observer) { observer_ = observer; }
|
| -
|
| private:
|
| void SetIsPageTranslated(bool value);
|
|
|
| @@ -100,21 +90,20 @@ class LanguageState {
|
| std::string prev_original_lang_;
|
| std::string prev_current_lang_;
|
|
|
| - // The navigation controller of the tab we are associated with.
|
| - content::NavigationController* navigation_controller_;
|
| + // Provides driver-level context to the shared code of the component. Must
|
| + // outlive this object.
|
| + TranslateDriver* translate_driver_;
|
|
|
| // Whether it is OK to offer to translate the page. Some pages explictly
|
| // specify that they should not be translated by the browser (this is the case
|
| // for GMail for example, which provides its own translation features).
|
| bool page_needs_translation_;
|
|
|
| - // Whether a translation is currently pending (WebContents waiting for the
|
| - // PAGE_TRANSLATED notification). This is needed to avoid sending duplicate
|
| - // translate requests to a page. TranslateManager initiates translations
|
| - // when it received the LANGUAGE_DETERMINED notification. This is sent by
|
| - // the renderer with the page contents, every time the load stops for the
|
| - // main frame, so we may get several.
|
| - // TODO(jcampan): make the renderer send the language just once per navigation
|
| + // Whether a translation is currently pending.
|
| + // This is needed to avoid sending duplicate translate requests to a page.
|
| + // Translations may be initiated every time the load stops for the main frame,
|
| + // which may happen several times.
|
| + // TODO(jcampan): make the client send the language just once per navigation
|
| // then we can get rid of that state.
|
| bool translation_pending_;
|
|
|
| @@ -129,9 +118,7 @@ class LanguageState {
|
| // Whether the Translate is enabled.
|
| bool translate_enabled_;
|
|
|
| - LanguageStateObserver* observer_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(LanguageState);
|
| };
|
|
|
| -#endif // CHROME_BROWSER_TAB_CONTENTS_LANGUAGE_STATE_H_
|
| +#endif // COMPONENTS_TRANSLATE_CORE_BROWSER_LANGUAGE_STATE_H_
|
|
|