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

Side by Side Diff: chrome/browser/ui/translate/translate_bubble_model.h

Issue 26775007: Translate: Add TranslateBubbleView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move implementation of the view type transitions to TranslateBubbleModel Created 7 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_TRANSLATE_TRANSLATE_BUBBLE_MODEL_H_
6 #define CHROME_BROWSER_UI_TRANSLATE_TRANSLATE_BUBBLE_MODEL_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
12
13 class TranslateBubbleModel {
sky 2013/10/15 16:10:40 Description.
sky 2013/10/15 16:10:40 Is there a reason this class shouldn't be pure vir
hajimehoshi 2013/10/16 07:35:06 No. I factored the implementation out to Translate
14 public:
15 enum ViewType {
sky 2013/10/15 16:10:40 Isn't this more of a State rather than a Type?
hajimehoshi2 2013/10/16 00:14:48 Yep, but do you mean these values should be classe
hajimehoshi 2013/10/16 07:35:06 Done.
16 BEFORE_TRANSLATE,
17 TRANSLATING,
18 AFTER_TRANSLATE,
19 ERROR,
20 ADVANCED,
21 };
22
23 class Observer {
sky 2013/10/15 16:10:40 Move into own header.
hajimehoshi 2013/10/16 07:35:06 I reimplemented TranslateBubbleView not to use thi
24 public:
25 virtual void OnViewTypeChanged(ViewType view_type) = 0;
26
27 protected:
28 virtual ~Observer() {}
29 };
30
31 explicit TranslateBubbleModel(ViewType view_type);
32 virtual ~TranslateBubbleModel() {}
33
34 ViewType view_type() const { return view_type_; }
35 void SetViewType(ViewType view_type);
36
37 void GoBackFromAdvanced();
38
39 void set_observer(Observer* observer) { observer_ = observer; }
40
41 // Returns the number of languages supported.
42 virtual int GetNumberOfLanguages() const = 0;
43
44 // Returns the displayable name for the language at |index|.
45 virtual string16 GetLanguageNameAt(int index) const = 0;
46
47 // Returns the original language index.
48 virtual int GetOriginalLanguageIndex() const = 0;
49
50 // Sets the original language index.
51 virtual void SetOriginalLanguageIndex(int index) = 0;
52
53 // Returns the target language index.
54 virtual int GetTargetLanguageIndex() const = 0;
55
56 // Sets the target language index.
57 virtual void SetTargetLanguageIndex(int index) = 0;
58
59 // Sets the value if the current language is blocked.
60 virtual void SetLanguageBlocked(bool value) = 0;
sky 2013/10/15 16:10:40 It's not at all clear what blocked or blacklisted
hajimehoshi 2013/10/16 07:35:06 Added comments and renamed them to SetNeverTransla
61
62 // Sets the value if the current webpage is blacklisted.
63 virtual void SetSiteBlacklist(bool value) = 0;
64
65 // Returns true if the webpage in the current original language should be
66 // translated into the current target language automatically.
67 virtual bool ShouldAlwaysTranslate() const = 0;
68
69 // Sets the value if the webpage in the current original language should be
70 // translated into the current target language automatically.
71 virtual void SetAlwaysTranslate(bool value) = 0;
72
73 // Starts translating the current page.
74 virtual void Translate() = 0;
75
76 // Reverts translation.
77 virtual void RevertTranslation() = 0;
78
79 // Processes when the user declines translation.
80 virtual void TranslationDeclined() = 0;
81
82 private:
83 // The current view type.
84 ViewType view_type_;
85
86 // The view type. When the current view type is not 'Advanced' view, this is
87 // equivalent to |view_type_|. Otherwise, this is the previous view type
88 // before the user opens the 'Advanced' view. This is used to navigate when
89 // pressing 'Cancel' button on the 'Advanced' view.
90 ViewType view_type_before_advanced_view_;
91
92 Observer* observer_;
93
94 DISALLOW_COPY_AND_ASSIGN(TranslateBubbleModel);
95 };
96
97 #endif // CHROME_BROWSER_UI_TRANSLATE_TRANSLATE_BUBBLE_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698