| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TAB_CONTENTS_LANGUAGE_STATE_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_LANGUAGE_STATE_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_LANGUAGE_STATE_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_LANGUAGE_STATE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 class NavigationController; | 14 class NavigationController; |
| 15 struct LoadCommittedDetails; | 15 struct LoadCommittedDetails; |
| 16 } | 16 } |
| 17 | 17 |
| 18 // This class holds the language state of the current page. | 18 // This class holds the language state of the current page. |
| 19 // There is one LanguageState instance per TabContents. | 19 // There is one LanguageState instance per WebContents. |
| 20 // It is used to determine when navigating to a new page whether it should | 20 // It is used to determine when navigating to a new page whether it should |
| 21 // automatically be translated. | 21 // automatically be translated. |
| 22 // This auto-translate behavior is the expected behavior when: | 22 // This auto-translate behavior is the expected behavior when: |
| 23 // - user is on page in language A that they had translated to language B. | 23 // - user is on page in language A that they had translated to language B. |
| 24 // - user clicks a link in that page that takes them to a page also in language | 24 // - user clicks a link in that page that takes them to a page also in language |
| 25 // A. | 25 // A. |
| 26 | 26 |
| 27 class LanguageState { | 27 class LanguageState { |
| 28 public: | 28 public: |
| 29 explicit LanguageState(content::NavigationController* nav_controller); | 29 explicit LanguageState(content::NavigationController* nav_controller); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 std::string prev_current_lang_; | 82 std::string prev_current_lang_; |
| 83 | 83 |
| 84 // The navigation controller of the tab we are associated with. | 84 // The navigation controller of the tab we are associated with. |
| 85 content::NavigationController* navigation_controller_; | 85 content::NavigationController* navigation_controller_; |
| 86 | 86 |
| 87 // Whether it is OK to offer to translate the page. Some pages explictly | 87 // Whether it is OK to offer to translate the page. Some pages explictly |
| 88 // specify that they should not be translated by the browser (this is the case | 88 // specify that they should not be translated by the browser (this is the case |
| 89 // for GMail for example, which provides its own translation features). | 89 // for GMail for example, which provides its own translation features). |
| 90 bool page_translatable_; | 90 bool page_translatable_; |
| 91 | 91 |
| 92 // Whether a translation is currently pending (TabContents waiting for the | 92 // Whether a translation is currently pending (WebContents waiting for the |
| 93 // PAGE_TRANSLATED notification). This is needed to avoid sending duplicate | 93 // PAGE_TRANSLATED notification). This is needed to avoid sending duplicate |
| 94 // translate requests to a page. TranslateManager initiates translations | 94 // translate requests to a page. TranslateManager initiates translations |
| 95 // when it received the LANGUAGE_DETERMINED notification. This is sent by | 95 // when it received the LANGUAGE_DETERMINED notification. This is sent by |
| 96 // the renderer with the page contents, every time the load stops for the | 96 // the renderer with the page contents, every time the load stops for the |
| 97 // main frame, so we may get several. | 97 // main frame, so we may get several. |
| 98 // TODO(jcampan): make the renderer send the language just once per navigation | 98 // TODO(jcampan): make the renderer send the language just once per navigation |
| 99 // then we can get rid of that state. | 99 // then we can get rid of that state. |
| 100 bool translation_pending_; | 100 bool translation_pending_; |
| 101 | 101 |
| 102 // Whether the user has declined to translate the page (by closing the infobar | 102 // Whether the user has declined to translate the page (by closing the infobar |
| 103 // for example). This is necessary as a new infobar could be shown if a new | 103 // for example). This is necessary as a new infobar could be shown if a new |
| 104 // load happens in the page after the user closed the infobar. | 104 // load happens in the page after the user closed the infobar. |
| 105 bool translation_declined_; | 105 bool translation_declined_; |
| 106 | 106 |
| 107 // Whether the current navigation is a fragment navigation (in page). | 107 // Whether the current navigation is a fragment navigation (in page). |
| 108 bool in_page_navigation_; | 108 bool in_page_navigation_; |
| 109 | 109 |
| 110 DISALLOW_COPY_AND_ASSIGN(LanguageState); | 110 DISALLOW_COPY_AND_ASSIGN(LanguageState); |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 #endif // CHROME_BROWSER_TAB_CONTENTS_LANGUAGE_STATE_H_ | 113 #endif // CHROME_BROWSER_TAB_CONTENTS_LANGUAGE_STATE_H_ |
| OLD | NEW |