MacViews: Get c/b/ui/views/tabs to build on Mac
[chromium-blink-merge.git] / chrome / browser / ui / views / chrome_web_dialog_view.cc
blobb1a651ccb638592f48e90828774f6faffc7ee2c5
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
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
6 #include "chrome/browser/ui/browser_dialogs.h"
7 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
8 #include "ui/views/controls/webview/web_dialog_view.h"
9 #include "ui/views/widget/widget.h"
11 namespace chrome {
13 // Declared in browser_dialogs.h so that others don't need to depend on our .h.
14 gfx::NativeWindow ShowWebDialog(gfx::NativeWindow parent,
15 content::BrowserContext* context,
16 ui::WebDialogDelegate* delegate) {
17 views::Widget* widget = NULL;
18 views::WebDialogView* view =
19 new views::WebDialogView(context, delegate, new ChromeWebContentsHandler);
20 if (parent) {
21 widget = views::Widget::CreateWindowWithParent(view, parent);
22 } else {
23 // We shouldn't be called with a NULL parent, but sometimes are.
24 widget = views::Widget::CreateWindow(view);
27 // Observer is needed for ChromeVox extension to send messages between content
28 // and background scripts.
29 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
30 view->web_contents());
32 widget->Show();
33 return widget->GetNativeWindow();
36 } // namespace chrome