Chromium Code Reviews| Index: chrome/browser/ui/translate/translate_bubble_model.h |
| diff --git a/chrome/browser/ui/translate/translate_bubble_model.h b/chrome/browser/ui/translate/translate_bubble_model.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5b3bcd65ea0160106cc9e1c94f2658176a22b72d |
| --- /dev/null |
| +++ b/chrome/browser/ui/translate/translate_bubble_model.h |
| @@ -0,0 +1,97 @@ |
| +// Copyright 2013 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_UI_TRANSLATE_TRANSLATE_BUBBLE_MODEL_H_ |
| +#define CHROME_BROWSER_UI_TRANSLATE_TRANSLATE_BUBBLE_MODEL_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/strings/string16.h" |
| + |
| +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
|
| + public: |
| + 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.
|
| + BEFORE_TRANSLATE, |
| + TRANSLATING, |
| + AFTER_TRANSLATE, |
| + ERROR, |
| + ADVANCED, |
| + }; |
| + |
| + 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
|
| + public: |
| + virtual void OnViewTypeChanged(ViewType view_type) = 0; |
| + |
| + protected: |
| + virtual ~Observer() {} |
| + }; |
| + |
| + explicit TranslateBubbleModel(ViewType view_type); |
| + virtual ~TranslateBubbleModel() {} |
| + |
| + ViewType view_type() const { return view_type_; } |
| + void SetViewType(ViewType view_type); |
| + |
| + void GoBackFromAdvanced(); |
| + |
| + void set_observer(Observer* observer) { observer_ = observer; } |
| + |
| + // Returns the number of languages supported. |
| + virtual int GetNumberOfLanguages() const = 0; |
| + |
| + // Returns the displayable name for the language at |index|. |
| + virtual string16 GetLanguageNameAt(int index) const = 0; |
| + |
| + // Returns the original language index. |
| + virtual int GetOriginalLanguageIndex() const = 0; |
| + |
| + // Sets the original language index. |
| + virtual void SetOriginalLanguageIndex(int index) = 0; |
| + |
| + // Returns the target language index. |
| + virtual int GetTargetLanguageIndex() const = 0; |
| + |
| + // Sets the target language index. |
| + virtual void SetTargetLanguageIndex(int index) = 0; |
| + |
| + // Sets the value if the current language is blocked. |
| + 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
|
| + |
| + // Sets the value if the current webpage is blacklisted. |
| + virtual void SetSiteBlacklist(bool value) = 0; |
| + |
| + // Returns true if the webpage in the current original language should be |
| + // translated into the current target language automatically. |
| + virtual bool ShouldAlwaysTranslate() const = 0; |
| + |
| + // Sets the value if the webpage in the current original language should be |
| + // translated into the current target language automatically. |
| + virtual void SetAlwaysTranslate(bool value) = 0; |
| + |
| + // Starts translating the current page. |
| + virtual void Translate() = 0; |
| + |
| + // Reverts translation. |
| + virtual void RevertTranslation() = 0; |
| + |
| + // Processes when the user declines translation. |
| + virtual void TranslationDeclined() = 0; |
| + |
| + private: |
| + // The current view type. |
| + ViewType view_type_; |
| + |
| + // The view type. When the current view type is not 'Advanced' view, this is |
| + // equivalent to |view_type_|. Otherwise, this is the previous view type |
| + // before the user opens the 'Advanced' view. This is used to navigate when |
| + // pressing 'Cancel' button on the 'Advanced' view. |
| + ViewType view_type_before_advanced_view_; |
| + |
| + Observer* observer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TranslateBubbleModel); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_TRANSLATE_TRANSLATE_BUBBLE_MODEL_H_ |