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

Unified Diff: components/translate/core/browser/language_state.h

Issue 133273029: Move LanguageState to the translate component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix more compile issues Created 6 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 side-by-side diff with in-line comments
Download patch
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 76%
rename from chrome/browser/tab_contents/language_state.h
rename to components/translate/core/browser/language_state.h
index 79a3f3b2bed2472a82514099ca7c1943d1ae6a1d..d40fd9d46de6480bfbcc64a6bbad35a72a55d1a7 100644
--- a/chrome/browser/tab_contents/language_state.h
+++ b/components/translate/core/browser/language_state.h
@@ -1,24 +1,18 @@
-// 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:
@@ -28,12 +22,12 @@ class WebContents;
class LanguageState {
public:
- explicit LanguageState(content::NavigationController* nav_controller);
+ LanguageState(TranslateDriver* driver);
MAD 2014/01/20 16:12:25 Why did you remove the "explicit"?
droger 2014/01/20 17:05:05 This was a mistake, explicit is back.
~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
@@ -81,8 +75,6 @@ class LanguageState {
// language.
bool HasLanguageChanged() const;
- void set_observer(LanguageStateObserver* observer) { observer_ = observer; }
-
private:
void SetIsPageTranslated(bool value);
@@ -100,21 +92,18 @@ 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_;
+ TranslateDriver* translate_driver_;
blundell 2014/01/20 14:22:53 Should have a comment, including lifetime expectat
// 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_

Powered by Google App Engine
This is Rietveld 408576698