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

Side by Side Diff: chrome/browser/translate/translate_ui_delegate.h

Issue 87503004: Pass the Translate error type to the bubble (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: (rebasing) Created 7 years 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_TRANSLATE_TRANSLATE_UI_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_UI_DELEGATE_H_
6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_UI_DELEGATE_H_ 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_UI_DELEGATE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "chrome/common/chrome_constants.h" 14 #include "chrome/common/chrome_constants.h"
15 #include "chrome/common/translate/translate_errors.h"
15 16
16 class TranslatePrefs; 17 class TranslatePrefs;
17 18
18 namespace content { 19 namespace content {
19 class WebContents; 20 class WebContents;
20 } // namespace content 21 } // namespace content
21 22
22 // The TranslateUIDelegate is a generic delegate for UI which offers Translate 23 // The TranslateUIDelegate is a generic delegate for UI which offers Translate
23 // feature to the user. 24 // feature to the user.
24 // 25 //
25 // Note: TranslateInfobarDelegate should be updated if this implementation is 26 // Note: TranslateInfobarDelegate should be updated if this implementation is
26 // updated. 27 // updated.
27 class TranslateUIDelegate { 28 class TranslateUIDelegate {
28 public: 29 public:
29 enum { 30 enum {
30 NO_INDEX = -1, 31 NO_INDEX = -1,
31 }; 32 };
32 33
33 // A pair whose key is a language code and value is the language's 34 // A pair whose key is a language code and value is the language's
34 // displayable name. 35 // displayable name.
35 typedef std::pair<std::string, string16> LanguageNamePair; 36 typedef std::pair<std::string, string16> LanguageNamePair;
36 37
37 TranslateUIDelegate(content::WebContents* web_contents, 38 TranslateUIDelegate(content::WebContents* web_contents,
38 const std::string& original_language, 39 const std::string& original_language,
39 const std::string& target_language); 40 const std::string& target_language,
41 TranslateErrors::Type error_type);
40 virtual ~TranslateUIDelegate(); 42 virtual ~TranslateUIDelegate();
41 43
42 // Retrieves the displayable names of the supported languages, based on 44 // Retrieves the displayable names of the supported languages, based on
43 // |locale|. The returned names are sorted in alphabetical order. 45 // |locale|. The returned names are sorted in alphabetical order.
44 static std::vector<LanguageNamePair> GetSortedLanguageNames( 46 static std::vector<LanguageNamePair> GetSortedLanguageNames(
45 const std::string& locale); 47 const std::string& locale);
46 48
47 // Gets the host of the page of |web_contents|, or an empty string if no URL 49 // Gets the host of the page of |web_contents|, or an empty string if no URL
48 // is associated with the current page. 50 // is associated with the current page.
49 static std::string GetPageHost(content::WebContents* web_contents); 51 static std::string GetPageHost(content::WebContents* web_contents);
50 52
51 content::WebContents* web_contents() { return web_contents_; } 53 content::WebContents* web_contents() { return web_contents_; }
52 54
55 TranslateErrors::Type error_type() const { return error_type_; }
56
57 void set_error_type(TranslateErrors::Type error_type) {
58 error_type_ = error_type;
59 }
60
53 // Returns the number of languages supported. 61 // Returns the number of languages supported.
54 size_t GetNumberOfLanguages() const; 62 size_t GetNumberOfLanguages() const;
55 63
56 // Returns the original language index. 64 // Returns the original language index.
57 size_t GetOriginalLanguageIndex() const; 65 size_t GetOriginalLanguageIndex() const;
58 66
59 // Updates the original language index. 67 // Updates the original language index.
60 void UpdateOriginalLanguageIndex(size_t language_index); 68 void UpdateOriginalLanguageIndex(size_t language_index);
61 69
62 // Returns the target language index. 70 // Returns the target language index.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 125
118 // The index for language the page is originally in. 126 // The index for language the page is originally in.
119 size_t original_language_index_; 127 size_t original_language_index_;
120 128
121 // The index for language the page should be translated to. 129 // The index for language the page should be translated to.
122 size_t target_language_index_; 130 size_t target_language_index_;
123 131
124 // The translation related preferences. 132 // The translation related preferences.
125 scoped_ptr<TranslatePrefs> prefs_; 133 scoped_ptr<TranslatePrefs> prefs_;
126 134
135 // The error type.
136 TranslateErrors::Type error_type_;
137
127 DISALLOW_COPY_AND_ASSIGN(TranslateUIDelegate); 138 DISALLOW_COPY_AND_ASSIGN(TranslateUIDelegate);
128 }; 139 };
129 140
130 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_UI_DELEGATE_H_ 141 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_UI_DELEGATE_H_
OLDNEW
« no previous file with comments | « chrome/browser/translate/translate_manager_browsertest.cc ('k') | chrome/browser/translate/translate_ui_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698