Chromium Code Reviews| Index: chrome/browser/ui/views/extensions/web_auth_flow_window_views.cc |
| =================================================================== |
| --- chrome/browser/ui/views/extensions/web_auth_flow_window_views.cc (revision 0) |
| +++ chrome/browser/ui/views/extensions/web_auth_flow_window_views.cc (revision 0) |
| @@ -0,0 +1,60 @@ |
| +// Copyright (c) 2012 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/ui/views/extensions/web_auth_flow_window_views.h" |
| + |
| +#include "ui/views/controls/webview/webview.h" |
| +#include "ui/views/widget/widget.h" |
| + |
| +using content::BrowserContext; |
| +using content::WebContents; |
| +using views::View; |
| +using views::WebView; |
| +using views::Widget; |
| +using views::WidgetDelegate; |
| + |
| +WebAuthFlowWindowViews::WebAuthFlowWindowViews( |
| + Delegate* delegate, |
| + BrowserContext* browser_context, |
| + WebContents* contents) |
| + : WebAuthFlowWindow(delegate, browser_context, contents), |
| + web_view_(NULL), |
| + widget_(NULL) { |
| +} |
| + |
| +WebAuthFlowWindowViews::~WebAuthFlowWindowViews() { |
|
sky
2012/05/16 23:17:11
Make order match header.
Munjal (Google)
2012/05/16 23:33:44
Done.
Munjal (Google)
2012/05/16 23:33:44
Done.
|
| + if (widget_) |
| + widget_->Close(); // This also deletes the widget. |
| +} |
| + |
| +void WebAuthFlowWindowViews::Show() { |
| + web_view_ = new WebView(browser_context_); |
| + web_view_->SetWebContents(contents_); |
| + widget_ = Widget::CreateWindow(this); |
| + widget_->CenterWindow(gfx::Size(kDefaultWidth, kDefaultHeight)); |
| + widget_->Show(); |
| +} |
| + |
| +views::View* WebAuthFlowWindowViews::GetContentsView() { |
| + CHECK(web_view_); |
|
sky
2012/05/16 23:17:11
Use DCHECK for these.
Munjal (Google)
2012/05/16 23:33:44
Done.
|
| + return web_view_; |
| +} |
| + |
| +views::View* WebAuthFlowWindowViews::GetInitiallyFocusedView() { |
| + CHECK(web_view_); |
| + return web_view_; |
| +} |
| + |
| +void WebAuthFlowWindowViews::DeleteDelegate() { |
| + if (delegate_) |
| + delegate_->OnClose(); |
| +} |
| + |
| +// static |
| +WebAuthFlowWindow* WebAuthFlowWindow::Create( |
| + Delegate* delegate, |
| + BrowserContext* browser_context, |
| + WebContents* contents) { |
| + return new WebAuthFlowWindowViews(delegate, browser_context, contents); |
| +} |