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

Side by Side Diff: chrome/browser/tab_contents/language_state.h

Issue 25373009: Translate: New Bubble UX (for the view toolkit) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bug fix: view id on tests Created 7 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/tab_contents/language_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 11
12 class LanguageStateObserver;
13
12 namespace content { 14 namespace content {
15 struct LoadCommittedDetails;
13 class NavigationController; 16 class NavigationController;
14 struct LoadCommittedDetails; 17 class WebContents;
15 } 18 }
16 19
17 // This class holds the language state of the current page. 20 // This class holds the language state of the current page.
18 // There is one LanguageState instance per WebContents. 21 // There is one LanguageState instance per WebContents.
19 // It is used to determine when navigating to a new page whether it should 22 // It is used to determine when navigating to a new page whether it should
20 // automatically be translated. 23 // automatically be translated.
21 // This auto-translate behavior is the expected behavior when: 24 // This auto-translate behavior is the expected behavior when:
22 // - user is on page in language A that they had translated to language B. 25 // - user is on page in language A that they had translated to language B.
23 // - user clicks a link in that page that takes them to a page also in language 26 // - user clicks a link in that page that takes them to a page also in language
24 // A. 27 // A.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 void set_translation_pending(bool value) { translation_pending_ = value; } 67 void set_translation_pending(bool value) { translation_pending_ = value; }
65 68
66 // Whether the user has already declined to translate the page. 69 // Whether the user has already declined to translate the page.
67 bool translation_declined() const { return translation_declined_; } 70 bool translation_declined() const { return translation_declined_; }
68 void set_translation_declined(bool value) { translation_declined_ = value; } 71 void set_translation_declined(bool value) { translation_declined_ = value; }
69 72
70 // Whether the current page was navigated through an in-page (fragment) 73 // Whether the current page was navigated through an in-page (fragment)
71 // navigation. 74 // navigation.
72 bool in_page_navigation() const { return in_page_navigation_; } 75 bool in_page_navigation() const { return in_page_navigation_; }
73 76
77 // Whether the translate is enabled. This value is supposed to be used for the
78 // Translate icon on the Omnibox.
79 bool translate_enabled() const { return translate_enabled_; }
80 void SetTranslateEnabled(bool value);
81
82 // Whether the current page's language is different from the previous
83 // language.
84 bool HasLanguageChanged() const;
85
86 void set_observer(LanguageStateObserver* observer) { observer_ = observer; }
87
74 private: 88 private:
75 // The languages this page is in. Note that current_lang_ is different from 89 // The languages this page is in. Note that current_lang_ is different from
76 // original_lang_ when the page has been translated. 90 // original_lang_ when the page has been translated.
77 // Note that these might be empty if the page language has not been determined 91 // Note that these might be empty if the page language has not been determined
78 // yet. 92 // yet.
79 std::string original_lang_; 93 std::string original_lang_;
80 std::string current_lang_; 94 std::string current_lang_;
81 95
82 // Same as above but for the previous page. 96 // Same as above but for the previous page.
83 std::string prev_original_lang_; 97 std::string prev_original_lang_;
(...skipping 18 matching lines...) Expand all
102 bool translation_pending_; 116 bool translation_pending_;
103 117
104 // Whether the user has declined to translate the page (by closing the infobar 118 // Whether the user has declined to translate the page (by closing the infobar
105 // for example). This is necessary as a new infobar could be shown if a new 119 // for example). This is necessary as a new infobar could be shown if a new
106 // load happens in the page after the user closed the infobar. 120 // load happens in the page after the user closed the infobar.
107 bool translation_declined_; 121 bool translation_declined_;
108 122
109 // Whether the current navigation is a fragment navigation (in page). 123 // Whether the current navigation is a fragment navigation (in page).
110 bool in_page_navigation_; 124 bool in_page_navigation_;
111 125
126 // Whether the Translate is enabled.
127 bool translate_enabled_;
128
129 LanguageStateObserver* observer_;
130
112 DISALLOW_COPY_AND_ASSIGN(LanguageState); 131 DISALLOW_COPY_AND_ASSIGN(LanguageState);
113 }; 132 };
114 133
115 #endif // CHROME_BROWSER_TAB_CONTENTS_LANGUAGE_STATE_H_ 134 #endif // CHROME_BROWSER_TAB_CONTENTS_LANGUAGE_STATE_H_
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/tab_contents/language_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698