Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 54 return; | 52 return; |
| 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); | |
|
msw
2013/11/16 04:15:44
I restored this one too.
| |
| 65 | |
| 66 widget_ = views::Widget::CreateWindowAsFramelessChild( | 62 widget_ = views::Widget::CreateWindowAsFramelessChild( |
| 67 captive_portal_view, | 63 captive_portal_view, |
| 68 parent_, | |
| 69 delegate->GetWebContentsModalDialogHost()->GetHostView()); | 64 delegate->GetWebContentsModalDialogHost()->GetHostView()); |
| 70 captive_portal_view->Init(); | 65 captive_portal_view->Init(); |
| 71 | 66 |
| 72 widget_->AddObserver(this); | 67 widget_->AddObserver(this); |
| 73 web_contents_modal_dialog_manager->ShowDialog(widget_->GetNativeView()); | 68 web_contents_modal_dialog_manager->ShowDialog(widget_->GetNativeView()); |
| 74 DCHECK(GetState() == STATE_DISPLAYED); | 69 DCHECK(GetState() == STATE_DISPLAYED); |
| 75 } | 70 } |
| 76 | 71 |
| 77 void CaptivePortalWindowProxy::Close() { | 72 void CaptivePortalWindowProxy::Close() { |
| 78 if (GetState() == STATE_DISPLAYED) | 73 if (GetState() == STATE_DISPLAYED) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 } else { | 114 } else { |
| 120 if (captive_portal_view_.get() == NULL) | 115 if (captive_portal_view_.get() == NULL) |
| 121 return STATE_DISPLAYED; | 116 return STATE_DISPLAYED; |
| 122 else | 117 else |
| 123 NOTREACHED(); | 118 NOTREACHED(); |
| 124 } | 119 } |
| 125 return STATE_UNKNOWN; | 120 return STATE_UNKNOWN; |
| 126 } | 121 } |
| 127 | 122 |
| 128 } // namespace chromeos | 123 } // namespace chromeos |
| OLD | NEW |