OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/login/ui/captive_portal_window_proxy.h" | 5 #include "chrome/browser/chromeos/login/ui/captive_portal_window_proxy.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "chrome/browser/chromeos/login/ui/captive_portal_view.h" | 8 #include "chrome/browser/chromeos/login/ui/captive_portal_view.h" |
9 #include "chrome/browser/chromeos/login/ui/proxy_settings_dialog.h" | 9 #include "chrome/browser/chromeos/login/ui/proxy_settings_dialog.h" |
10 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 11 #include "components/constrained_window/constrained_window_views.h" |
11 #include "components/web_modal/web_contents_modal_dialog_host.h" | 12 #include "components/web_modal/web_contents_modal_dialog_host.h" |
12 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 13 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
13 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 14 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
14 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 // The captive portal dialog is system-modal, but uses the web-content-modal | 19 // The captive portal dialog is system-modal, but uses the web-content-modal |
19 // dialog manager (odd) and requires this atypical dialog widget initialization. | 20 // dialog manager (odd) and requires this atypical dialog widget initialization. |
20 views::Widget* CreateWindowAsFramelessChild(views::WidgetDelegate* delegate, | 21 views::Widget* CreateWindowAsFramelessChild(views::WidgetDelegate* delegate, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 InitCaptivePortalView(); | 75 InitCaptivePortalView(); |
75 | 76 |
76 CaptivePortalView* portal = captive_portal_view_.release(); | 77 CaptivePortalView* portal = captive_portal_view_.release(); |
77 auto* manager = | 78 auto* manager = |
78 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents_); | 79 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents_); |
79 widget_ = CreateWindowAsFramelessChild( | 80 widget_ = CreateWindowAsFramelessChild( |
80 portal, | 81 portal, |
81 manager->delegate()->GetWebContentsModalDialogHost()->GetHostView()); | 82 manager->delegate()->GetWebContentsModalDialogHost()->GetHostView()); |
82 portal->Init(); | 83 portal->Init(); |
83 widget_->AddObserver(this); | 84 widget_->AddObserver(this); |
84 manager->ShowModalDialog(widget_->GetNativeView()); | 85 constrained_window::ShowModalDialog(widget_->GetNativeView(), web_contents_); |
85 } | 86 } |
86 | 87 |
87 void CaptivePortalWindowProxy::Close() { | 88 void CaptivePortalWindowProxy::Close() { |
88 if (GetState() == STATE_DISPLAYED) | 89 if (GetState() == STATE_DISPLAYED) |
89 widget_->Close(); | 90 widget_->Close(); |
90 captive_portal_view_.reset(); | 91 captive_portal_view_.reset(); |
91 captive_portal_view_for_testing_ = NULL; | 92 captive_portal_view_for_testing_ = NULL; |
92 } | 93 } |
93 | 94 |
94 void CaptivePortalWindowProxy::OnRedirected() { | 95 void CaptivePortalWindowProxy::OnRedirected() { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 } | 154 } |
154 | 155 |
155 void CaptivePortalWindowProxy::DetachFromWidget(views::Widget* widget) { | 156 void CaptivePortalWindowProxy::DetachFromWidget(views::Widget* widget) { |
156 if (!widget_ || widget_ != widget) | 157 if (!widget_ || widget_ != widget) |
157 return; | 158 return; |
158 widget_->RemoveObserver(this); | 159 widget_->RemoveObserver(this); |
159 widget_ = NULL; | 160 widget_ = NULL; |
160 } | 161 } |
161 | 162 |
162 } // namespace chromeos | 163 } // namespace chromeos |
OLD | NEW |