views/mus: Fix showing menu in chrome in mus.

For menus in chrome-in-mus, we attempt to create a Widget hosted in a native
window. For desktop builds, this means we attempt to host in a HWND or an
X11 window created by DesktopNativeWidgetAura. But for mus, we want to use
NativeWidgetMus. To do this, use the native-widget factory first if it's
available.

BUG=none

Committed: https://crrev.com/2914df72a605451828a05e108c35fe9a1d72c971
Cr-Commit-Position: refs/heads/master@{#361151}

R=jam@chromium.org, sky@chromium.org

Review URL: https://codereview.chromium.org/1460003004 .

Cr-Commit-Position: refs/heads/master@{#361271}
parent 72531bf4
......@@ -75,6 +75,10 @@ namespace ui {
class WindowResizeHelperMac;
}
namespace views {
class WindowManagerConnection;
}
namespace base {
namespace android {
......@@ -221,6 +225,7 @@ class BASE_EXPORT ThreadRestrictions {
#if !defined(OFFICIAL_BUILD)
friend class content::SoftwareOutputDeviceMus; // Interim non-production code
#endif
friend class views::WindowManagerConnection;
// END USAGE THAT NEEDS TO BE FIXED.
#if ENABLE_THREAD_RESTRICTIONS
......
......@@ -64,7 +64,6 @@
#include "chrome/browser/ui/ash/ash_util.h"
#endif
// Helpers --------------------------------------------------------------------
namespace {
......@@ -374,6 +373,11 @@ void ChromeViewsDelegate::OnBeforeWidgetInit(
}
}
#endif // OS_WIN
if (!use_non_toplevel_window && !native_widget_factory().is_null()) {
params->native_widget = native_widget_factory().Run(*params, delegate);
return;
}
#endif // USE_AURA
#if defined(OS_CHROMEOS)
......
......@@ -6,6 +6,7 @@
#include "base/lazy_instance.h"
#include "base/threading/thread_local.h"
#include "base/threading/thread_restrictions.h"
#include "components/mus/public/cpp/window_tree_connection.h"
#include "components/mus/public/interfaces/window_tree.mojom.h"
#include "mojo/application/public/cpp/application_connection.h"
......@@ -111,6 +112,8 @@ mus::Window* WindowManagerConnection::NewWindow(
window_manager_->OpenWindow(
window_tree_client.Pass(),
mojo::Map<mojo::String, mojo::Array<uint8_t>>::From(properties));
base::ThreadRestrictions::ScopedAllowWait allow_wait;
mus::WindowTreeConnection* window_tree_connection =
mus::WindowTreeConnection::Create(
this, window_tree_client_request.Pass(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment