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/strings/string16.h" 11 #include "chrome/common/translate/translate_errors.h" 12 13 // The model for the Translate bubble UX. This manages the user's manipulation 14 // of the bubble and offers the data to show on the bubble. 15 class TranslateBubbleModel { 16 public: 17 enum ViewState { 18 // The view state before translating. 19 VIEW_STATE_BEFORE_TRANSLATE, 20 21 // The view state during translating. 22 VIEW_STATE_TRANSLATING, 23 24 // The view state after translating. 25 VIEW_STATE_AFTER_TRANSLATE, 26 27 // The view state when an error of Translate happens. 28 VIEW_STATE_ERROR, 29 30 // The view state when the detailed settings is shown. This view appears 31 // when the user click a link 'Advanced' on other views. 32 VIEW_STATE_ADVANCED, 33 }; 34 35 virtual ~TranslateBubbleModel() {} 36 37 // Returns the current view state. 38 virtual ViewState GetViewState() const = 0; 39 40 // Transitions the view state. 41 virtual void SetViewState(ViewState view_state) = 0; 42 43 // Shows an error. 44 virtual void ShowError(TranslateErrors::Type error_type) = 0; 45 46 // Goes back from the 'Advanced' view state. 47 virtual void GoBackFromAdvanced() = 0; 48 49 // Returns the number of languages supported. 50 virtual int GetNumberOfLanguages() const = 0; 51 52 // Returns the displayable name for the language at |index|. 53 virtual base::string16 GetLanguageNameAt(int index) const = 0; 54 55 // Returns the original language index. 56 virtual int GetOriginalLanguageIndex() const = 0; 57 58 // Updates the original language index. 59 virtual void UpdateOriginalLanguageIndex(int index) = 0; 60 61 // Returns the target language index. 62 virtual int GetTargetLanguageIndex() const = 0; 63 64 // Updates the target language index. 65 virtual void UpdateTargetLanguageIndex(int index) = 0; 66 67 // Sets the value if the user doesn't want to have the page translated in the 68 // current page's language. 69 virtual void SetNeverTranslateLanguage(bool value) = 0; 70 71 // Sets the value if the user doesn't want to have the page translated the 72 // current page's domain. 73 virtual void SetNeverTranslateSite(bool value) = 0; 74 75 // Returns true if the webpage in the current original language should be 76 // translated into the current target language automatically. 77 virtual bool ShouldAlwaysTranslate() const = 0; 78 79 // Sets the value if the webpage in the current original language should be 80 // translated into the current target language automatically. 81 virtual void SetAlwaysTranslate(bool value) = 0; 82 83 // Starts translating the current page. 84 virtual void Translate() = 0; 85 86 // Reverts translation. 87 virtual void RevertTranslation() = 0; 88 89 // Processes when the user dismiss the bubble without translating. 90 // |explicitly_closed| is true if the user explicitly closed the UI, for 91 // example, clicking 'Nope' button. 92 virtual void TranslationDeclined(bool explicitly_closed) = 0; 93 94 // Returns true if the page is translated in the currently selected source 95 // and target language. 96 virtual bool IsPageTranslatedInCurrentLanguages() const = 0; 97 }; 98 99 #endif // CHROME_BROWSER_UI_TRANSLATE_TRANSLATE_BUBBLE_MODEL_H_ 100