1ef8225444452a1486bd721f3285301fe84643b00Stephen Hines// Copyright 2013 The Chromium Authors. All rights reserved. 2ef8225444452a1486bd721f3285301fe84643b00Stephen Hines// Use of this source code is governed by a BSD-style license that can be 3ef8225444452a1486bd721f3285301fe84643b00Stephen Hines// found in the LICENSE file. 4ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 5ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#ifndef CHROME_BROWSER_CHROMEOS_UI_ECHO_DIALOG_VIEW_H_ 6ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#define CHROME_BROWSER_CHROMEOS_UI_ECHO_DIALOG_VIEW_H_ 7ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 8ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#include "base/basictypes.h" 9ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#include "base/compiler_specific.h" 10ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#include "ui/views/controls/styled_label_listener.h" 11ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#include "ui/views/window/dialog_delegate.h" 12ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 13ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesnamespace views { 14ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesclass StyledLabel; 15ef8225444452a1486bd721f3285301fe84643b00Stephen Hines} 16ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 17ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesnamespace chromeos { 18ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 19ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesclass EchoDialogListener; 20ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 21ef8225444452a1486bd721f3285301fe84643b00Stephen Hines// Dialog shown by echoPrivate extension API when getUserConsent function is 22ef8225444452a1486bd721f3285301fe84643b00Stephen Hines// called. The API is used by echo extension when an offer from a service is 23ef8225444452a1486bd721f3285301fe84643b00Stephen Hines// being redeemed. The dialog is shown to get an user consent. If the echo 24ef8225444452a1486bd721f3285301fe84643b00Stephen Hines// extension is not allowed by policy to redeem offers, the dialog informs user 25ef8225444452a1486bd721f3285301fe84643b00Stephen Hines// about this. 26ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesclass EchoDialogView : public views::DialogDelegateView, 27ef8225444452a1486bd721f3285301fe84643b00Stephen Hines public views::StyledLabelListener { 28ef8225444452a1486bd721f3285301fe84643b00Stephen Hines public: 29ef8225444452a1486bd721f3285301fe84643b00Stephen Hines explicit EchoDialogView(EchoDialogListener* listener); 30ef8225444452a1486bd721f3285301fe84643b00Stephen Hines virtual ~EchoDialogView(); 31ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 32ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // Initializes dialog layout that will be showed when echo extension is 33ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // allowed to redeem offers. |service_name| is the name of the service that 34ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // requests user consent to redeem an offer. |origin| is the service's origin 35ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // url. Service name should be underlined in the dialog, and hovering over its 36ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // label should display tooltip containing |origin|. 37ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // The dialog will have both OK and Cancel buttons. 38ef8225444452a1486bd721f3285301fe84643b00Stephen Hines void InitForEnabledEcho(const base::string16& service_name, const base::string16& origin); 39ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 40ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // Initializes dialog layout that will be shown when echo extension is not 41 // allowed to redeem offers. The dialog will be showing a message that the 42 // offer redeeming is disabled by policy. 43 // The dialog will have only Cancel button. 44 void InitForDisabledEcho(); 45 46 // Shows the dialog. 47 void Show(gfx::NativeWindow parent); 48 49 private: 50 friend class ExtensionEchoPrivateApiTest; 51 52 // views::DialogDelegate overrides. 53 virtual int GetDialogButtons() const OVERRIDE; 54 virtual int GetDefaultDialogButton() const OVERRIDE; 55 virtual base::string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; 56 virtual bool Cancel() OVERRIDE; 57 virtual bool Accept() OVERRIDE; 58 59 // views::WidgetDelegate overrides. 60 virtual ui::ModalType GetModalType() const OVERRIDE; 61 virtual bool ShouldShowWindowTitle() const OVERRIDE; 62 virtual bool ShouldShowWindowIcon() const OVERRIDE; 63 64 // views::LinkListener override. 65 virtual void StyledLabelLinkClicked(const gfx::Range& range, 66 int event_flags) OVERRIDE; 67 68 // views::View override. 69 virtual gfx::Size GetPreferredSize() const OVERRIDE; 70 71 // Sets the border and bounds for the styled label containing the dialog 72 // text. 73 void SetLabelBorderAndBounds(); 74 75 views::StyledLabel* label_; 76 EchoDialogListener* listener_; 77 int ok_button_label_id_; 78 int cancel_button_label_id_; 79 80 DISALLOW_COPY_AND_ASSIGN(EchoDialogView); 81}; 82 83} // namespace chromeos 84 85#endif // CHROME_BROWSER_CHROMEOS_UI_ECHO_DIALOG_VIEW_H_ 86