OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/captive_portal_window_proxy.h" | 5 #include "chrome/browser/chromeos/login/captive_portal_window_proxy.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/login/captive_portal_view.h" | 7 #include "chrome/browser/chromeos/login/captive_portal_view.h" |
8 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" | 8 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" |
9 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
10 #include "components/web_modal/web_contents_modal_dialog_host.h" | 10 #include "components/web_modal/web_contents_modal_dialog_host.h" |
11 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 11 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
12 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 12 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
14 | 14 |
15 using web_modal::WebContentsModalDialogManager; | 15 using web_modal::WebContentsModalDialogManager; |
16 using web_modal::WebContentsModalDialogManagerDelegate; | 16 using web_modal::WebContentsModalDialogManagerDelegate; |
17 | 17 |
18 namespace chromeos { | 18 namespace chromeos { |
19 | 19 |
20 CaptivePortalWindowProxy::CaptivePortalWindowProxy( | 20 CaptivePortalWindowProxy::CaptivePortalWindowProxy( |
21 Delegate* delegate, | 21 Delegate* delegate, |
22 gfx::NativeWindow parent, | |
23 content::WebContents* web_contents) | 22 content::WebContents* web_contents) |
24 : delegate_(delegate), | 23 : delegate_(delegate), |
25 widget_(NULL), | 24 widget_(NULL), |
26 parent_(parent), | |
27 web_contents_(web_contents) { | 25 web_contents_(web_contents) { |
28 DCHECK(GetState() == STATE_IDLE); | 26 DCHECK(GetState() == STATE_IDLE); |
29 } | 27 } |
30 | 28 |
31 CaptivePortalWindowProxy::~CaptivePortalWindowProxy() { | 29 CaptivePortalWindowProxy::~CaptivePortalWindowProxy() { |
32 if (!widget_) | 30 if (!widget_) |
33 return; | 31 return; |
34 DCHECK(GetState() == STATE_DISPLAYED); | 32 DCHECK(GetState() == STATE_DISPLAYED); |
35 widget_->RemoveObserver(this); | 33 widget_->RemoveObserver(this); |
36 widget_->Close(); | 34 widget_->Close(); |
(...skipping 18 matching lines...) Expand all Loading... |
55 | 53 |
56 InitCaptivePortalView(); | 54 InitCaptivePortalView(); |
57 | 55 |
58 CaptivePortalView* captive_portal_view = captive_portal_view_.release(); | 56 CaptivePortalView* captive_portal_view = captive_portal_view_.release(); |
59 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 57 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
60 WebContentsModalDialogManager::FromWebContents(web_contents_); | 58 WebContentsModalDialogManager::FromWebContents(web_contents_); |
61 DCHECK(web_contents_modal_dialog_manager); | 59 DCHECK(web_contents_modal_dialog_manager); |
62 WebContentsModalDialogManagerDelegate* delegate = | 60 WebContentsModalDialogManagerDelegate* delegate = |
63 web_contents_modal_dialog_manager->delegate(); | 61 web_contents_modal_dialog_manager->delegate(); |
64 DCHECK(delegate); | 62 DCHECK(delegate); |
65 | |
66 widget_ = views::Widget::CreateWindowAsFramelessChild( | 63 widget_ = views::Widget::CreateWindowAsFramelessChild( |
67 captive_portal_view, | 64 captive_portal_view, |
68 parent_, | |
69 delegate->GetWebContentsModalDialogHost()->GetHostView()); | 65 delegate->GetWebContentsModalDialogHost()->GetHostView()); |
70 captive_portal_view->Init(); | 66 captive_portal_view->Init(); |
71 | 67 |
72 widget_->AddObserver(this); | 68 widget_->AddObserver(this); |
73 web_contents_modal_dialog_manager->ShowDialog(widget_->GetNativeView()); | 69 web_contents_modal_dialog_manager->ShowDialog(widget_->GetNativeView()); |
74 DCHECK(GetState() == STATE_DISPLAYED); | 70 DCHECK(GetState() == STATE_DISPLAYED); |
75 } | 71 } |
76 | 72 |
77 void CaptivePortalWindowProxy::Close() { | 73 void CaptivePortalWindowProxy::Close() { |
78 if (GetState() == STATE_DISPLAYED) | 74 if (GetState() == STATE_DISPLAYED) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 } else { | 115 } else { |
120 if (captive_portal_view_.get() == NULL) | 116 if (captive_portal_view_.get() == NULL) |
121 return STATE_DISPLAYED; | 117 return STATE_DISPLAYED; |
122 else | 118 else |
123 NOTREACHED(); | 119 NOTREACHED(); |
124 } | 120 } |
125 return STATE_UNKNOWN; | 121 return STATE_UNKNOWN; |
126 } | 122 } |
127 | 123 |
128 } // namespace chromeos | 124 } // namespace chromeos |
OLD | NEW |