Commit 7248a981 authored by munjal@chromium.org's avatar munjal@chromium.org

Remove WebAuthFlowWindow and its implementation on all platforms. We don't...

Remove WebAuthFlowWindow and its implementation on all platforms. We don't need it anymore since we now use browser popups.

TBR=ben

Review URL: https://chromiumcodereview.appspot.com/10823149

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149774 0039d316-1c4b-4281-b951-d872f2087c98
parent 2624ac22
// 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.
#ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_WEB_AUTH_FLOW_WINDOW_COCOA_H_
#define CHROME_BROWSER_UI_COCOA_EXTENSIONS_WEB_AUTH_FLOW_WINDOW_COCOA_H_
#import <Cocoa/Cocoa.h>
#include "base/memory/scoped_nsobject.h"
#include "chrome/browser/ui/extensions/web_auth_flow_window.h"
namespace content {
class BrowserContext;
class WebContents;
}
@class WebAuthFlowWindowController;
// Cocoa bridge to WebAuthFlowWindow.
class WebAuthFlowWindowCocoa : public WebAuthFlowWindow {
public:
WebAuthFlowWindowCocoa(
Delegate* delegate,
content::BrowserContext* browser_context,
content::WebContents* contents);
// WebAuthFlowWindow implementation.
virtual void Show() OVERRIDE;
// Called when the window is about to be closed.
void WindowWillClose();
private:
virtual ~WebAuthFlowWindowCocoa();
scoped_nsobject<WebAuthFlowWindowController> window_controller_;
NSInteger attention_request_id_; // identifier from requestUserAttention
DISALLOW_COPY_AND_ASSIGN(WebAuthFlowWindowCocoa);
};
#endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_WEB_AUTH_FLOW_WINDOW_COCOA_H_
// 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/cocoa/extensions/web_auth_flow_window_cocoa.h"
#include "base/sys_string_conversions.h"
#include "chrome/browser/ui/cocoa/browser_window_utils.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
// A window controller for a minimal window to host a web app view. Passes
// Objective-C notifications to the C++ bridge.
@interface WebAuthFlowWindowController
: NSWindowController<NSWindowDelegate> {
@private
WebAuthFlowWindowCocoa* webAuthWindow_; // Weak; owns self.
}
@property(assign, nonatomic) WebAuthFlowWindowCocoa* webAuthWindow;
@end
@implementation WebAuthFlowWindowController
@synthesize webAuthWindow = webAuthWindow_;
- (void)windowWillClose:(NSNotification*)notification {
if (webAuthWindow_)
webAuthWindow_->WindowWillClose();
}
@end
WebAuthFlowWindowCocoa::WebAuthFlowWindowCocoa(
Delegate* delegate,
content::BrowserContext* browser_context,
content::WebContents* contents)
: WebAuthFlowWindow(delegate, browser_context, contents),
attention_request_id_(0) {
}
void WebAuthFlowWindowCocoa::Show() {
NSRect rect = NSMakeRect(0, 0, kDefaultWidth, kDefaultHeight);
NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask;
scoped_nsobject<NSWindow> window([[UnderlayOpenGLHostingWindow alloc]
initWithContentRect:rect
styleMask:styleMask
backing:NSBackingStoreBuffered
defer:NO]);
NSView* view = contents()->GetView()->GetNativeView();
[view setFrame:rect];
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[[window contentView] addSubview:view];
window_controller_.reset(
[[WebAuthFlowWindowController alloc] initWithWindow:window.release()]);
[[window_controller_ window] setDelegate:window_controller_];
[window_controller_ setWebAuthWindow:this];
[[window_controller_ window] center];
[window_controller_ showWindow:nil];
}
void WebAuthFlowWindowCocoa::WindowWillClose() {
if (delegate())
delegate()->OnClose();
}
WebAuthFlowWindowCocoa::~WebAuthFlowWindowCocoa() {
[window_controller_ setWebAuthWindow:NULL];
[window_controller_ close];
}
// static
WebAuthFlowWindow* WebAuthFlowWindow::Create(
Delegate* delegate,
content::BrowserContext* browser_context,
content::WebContents* contents) {
return new WebAuthFlowWindowCocoa(delegate, browser_context, contents);
}
// 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/extensions/web_auth_flow_window.h"
#include "content/public/browser/browser_context.h"
using content::BrowserContext;
using content::WebContents;
WebAuthFlowWindow::~WebAuthFlowWindow() {
}
WebAuthFlowWindow::WebAuthFlowWindow(
Delegate* delegate,
BrowserContext* browser_context,
WebContents* contents)
: delegate_(delegate),
browser_context_(browser_context),
contents_(contents) {
}
// 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.
#ifndef CHROME_BROWSER_UI_EXTENSIONS_WEB_AUTH_FLOW_WINDOW_H_
#define CHROME_BROWSER_UI_EXTENSIONS_WEB_AUTH_FLOW_WINDOW_H_
#include "base/basictypes.h"
class Profile;
namespace content {
class BrowserContext;
class WebContents;
}
// Platform independent abstraction for a window that performs web auth flow.
// Platform specific implementations implement this abstract class.
class WebAuthFlowWindow {
public:
class Delegate {
public:
virtual void OnClose() = 0;
};
// TODO(munjal): Allow customizing these?
static const int kDefaultWidth = 1024;
static const int kDefaultHeight = 768;
// Creates a new instance of WebAuthFlowWindow with the given parmaters.
// Delegate::OnClose will be called when the window is closed.
static WebAuthFlowWindow* Create(Delegate* delegate,
content::BrowserContext* browser_context,
content::WebContents* contents);
virtual ~WebAuthFlowWindow();
// Show the window.
virtual void Show() = 0;
protected:
WebAuthFlowWindow(Delegate* delegate,
content::BrowserContext* browser_context,
content::WebContents* contents);
Delegate* delegate() { return delegate_; }
content::BrowserContext* browser_context() { return browser_context_; }
content::WebContents* contents() { return contents_; }
private:
Delegate* delegate_;
content::BrowserContext* browser_context_;
content::WebContents* contents_;
DISALLOW_COPY_AND_ASSIGN(WebAuthFlowWindow);
};
#endif // CHROME_BROWSER_UI_EXTENSIONS_WEB_AUTH_FLOW_WINDOW_H_
// 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/gtk/extensions/web_auth_flow_window_gtk.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "ui/gfx/native_widget_types.h"
using content::BrowserContext;
using content::WebContents;
WebAuthFlowWindowGtk::WebAuthFlowWindowGtk(
Delegate* delegate,
BrowserContext* browser_context,
WebContents* contents)
: WebAuthFlowWindow(delegate, browser_context, contents),
window_(NULL) {
}
void WebAuthFlowWindowGtk::Show() {
window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
gfx::NativeView native_view = contents()->GetView()->GetNativeView();
gtk_container_add(GTK_CONTAINER(window_), native_view);
gtk_window_set_default_size(window_, kDefaultWidth, kDefaultHeight);
g_signal_connect(window_, "delete-event",
G_CALLBACK(OnMainWindowDeleteEventThunk), this);
gtk_window_present(window_);
}
WebAuthFlowWindowGtk::~WebAuthFlowWindowGtk() {
if (window_)
gtk_widget_destroy(GTK_WIDGET(window_));
}
// Callback for the delete event. This event is fired when the user tries to
// close the window (e.g., clicking on the X in the window manager title bar).
gboolean WebAuthFlowWindowGtk::OnMainWindowDeleteEvent(
GtkWidget* widget, GdkEvent* event) {
if (delegate())
delegate()->OnClose();
// Return FALSE to tell the caller to delete the window.
return FALSE;
}
// static
WebAuthFlowWindow* WebAuthFlowWindow::Create(
Delegate* delegate,
BrowserContext* browser_context,
WebContents* contents) {
return new WebAuthFlowWindowGtk(delegate, browser_context, contents);
}
// 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.
#ifndef CHROME_BROWSER_UI_GTK_EXTENSIONS_WEB_AUTH_FLOW_WINDOW_GTK_H_
#define CHROME_BROWSER_UI_GTK_EXTENSIONS_WEB_AUTH_FLOW_WINDOW_GTK_H_
#include <gtk/gtk.h>
#include "base/compiler_specific.h"
#include "chrome/browser/ui/extensions/web_auth_flow_window.h"
#include "ui/base/gtk/gtk_signal.h"
namespace content {
class BrowserContext;
class WebContents;
}
class WebAuthFlowWindowGtk : public WebAuthFlowWindow {
public:
WebAuthFlowWindowGtk(Delegate* delegate,
content::BrowserContext* browser_context,
content::WebContents* contents);
// WebAuthFlowWindow implementation.
virtual void Show() OVERRIDE;
private:
virtual ~WebAuthFlowWindowGtk();
CHROMEGTK_CALLBACK_1(WebAuthFlowWindowGtk, gboolean, OnMainWindowDeleteEvent,
GdkEvent*);
GtkWindow* window_;
DISALLOW_COPY_AND_ASSIGN(WebAuthFlowWindowGtk);
};
#endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_WEB_AUTH_FLOW_WINDOW_GTK_H_
// 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) {
}
views::View* WebAuthFlowWindowViews::GetContentsView() {
DCHECK(web_view_);
return web_view_;
}
views::View* WebAuthFlowWindowViews::GetInitiallyFocusedView() {
DCHECK(web_view_);
return web_view_;
}
void WebAuthFlowWindowViews::DeleteDelegate() {
if (delegate())
delegate()->OnClose();
}
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();
}
WebAuthFlowWindowViews::~WebAuthFlowWindowViews() {
if (widget_)
widget_->Close(); // This also deletes the widget.
}
// static
WebAuthFlowWindow* WebAuthFlowWindow::Create(
Delegate* delegate,
BrowserContext* browser_context,
WebContents* contents) {
return new WebAuthFlowWindowViews(delegate, browser_context, contents);
}
// 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.
#ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_WEB_AUTH_FLOW_WINDOW_VIEWS_H_
#define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_WEB_AUTH_FLOW_WINDOW_VIEWS_H_
#include "chrome/browser/ui/extensions/web_auth_flow_window.h"
#include "ui/gfx/rect.h"
#include "ui/views/widget/widget_delegate.h"
namespace content {
class BrowserContext;
class WebContents;
}
namespace views {
class View;
class WebView;
class Widget;
}
class WebAuthFlowWindowViews : public WebAuthFlowWindow,
public views::WidgetDelegateView {
public:
WebAuthFlowWindowViews(
Delegate* delegate,
content::BrowserContext* browser_context,
content::WebContents* contents);
// WidgetDelegate implementation.
virtual views::View* GetContentsView() OVERRIDE;
virtual views::View* GetInitiallyFocusedView() OVERRIDE;
virtual void DeleteDelegate() OVERRIDE;
// WebAuthFlowWindow implementation.
virtual void Show() OVERRIDE;
private:
virtual ~WebAuthFlowWindowViews();
views::WebView* web_view_;
views::Widget* widget_;
DISALLOW_COPY_AND_ASSIGN(WebAuthFlowWindowViews);
};
#endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_WEB_AUTH_FLOW_WINDOW_VIEWS_H_
......@@ -2704,8 +2704,6 @@
'browser/ui/cocoa/extensions/extension_view_mac.mm',
'browser/ui/cocoa/extensions/shell_window_cocoa.h',
'browser/ui/cocoa/extensions/shell_window_cocoa.mm',
'browser/ui/cocoa/extensions/web_auth_flow_window_cocoa.h',
'browser/ui/cocoa/extensions/web_auth_flow_window_cocoa.mm',
'browser/ui/cocoa/external_protocol_dialog.h',
'browser/ui/cocoa/external_protocol_dialog.mm',
'browser/ui/cocoa/fast_resize_view.h',
......@@ -2995,8 +2993,6 @@
'browser/ui/extensions/application_launch.h',
'browser/ui/extensions/shell_window.cc',
'browser/ui/extensions/shell_window.h',
'browser/ui/extensions/web_auth_flow_window.cc',
'browser/ui/extensions/web_auth_flow_window.h',
'browser/ui/find_bar/find_bar.h',
'browser/ui/find_bar/find_bar_controller.cc',
'browser/ui/find_bar/find_bar_controller.h',
......@@ -3113,8 +3109,6 @@
'browser/ui/gtk/extensions/extension_view_gtk.h',
'browser/ui/gtk/extensions/shell_window_gtk.cc',
'browser/ui/gtk/extensions/shell_window_gtk.h',
'browser/ui/gtk/extensions/web_auth_flow_window_gtk.cc',
'browser/ui/gtk/extensions/web_auth_flow_window_gtk.h',
'browser/ui/gtk/external_protocol_dialog_gtk.cc',
'browser/ui/gtk/external_protocol_dialog_gtk.h',
'browser/ui/gtk/find_bar_gtk.cc',
......@@ -3652,8 +3646,6 @@
'browser/ui/views/extensions/extension_view.h',
'browser/ui/views/extensions/shell_window_views.cc',
'browser/ui/views/extensions/shell_window_views.h',
'browser/ui/views/extensions/web_auth_flow_window_views.cc',
'browser/ui/views/extensions/web_auth_flow_window_views.h',
'browser/ui/views/external_protocol_dialog.cc',
'browser/ui/views/external_protocol_dialog.h',
'browser/ui/views/external_tab_container_win.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment