OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 5 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
6 #include "chrome/browser/ui/browser_dialogs.h" | 6 #include "chrome/browser/ui/browser_dialogs.h" |
7 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" | 7 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" |
8 #include "ui/views/controls/webview/web_dialog_view.h" | 8 #include "ui/views/controls/webview/web_dialog_view.h" |
9 #include "ui/views/widget/widget.h" | 9 #include "ui/views/widget/widget.h" |
10 | 10 |
11 #if defined(USE_ASH) | 11 #if defined(USE_ASH) |
12 #include "ash/public/cpp/shell_window_ids.h" // nogncheck | 12 #include "ash/public/cpp/shell_window_ids.h" // nogncheck |
13 #include "ash/shell.h" // nogncheck | 13 #include "ash/shell.h" // nogncheck |
14 #include "chrome/browser/ui/ash/ash_util.h" | 14 #include "chrome/browser/ui/ash/ash_util.h" |
15 #include "services/ui/public/cpp/property_type_converters.h" | 15 #include "services/ui/public/cpp/property_type_converters.h" |
16 #include "services/ui/public/interfaces/window_manager.mojom.h" | 16 #include "services/ui/public/interfaces/window_manager.mojom.h" |
17 #include "ui/aura/mus/mus_util.h" | |
18 #endif // defined(USE_ASH) | 17 #endif // defined(USE_ASH) |
19 | 18 |
20 namespace chrome { | 19 namespace chrome { |
21 namespace { | 20 namespace { |
22 | 21 |
23 gfx::NativeWindow ShowWebDialogWidget(const views::Widget::InitParams& params, | 22 gfx::NativeWindow ShowWebDialogWidget(const views::Widget::InitParams& params, |
24 views::WebDialogView* view) { | 23 views::WebDialogView* view) { |
25 views::Widget* widget = new views::Widget; | 24 views::Widget* widget = new views::Widget; |
26 widget->Init(params); | 25 widget->Init(params); |
27 | 26 |
(...skipping 12 matching lines...) Expand all Loading... |
40 gfx::NativeWindow ShowWebDialog(gfx::NativeView parent, | 39 gfx::NativeWindow ShowWebDialog(gfx::NativeView parent, |
41 content::BrowserContext* context, | 40 content::BrowserContext* context, |
42 ui::WebDialogDelegate* delegate) { | 41 ui::WebDialogDelegate* delegate) { |
43 views::WebDialogView* view = | 42 views::WebDialogView* view = |
44 new views::WebDialogView(context, delegate, new ChromeWebContentsHandler); | 43 new views::WebDialogView(context, delegate, new ChromeWebContentsHandler); |
45 views::Widget::InitParams params; | 44 views::Widget::InitParams params; |
46 params.delegate = view; | 45 params.delegate = view; |
47 // NOTE: The |parent| may be null, which will result in the default window | 46 // NOTE: The |parent| may be null, which will result in the default window |
48 // placement on Aura. | 47 // placement on Aura. |
49 params.parent = parent; | 48 params.parent = parent; |
50 #if defined(USE_ASH) | |
51 if (chrome::IsRunningInMash()) | |
52 params.parent_mus = aura::GetMusWindow(parent); | |
53 #endif // defined(USE_ASH) | |
54 return ShowWebDialogWidget(params, view); | 49 return ShowWebDialogWidget(params, view); |
55 } | 50 } |
56 | 51 |
57 #if defined(USE_ASH) | 52 #if defined(USE_ASH) |
58 void ShowWebDialogInContainer(int container_id, | 53 void ShowWebDialogInContainer(int container_id, |
59 content::BrowserContext* context, | 54 content::BrowserContext* context, |
60 ui::WebDialogDelegate* delegate) { | 55 ui::WebDialogDelegate* delegate) { |
61 DCHECK(container_id != ash::kShellWindowId_Invalid); | 56 DCHECK(container_id != ash::kShellWindowId_Invalid); |
62 views::WebDialogView* view = | 57 views::WebDialogView* view = |
63 new views::WebDialogView(context, delegate, new ChromeWebContentsHandler); | 58 new views::WebDialogView(context, delegate, new ChromeWebContentsHandler); |
64 views::Widget::InitParams params; | 59 views::Widget::InitParams params; |
65 params.delegate = view; | 60 params.delegate = view; |
66 if (chrome::IsRunningInMash()) { | 61 if (chrome::IsRunningInMash()) { |
67 using ui::mojom::WindowManager; | 62 using ui::mojom::WindowManager; |
68 params.mus_properties[WindowManager::kContainerId_InitProperty] = | 63 params.mus_properties[WindowManager::kContainerId_InitProperty] = |
69 mojo::ConvertTo<std::vector<uint8_t>>(container_id); | 64 mojo::ConvertTo<std::vector<uint8_t>>(container_id); |
70 } else { | 65 } else { |
71 params.parent = ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), | 66 params.parent = ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), |
72 container_id); | 67 container_id); |
73 } | 68 } |
74 ShowWebDialogWidget(params, view); | 69 ShowWebDialogWidget(params, view); |
75 } | 70 } |
76 #endif // defined(USE_ASH) | 71 #endif // defined(USE_ASH) |
77 | 72 |
78 } // namespace chrome | 73 } // namespace chrome |
OLD | NEW |