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.
5 #ifndef CHROME_BROWSER_CHROMEOS_ATTESTATION_PLATFORM_VERIFICATION_DIALOG_H_
6 #define CHROME_BROWSER_CHROMEOS_ATTESTATION_PLATFORM_VERIFICATION_DIALOG_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/strings/string16.h"
11 #include "content/public/browser/web_contents_observer.h"
12 #include "ui/views/controls/styled_label_listener.h"
13 #include "ui/views/window/dialog_delegate.h"
20 namespace attestation
{
22 // A tab-modal dialog UI to ask the user for PlatformVerificationFlow.
23 class PlatformVerificationDialog
: public views::DialogDelegateView
,
24 public views::StyledLabelListener
,
25 public content::WebContentsObserver
{
27 enum ConsentResponse
{
28 CONSENT_RESPONSE_NONE
,
29 CONSENT_RESPONSE_ALLOW
,
33 using ConsentCallback
= base::Callback
<void(ConsentResponse response
)>;
35 // Initializes a tab-modal dialog for |web_contents| and |requesting_origin|
36 // and shows it. Returns a non-owning pointer to the widget so that caller can
37 // close the dialog and cancel the request. The returned widget is only
38 // guaranteed to be valid before |callback| is called.
39 static views::Widget
* ShowDialog(content::WebContents
* web_contents
,
40 const GURL
& requesting_origin
,
41 const ConsentCallback
& callback
);
44 ~PlatformVerificationDialog() override
;
47 PlatformVerificationDialog(content::WebContents
* web_contents
,
48 const base::string16
& domain
,
49 const ConsentCallback
& callback
);
51 // views::DialogDelegate:
52 bool Cancel() override
;
53 bool Accept() override
;
54 bool Close() override
;
55 base::string16
GetDialogButtonLabel(ui::DialogButton button
) const override
;
57 // views::WidgetDelegate:
58 ui::ModalType
GetModalType() const override
;
61 gfx::Size
GetPreferredSize() const override
;
63 // views::StyledLabelListener:
64 void StyledLabelLinkClicked(const gfx::Range
& range
,
65 int event_flags
) override
;
67 // content::WebContentsObserver:
68 void DidStartNavigationToPendingEntry(
70 content::NavigationController::ReloadType reload_type
) override
;
72 base::string16 domain_
;
73 ConsentCallback callback_
;
75 DISALLOW_COPY_AND_ASSIGN(PlatformVerificationDialog
);
78 } // namespace attestation
79 } // namespace chromeos
81 #endif // CHROME_BROWSER_CHROMEOS_ATTESTATION_PLATFORM_VERIFICATION_DIALOG_H_