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