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"
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
);
21 widget
= views::Widget::CreateWindowWithParent(view
, parent
);
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());
33 return widget
->GetNativeWindow();