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

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

Issue 1681813003: arc: Use incognito profile for OptIn and cookie fetcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased, added reseting windowClosedInternally before window creation 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/ui/webui/chrome_web_contents_handler.h"
9 #include "content/public/browser/browser_context.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(content::BrowserContext* browser_context,
25 Delegate* delegate)
26 : browser_context_(browser_context),
27 delegate_(delegate),
28 target_url_(ArcAuthFetcher::CreateURL()) {
29 DCHECK(browser_context_ && delegate_);
30 views::WebDialogView* view = new views::WebDialogView(
31 browser_context_, this, new ChromeWebContentsHandler);
32 widget_ = views::Widget::CreateWindow(view);
33 widget_->Show();
34 }
35
36 ArcAuthUI::~ArcAuthUI() {}
37
38 void ArcAuthUI::Close() {
39 widget_->CloseNow();
40 }
41
42 ui::ModalType ArcAuthUI::GetDialogModalType() const {
43 return ui::MODAL_TYPE_SYSTEM;
44 }
45
46 base::string16 ArcAuthUI::GetDialogTitle() const {
47 return base::string16();
48 }
49
50 GURL ArcAuthUI::GetDialogContentURL() const {
51 return target_url_;
52 }
53
54 void ArcAuthUI::GetWebUIMessageHandlers(
55 std::vector<content::WebUIMessageHandler*>* handlers) const {}
56
57 void ArcAuthUI::GetDialogSize(gfx::Size* size) const {
58 size->SetSize(kDefaultWidth, kDefaultHeight);
59 }
60
61 std::string ArcAuthUI::GetDialogArgs() const {
62 return std::string();
63 }
64
65 void ArcAuthUI::OnDialogClosed(const std::string& json_retval) {
66 delegate_->OnAuthUIClosed();
67 delete this;
68 }
69
70 void ArcAuthUI::OnCloseContents(content::WebContents* source,
71 bool* out_close_dialog) {
72 *out_close_dialog = true;
73 }
74
75 bool ArcAuthUI::ShouldShowDialogTitle() const {
76 return false;
77 }
78
79 bool ArcAuthUI::HandleContextMenu(const content::ContextMenuParams& params) {
80 // Disable context menu.
81 return true;
82 }
83
84 void ArcAuthUI::OnLoadingStateChanged(content::WebContents* source) {
85 if (source->IsLoading())
86 return;
87
88 // Check if current page may contain required cookies and skip intermediate
89 // steps.
90 const GURL& current_url = source->GetVisibleURL();
91 if (target_url_.GetOrigin() != current_url.GetOrigin() ||
92 target_url_.path() != current_url.path()) {
93 return;
94 }
95
96 auth_fetcher_.reset(
97 new ArcAuthFetcher(browser_context_->GetRequestContext(), this));
98 }
99
100 void ArcAuthUI::OnAuthCodeFetched(const std::string& auth_code) {
101 ArcAuthService::Get()->SetAuthCodeAndStartArc(auth_code);
102 }
103
104 void ArcAuthUI::OnAuthCodeNeedUI() {}
105
106 void ArcAuthUI::OnAuthCodeFailed() {}
107
108 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698