OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #include "chrome/browser/ui/ash/web_dialog_util.h" |
| 6 |
| 7 #include "ash/public/cpp/shell_window_ids.h" |
| 8 #include "ash/shell.h" |
| 9 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
| 10 #include "chrome/browser/ui/ash/ash_util.h" |
| 11 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" |
| 12 #include "services/ui/public/cpp/property_type_converters.h" |
| 13 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 14 #include "ui/aura/mus/mus_util.h" |
| 15 #include "ui/views/controls/webview/web_dialog_view.h" |
| 16 #include "ui/views/widget/widget.h" |
| 17 |
| 18 namespace chrome { |
| 19 |
| 20 void ShowWebDialogWithContainer(gfx::NativeView parent, |
| 21 int container_id, |
| 22 content::BrowserContext* context, |
| 23 ui::WebDialogDelegate* delegate) { |
| 24 DCHECK(parent || container_id != ash::kShellWindowId_Invalid); |
| 25 views::WebDialogView* view = |
| 26 new views::WebDialogView(context, delegate, new ChromeWebContentsHandler); |
| 27 |
| 28 views::Widget* widget = new views::Widget; |
| 29 views::Widget::InitParams params; |
| 30 params.delegate = view; |
| 31 if (chrome::IsRunningInMash()) { |
| 32 if (parent) { |
| 33 ui::Window* parent_mus = aura::GetMusWindow(parent); |
| 34 DCHECK(parent_mus); |
| 35 params.parent_mus = parent_mus; |
| 36 } else { |
| 37 using ui::mojom::WindowManager; |
| 38 params.mus_properties[WindowManager::kInitialContainerId_Property] = |
| 39 mojo::ConvertTo<std::vector<uint8_t>>(container_id); |
| 40 } |
| 41 } else { |
| 42 if (parent) { |
| 43 params.parent = parent; |
| 44 } else { |
| 45 params.parent = ash::Shell::GetContainer( |
| 46 ash::Shell::GetPrimaryRootWindow(), container_id); |
| 47 } |
| 48 } |
| 49 widget->Init(params); |
| 50 |
| 51 // Observer is needed for ChromeVox extension to send messages between content |
| 52 // and background scripts. |
| 53 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( |
| 54 view->web_contents()); |
| 55 |
| 56 widget->Show(); |
| 57 } |
| 58 |
| 59 } // namespace chrome |
OLD | NEW |