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_IMPL_H_ 6 #define CHROME_BROWSER_UI_TRANSLATE_TRANSLATE_BUBBLE_MODEL_IMPL_H_ 7 8 #include "base/basictypes.h" 9 #include "base/memory/scoped_ptr.h" 10 #include "chrome/browser/translate/chrome_translate_client.h" 11 #include "chrome/browser/ui/translate/translate_bubble_model.h" 12 #include "chrome/browser/ui/translate/translate_bubble_view_state_transition.h" 13 14 class TranslateUIDelegate; 15 16 // The standard implementation of TranslateBubbleModel. 17 class TranslateBubbleModelImpl : public TranslateBubbleModel { 18 public: 19 TranslateBubbleModelImpl(translate::TranslateStep step, 20 scoped_ptr<TranslateUIDelegate> ui_delegate); 21 virtual ~TranslateBubbleModelImpl(); 22 23 // Converts a TranslateStep to a ViewState. 24 // This function never returns VIEW_STATE_ADVANCED. 25 static TranslateBubbleModel::ViewState TranslateStepToViewState( 26 translate::TranslateStep step); 27 28 // TranslateBubbleModel methods. 29 virtual TranslateBubbleModel::ViewState GetViewState() const OVERRIDE; 30 virtual void SetViewState(TranslateBubbleModel::ViewState view_state) 31 OVERRIDE; 32 virtual void ShowError(TranslateErrors::Type error_type) OVERRIDE; 33 virtual void GoBackFromAdvanced() OVERRIDE; 34 virtual int GetNumberOfLanguages() const OVERRIDE; 35 virtual base::string16 GetLanguageNameAt(int index) const OVERRIDE; 36 virtual int GetOriginalLanguageIndex() const OVERRIDE; 37 virtual void UpdateOriginalLanguageIndex(int index) OVERRIDE; 38 virtual int GetTargetLanguageIndex() const OVERRIDE; 39 virtual void UpdateTargetLanguageIndex(int index) OVERRIDE; 40 virtual void SetNeverTranslateLanguage(bool value) OVERRIDE; 41 virtual void SetNeverTranslateSite(bool value) OVERRIDE; 42 virtual bool ShouldAlwaysTranslate() const OVERRIDE; 43 virtual void SetAlwaysTranslate(bool value) OVERRIDE; 44 virtual void Translate() OVERRIDE; 45 virtual void RevertTranslation() OVERRIDE; 46 virtual void TranslationDeclined(bool explicitly_closed) OVERRIDE; 47 virtual bool IsPageTranslatedInCurrentLanguages() const OVERRIDE; 48 49 private: 50 scoped_ptr<TranslateUIDelegate> ui_delegate_; 51 TranslateBubbleViewStateTransition view_state_transition_; 52 53 DISALLOW_COPY_AND_ASSIGN(TranslateBubbleModelImpl); 54 }; 55 56 #endif // CHROME_BROWSER_UI_TRANSLATE_TRANSLATE_BUBBLE_MODEL_IMPL_H_ 57