OLD | NEW |
| (Empty) |
1 // Copyright 2016 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_CHROMEOS_ARC_ARC_AUTH_UI_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_UI_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "components/arc/auth/arc_auth_fetcher.h" | |
10 #include "ui/web_dialogs/web_dialog_delegate.h" | |
11 | |
12 namespace content { | |
13 class BrowserContext; | |
14 } | |
15 | |
16 namespace views { | |
17 class Widget; | |
18 } | |
19 | |
20 namespace arc { | |
21 | |
22 // Shows ARC LSO web view that requires user input. | |
23 class ArcAuthUI : public ui::WebDialogDelegate, | |
24 public ArcAuthFetcher::Delegate { | |
25 public: | |
26 class Delegate { | |
27 public: | |
28 // Called when dialog is closed. | |
29 virtual void OnAuthUIClosed() = 0; | |
30 | |
31 protected: | |
32 virtual ~Delegate() = default; | |
33 }; | |
34 | |
35 ArcAuthUI(content::BrowserContext* browser_context, Delegate* delegate); | |
36 ~ArcAuthUI() override; | |
37 | |
38 void Close(); | |
39 | |
40 // ui::WebDialogDelegate: | |
41 ui::ModalType GetDialogModalType() const override; | |
42 base::string16 GetDialogTitle() const override; | |
43 GURL GetDialogContentURL() const override; | |
44 void GetWebUIMessageHandlers( | |
45 std::vector<content::WebUIMessageHandler*>* handlers) const override; | |
46 void GetDialogSize(gfx::Size* size) const override; | |
47 std::string GetDialogArgs() const override; | |
48 void OnDialogClosed(const std::string& json_retval) override; | |
49 void OnCloseContents(content::WebContents* source, | |
50 bool* out_close_dialog) override; | |
51 bool ShouldShowDialogTitle() const override; | |
52 bool HandleContextMenu(const content::ContextMenuParams& params) override; | |
53 void OnLoadingStateChanged(content::WebContents* source) override; | |
54 | |
55 // ArcAuthFetcher::Delegate: | |
56 void OnAuthCodeFetched(const std::string& code) override; | |
57 void OnAuthCodeNeedUI() override; | |
58 void OnAuthCodeFailed() override; | |
59 | |
60 private: | |
61 // Unowned pointers. | |
62 content::BrowserContext* const browser_context_; | |
63 Delegate* const delegate_; | |
64 const GURL target_url_; | |
65 | |
66 // Owned by view hierarchy. | |
67 views::Widget* widget_; | |
68 | |
69 scoped_ptr<ArcAuthFetcher> auth_fetcher_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(ArcAuthUI); | |
72 }; | |
73 | |
74 } // namespace arc | |
75 | |
76 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_UI_H_ | |
OLD | NEW |