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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/arc/arc_auth_ui.cc
diff --git a/chrome/browser/chromeos/arc/arc_auth_ui.cc b/chrome/browser/chromeos/arc/arc_auth_ui.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a07d12cce3c4bea85ef9625bd92949681fff483b
--- /dev/null
+++ b/chrome/browser/chromeos/arc/arc_auth_ui.cc
@@ -0,0 +1,95 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/arc/arc_auth_ui.h"
+
+#include "chrome/browser/chromeos/arc/arc_auth_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
+#include "content/public/browser/web_contents.h"
+#include "net/base/load_states.h"
+#include "ui/views/controls/webview/web_dialog_view.h"
+#include "ui/views/widget/widget.h"
+
+namespace arc {
+
+namespace {
+
+const int kDefaultWidth = 480;
+const int kDefaultHeight = 640;
+
+} // namespace
+
+ArcAuthUI::ArcAuthUI(Profile* profile, Delegate* delegate)
+ : profile_(profile), delegate_(delegate) {
+ DCHECK(profile_ != nullptr && delegate_ != nullptr);
+ views::WebDialogView* view =
+ new views::WebDialogView(profile_, this, new ChromeWebContentsHandler);
+ widget_ = views::Widget::CreateWindow(view);
+ widget_->Show();
+}
+
+ArcAuthUI::~ArcAuthUI() {}
+
+void ArcAuthUI::Close() {
+ widget_->CloseNow();
+}
+
+ui::ModalType ArcAuthUI::GetDialogModalType() const {
+ return ui::MODAL_TYPE_SYSTEM;
+}
+
+base::string16 ArcAuthUI::GetDialogTitle() const {
+ return base::string16();
+}
+
+GURL ArcAuthUI::GetDialogContentURL() const {
+ return ArcAuthFetcher::CreateURL(profile_);
+}
+
+void ArcAuthUI::GetWebUIMessageHandlers(
+ std::vector<content::WebUIMessageHandler*>* handlers) const {}
+
+void ArcAuthUI::GetDialogSize(gfx::Size* size) const {
+ size->SetSize(kDefaultWidth, kDefaultHeight);
+}
+
+std::string ArcAuthUI::GetDialogArgs() const {
+ return std::string();
+}
+
+void ArcAuthUI::OnDialogClosed(const std::string& json_retval) {
+ delegate_->OnAuthUIClosed();
+ delete this;
+}
+
+void ArcAuthUI::OnCloseContents(content::WebContents* source,
+ bool* out_close_dialog) {
+ *out_close_dialog = true;
+}
+
+bool ArcAuthUI::ShouldShowDialogTitle() const {
+ return false;
+}
+
+bool ArcAuthUI::HandleContextMenu(const content::ContextMenuParams& params) {
+ // Disable context menu.
+ return true;
+}
+
+void ArcAuthUI::OnLoadingStateChanged(content::WebContents* source) {
+ // Check an auth code whenever page is reloaded.
+ if (source->GetLoadState().state == net::LoadState::LOAD_STATE_IDLE)
+ auth_fetcher_.reset(new ArcAuthFetcher(profile_, this));
+}
+
+void ArcAuthUI::OnAuthCodeFetched(const std::string& auth_code) {
+ ArcAuthService::Get()->SetAuthCodeAndStartArc(auth_code);
+}
+
+void ArcAuthUI::OnAuthCodeNeedUI() {}
+
+void ArcAuthUI::OnAuthCodeFailed() {}
+
+} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698