Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_ui.cc

Issue 1618193003: arc: Pass auth token from Chrome to ARC instance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactored. Added LSO UI Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #include "chrome/browser/chromeos/arc/arc_auth_ui.h"
6
7 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
10 #include "content/public/browser/web_contents.h"
11 #include "net/base/load_states.h"
12 #include "ui/views/controls/webview/web_dialog_view.h"
13 #include "ui/views/widget/widget.h"
14
15 namespace arc {
16
17 namespace {
18
19 const int kDefaultWidth = 480;
20 const int kDefaultHeight = 640;
21
22 } // namespace
23
24 ArcAuthUI::ArcAuthUI(Profile* profile, Delegate* delegate)
25 : profile_(profile), delegate_(delegate) {
26 DCHECK(profile_ != nullptr && delegate_ != nullptr);
27 views::WebDialogView* view =
28 new views::WebDialogView(profile_, this, new ChromeWebContentsHandler);
29 widget_ = views::Widget::CreateWindow(view);
30 widget_->Show();
31 }
32
33 ArcAuthUI::~ArcAuthUI() {}
34
35 void ArcAuthUI::Close() {
36 widget_->CloseNow();
37 }
38
39 ui::ModalType ArcAuthUI::GetDialogModalType() const {
40 return ui::MODAL_TYPE_SYSTEM;
41 }
42
43 base::string16 ArcAuthUI::GetDialogTitle() const {
44 return base::string16();
45 }
46
47 GURL ArcAuthUI::GetDialogContentURL() const {
48 return ArcAuthFetcher::CreateURL(profile_);
49 }
50
51 void ArcAuthUI::GetWebUIMessageHandlers(
52 std::vector<content::WebUIMessageHandler*>* handlers) const {}
53
54 void ArcAuthUI::GetDialogSize(gfx::Size* size) const {
55 size->SetSize(kDefaultWidth, kDefaultHeight);
56 }
57
58 std::string ArcAuthUI::GetDialogArgs() const {
59 return std::string();
60 }
61
62 void ArcAuthUI::OnDialogClosed(const std::string& json_retval) {
63 delegate_->OnAuthUIClosed();
64 delete this;
65 }
66
67 void ArcAuthUI::OnCloseContents(content::WebContents* source,
68 bool* out_close_dialog) {
69 *out_close_dialog = true;
70 }
71
72 bool ArcAuthUI::ShouldShowDialogTitle() const {
73 return false;
74 }
75
76 bool ArcAuthUI::HandleContextMenu(const content::ContextMenuParams& params) {
77 // Disable context menu.
78 return true;
79 }
80
81 void ArcAuthUI::OnLoadingStateChanged(content::WebContents* source) {
82 // Check an auth code whenever page is reloaded.
83 if (source->GetLoadState().state == net::LoadState::LOAD_STATE_IDLE)
84 auth_fetcher_.reset(new ArcAuthFetcher(profile_, this));
85 }
86
87 void ArcAuthUI::OnAuthCodeFetched(const std::string& auth_code) {
88 ArcAuthService::Get()->SetAuthCodeAndStartArc(auth_code);
89 }
90
91 void ArcAuthUI::OnAuthCodeNeedUI() {}
92
93 void ArcAuthUI::OnAuthCodeFailed() {}
94
95 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698