Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / chromeos / attestation / platform_verification_dialog.h
blob29675061c4aa5434b2e6f26414af896d74b3a44e
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"
15 namespace content {
16 class WebContents;
19 namespace chromeos {
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 {
26 public:
27 enum ConsentResponse {
28 CONSENT_RESPONSE_NONE,
29 CONSENT_RESPONSE_ALLOW,
30 CONSENT_RESPONSE_DENY
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);
43 protected:
44 ~PlatformVerificationDialog() override;
46 private:
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;
60 // views::View:
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(
69 const GURL& url,
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_