Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Unified Diff: chrome/browser/ui/ash/web_dialog_util.cc

Issue 2441133002: mash: Introduce ShowWebDialogWithContainer for webui dialogs (Closed)
Patch Set: review comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/web_dialog_util.cc
diff --git a/chrome/browser/ui/ash/web_dialog_util.cc b/chrome/browser/ui/ash/web_dialog_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b1fe668841fbfcf3ce927b822b27d62d8856e141
--- /dev/null
+++ b/chrome/browser/ui/ash/web_dialog_util.cc
@@ -0,0 +1,59 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/ash/web_dialog_util.h"
+
+#include "ash/public/cpp/shell_window_ids.h"
+#include "ash/shell.h"
+#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
+#include "chrome/browser/ui/ash/ash_util.h"
+#include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
+#include "services/ui/public/cpp/property_type_converters.h"
+#include "services/ui/public/interfaces/window_manager.mojom.h"
+#include "ui/aura/mus/mus_util.h"
+#include "ui/views/controls/webview/web_dialog_view.h"
+#include "ui/views/widget/widget.h"
+
+namespace chrome {
+
+void ShowWebDialogWithContainer(gfx::NativeView parent,
+ int container_id,
+ content::BrowserContext* context,
+ ui::WebDialogDelegate* delegate) {
+ DCHECK(parent || container_id != ash::kShellWindowId_Invalid);
+ views::WebDialogView* view =
+ new views::WebDialogView(context, delegate, new ChromeWebContentsHandler);
+
+ views::Widget* widget = new views::Widget;
+ views::Widget::InitParams params;
+ params.delegate = view;
+ if (chrome::IsRunningInMash()) {
+ if (parent) {
+ ui::Window* parent_mus = aura::GetMusWindow(parent);
+ DCHECK(parent_mus);
+ params.parent_mus = parent_mus;
+ } else {
+ using ui::mojom::WindowManager;
+ params.mus_properties[WindowManager::kInitialContainerId_Property] =
+ mojo::ConvertTo<std::vector<uint8_t>>(container_id);
+ }
+ } else {
+ if (parent) {
+ params.parent = parent;
+ } else {
+ params.parent = ash::Shell::GetContainer(
+ ash::Shell::GetPrimaryRootWindow(), container_id);
+ }
+ }
+ widget->Init(params);
+
+ // Observer is needed for ChromeVox extension to send messages between content
+ // and background scripts.
+ extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
+ view->web_contents());
+
+ widget->Show();
+}
+
+} // namespace chrome
« no previous file with comments | « chrome/browser/ui/ash/web_dialog_util.h ('k') | chrome/browser/ui/webui/options/chromeos/date_time_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698