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

Unified Diff: ash/mus/native_widget_factory_mus.cc

Issue 2271373002: mash: Port mojo:ash_sysui's ContextMenuMus to mojo:ash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 4 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
« no previous file with comments | « ash/mus/native_widget_factory_mus.h ('k') | ash/mus/shell_delegate_mus.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/mus/native_widget_factory_mus.cc
diff --git a/ash/mus/native_widget_factory_mus.cc b/ash/mus/native_widget_factory_mus.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6e9bceec804e9d1b7ace300a27f84f6868b3359e
--- /dev/null
+++ b/ash/mus/native_widget_factory_mus.cc
@@ -0,0 +1,51 @@
+// 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 "ash/mus/native_widget_factory_mus.h"
+
+#include "ash/common/wm_shell.h"
+#include "ash/mus/bridge/wm_window_mus.h"
+#include "ash/mus/window_manager.h"
+#include "services/ui/public/cpp/property_type_converters.h"
+#include "ui/views/mus/native_widget_mus.h"
+#include "ui/views/views_delegate.h"
+#include "ui/views/widget/widget.h"
+
+namespace ash {
+namespace mus {
+
+namespace {
+
+views::NativeWidget* CreateNativeWidgetMus(
+ WindowManager* window_manager,
+ const views::Widget::InitParams& init_params,
+ views::internal::NativeWidgetDelegate* delegate) {
+ // TYPE_CONTROL widgets require a NativeWidgetAura. So we let this fall
+ // through, so that the default NativeWidgetPrivate::CreateNativeWidget() is
+ // used instead.
+ if (init_params.type == views::Widget::InitParams::TYPE_CONTROL)
+ return nullptr;
+ std::map<std::string, std::vector<uint8_t>> props;
+ views::NativeWidgetMus::ConfigurePropertiesForNewWindow(init_params, &props);
+ return new views::NativeWidgetMus(delegate,
+ window_manager->NewTopLevelWindow(&props),
+ ui::mojom::SurfaceType::DEFAULT);
+}
+
+} // namespace
+
+NativeWidgetFactoryMus::NativeWidgetFactoryMus(WindowManager* window_manager) {
+ views::ViewsDelegate::GetInstance()->set_native_widget_factory(
+ base::Bind(&CreateNativeWidgetMus, window_manager));
+}
+
+NativeWidgetFactoryMus::~NativeWidgetFactoryMus() {
+ if (views::ViewsDelegate::GetInstance()) {
+ views::ViewsDelegate::GetInstance()->set_native_widget_factory(
+ views::ViewsDelegate::NativeWidgetFactory());
+ }
+}
+
+} // namespace mus
+} // namespace ash
« no previous file with comments | « ash/mus/native_widget_factory_mus.h ('k') | ash/mus/shell_delegate_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698