diff options
author | sky <sky@chromium.org> | 2015-10-14 16:36:16 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-14 23:37:07 +0000 |
commit | c4d274a47875d10f80066a46bec8332abf590b79 (patch) | |
tree | 113b474083a3ce5d20a914c9bbf9ba5a45406ccf | |
parent | c23a9f9c2230c5d190ceaaaa15d226058c5745d1 (diff) | |
download | chromium_src-c4d274a47875d10f80066a46bec8332abf590b79.zip chromium_src-c4d274a47875d10f80066a46bec8332abf590b79.tar.gz chromium_src-c4d274a47875d10f80066a46bec8332abf590b79.tar.bz2 |
Adds viewsexamples to mus/examples and a main mojom
I also nuked client as it's pretty useless. I added main as a
convenient place to launch everything we want to show.
BUG=none
TEST=none
R=ben@chromium.org
Review URL: https://codereview.chromium.org/1409583002
Cr-Commit-Position: refs/heads/master@{#354151}
17 files changed, 164 insertions, 66 deletions
diff --git a/components/mus/example/BUILD.gn b/components/mus/example/BUILD.gn index 10a5e97..639c1cd 100644 --- a/components/mus/example/BUILD.gn +++ b/components/mus/example/BUILD.gn @@ -6,7 +6,8 @@ group("example") { testonly = true deps = [ - "//components/mus/example/client", + "//components/mus/example/main", + "//components/mus/example/views_examples", "//components/mus/example/window_type_launcher", "//components/mus/example/wm", ] diff --git a/components/mus/example/client/DEPS b/components/mus/example/client/DEPS deleted file mode 100644 index 7caf211..0000000 --- a/components/mus/example/client/DEPS +++ /dev/null @@ -1,4 +0,0 @@ -include_rules = [ - # TODO(sky): nuke this. Refactor mandoline/ui/aura into mojo. - "+mandoline/ui/aura", -] diff --git a/components/mus/example/client/client_application_delegate.cc b/components/mus/example/client/client_application_delegate.cc deleted file mode 100644 index c7fbe88..0000000 --- a/components/mus/example/client/client_application_delegate.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 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 "components/mus/example/client/client_application_delegate.h" - -#include "components/mus/example/common/mus_views_init.h" -#include "mojo/application/public/cpp/application_connection.h" -#include "mojo/application/public/cpp/application_impl.h" -#include "ui/views/background.h" -#include "ui/views/widget/widget.h" -#include "ui/views/widget/widget_delegate.h" - -ClientApplicationDelegate::ClientApplicationDelegate() : app_(nullptr) {} - -ClientApplicationDelegate::~ClientApplicationDelegate() {} - -void ClientApplicationDelegate::Initialize(mojo::ApplicationImpl* app) { - app_ = app; - - mus_views_init_.reset(new MUSViewsInit(app)); - - for (int i = 0; i < 3; ++i) { - views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView; - widget_delegate->GetContentsView()->set_background( - views::Background::CreateSolidBackground(0xFFDDDDDD)); - - views::Widget* widget = views::Widget::CreateWindow(widget_delegate); - widget->Show(); - } -} - -bool ClientApplicationDelegate::ConfigureIncomingConnection( - mojo::ApplicationConnection* connection) { - return false; -} diff --git a/components/mus/example/common/DEPS b/components/mus/example/common/DEPS deleted file mode 100644 index 7caf211..0000000 --- a/components/mus/example/common/DEPS +++ /dev/null @@ -1,4 +0,0 @@ -include_rules = [ - # TODO(sky): nuke this. Refactor mandoline/ui/aura into mojo. - "+mandoline/ui/aura", -] diff --git a/components/mus/example/main/BUILD.gn b/components/mus/example/main/BUILD.gn new file mode 100644 index 0000000..3e71b4f --- /dev/null +++ b/components/mus/example/main/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright 2015 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. + +import("//build/config/ui.gni") +import("//mojo/public/mojo_application.gni") +import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni") +import("//tools/grit/repack.gni") + +mojo_native_application("main") { + output_name = "example_main" + testonly = true + + sources = [ + "main.cc", + "main_application_delegate.cc", + "main_application_delegate.h", + ] + + deps = [ + "//base", + "//mojo/application/public/cpp", + "//mojo/application/public/cpp:sources", + "//third_party/mojo/src/mojo/public/cpp/bindings", + ] + + data_deps = [ + "//components/mus/example/views_examples", + "//components/mus/example/window_type_launcher", + ] +} diff --git a/components/mus/example/client/main.cc b/components/mus/example/main/main.cc index 913d391c..d71cfd4 100644 --- a/components/mus/example/client/main.cc +++ b/components/mus/example/main/main.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/mus/example/client/client_application_delegate.h" +#include "components/mus/example/main/main_application_delegate.h" #include "mojo/application/public/cpp/application_runner.h" #include "third_party/mojo/src/mojo/public/c/system/main.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(new ClientApplicationDelegate); + mojo::ApplicationRunner runner(new MainApplicationDelegate); return runner.Run(shell_handle); } diff --git a/components/mus/example/main/main_application_delegate.cc b/components/mus/example/main/main_application_delegate.cc new file mode 100644 index 0000000..399e21a --- /dev/null +++ b/components/mus/example/main/main_application_delegate.cc @@ -0,0 +1,23 @@ +// Copyright 2015 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 "components/mus/example/main/main_application_delegate.h" + +#include "mojo/application/public/cpp/application_connection.h" +#include "mojo/application/public/cpp/application_impl.h" + +MainApplicationDelegate::MainApplicationDelegate() {} + +MainApplicationDelegate::~MainApplicationDelegate() {} + +void MainApplicationDelegate::Initialize(mojo::ApplicationImpl* app) { + connections_.push_back(app->ConnectToApplication("mojo:views_examples")); + connections_.push_back( + app->ConnectToApplication("mojo:window_type_launcher")); +} + +bool MainApplicationDelegate::ConfigureIncomingConnection( + mojo::ApplicationConnection* connection) { + return false; +} diff --git a/components/mus/example/main/main_application_delegate.h b/components/mus/example/main/main_application_delegate.h new file mode 100644 index 0000000..2c2e6f2 --- /dev/null +++ b/components/mus/example/main/main_application_delegate.h @@ -0,0 +1,33 @@ +// Copyright 2015 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. + +#ifndef COMPONENTS_MUS_EXAMPLE_MAIN_MAIN_APPLICATION_DELEGATE_H_ +#define COMPONENTS_MUS_EXAMPLE_MAIN_MAIN_APPLICATION_DELEGATE_H_ + +#include "base/macros.h" +#include "base/memory/scoped_vector.h" +#include "mojo/application/public/cpp/application_delegate.h" +#include "mojo/application/public/cpp/interface_factory_impl.h" + +namespace mojo { +class ApplicationConnection; +} + +class MainApplicationDelegate : public mojo::ApplicationDelegate { + public: + MainApplicationDelegate(); + ~MainApplicationDelegate() override; + + private: + // ApplicationDelegate: + void Initialize(mojo::ApplicationImpl* app) override; + bool ConfigureIncomingConnection( + mojo::ApplicationConnection* connection) override; + + ScopedVector<mojo::ApplicationConnection> connections_; + + DISALLOW_COPY_AND_ASSIGN(MainApplicationDelegate); +}; + +#endif // COMPONENTS_MUS_EXAMPLE_MAIN_MAIN_APPLICATION_DELEGATE_H_ diff --git a/components/mus/example/client/BUILD.gn b/components/mus/example/views_examples/BUILD.gn index d0710b4..60a7dc1 100644 --- a/components/mus/example/client/BUILD.gn +++ b/components/mus/example/views_examples/BUILD.gn @@ -7,14 +7,13 @@ import("//mojo/public/mojo_application.gni") import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni") import("//tools/grit/repack.gni") -mojo_native_application("client") { - output_name = "example_client" +mojo_native_application("views_examples") { testonly = true sources = [ - "client_application_delegate.cc", - "client_application_delegate.h", "main.cc", + "views_examples_application_delegate.cc", + "views_examples_application_delegate.h", ] deps = [ @@ -30,6 +29,7 @@ mojo_native_application("client") { "//ui/gfx/geometry", "//ui/mojo/events:interfaces", "//ui/views", + "//ui/views/examples:views_examples_lib", ] resources = [ "$root_out_dir/example_resources.pak" ] diff --git a/components/mus/example/views_examples/main.cc b/components/mus/example/views_examples/main.cc new file mode 100644 index 0000000..03d579b --- /dev/null +++ b/components/mus/example/views_examples/main.cc @@ -0,0 +1,12 @@ +// Copyright 2015 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 "components/mus/example/views_examples/views_examples_application_delegate.h" +#include "mojo/application/public/cpp/application_runner.h" +#include "third_party/mojo/src/mojo/public/c/system/main.h" + +MojoResult MojoMain(MojoHandle shell_handle) { + mojo::ApplicationRunner runner(new ViewsExamplesApplicationDelegate); + return runner.Run(shell_handle); +} diff --git a/components/mus/example/views_examples/views_examples_application_delegate.cc b/components/mus/example/views_examples/views_examples_application_delegate.cc new file mode 100644 index 0000000..889186c --- /dev/null +++ b/components/mus/example/views_examples/views_examples_application_delegate.cc @@ -0,0 +1,38 @@ +// Copyright 2015 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 "components/mus/example/views_examples/views_examples_application_delegate.h" + +#include "components/mus/example/common/mus_views_init.h" +#include "mojo/application/public/cpp/application_connection.h" +#include "mojo/application/public/cpp/application_impl.h" +#include "ui/views/examples/example_base.h" +#include "ui/views/examples/examples_window.h" +#include "ui/views/widget/widget_delegate.h" + +ViewsExamplesApplicationDelegate::ViewsExamplesApplicationDelegate() + : app_(nullptr) {} + +ViewsExamplesApplicationDelegate::~ViewsExamplesApplicationDelegate() { +} + +void ViewsExamplesApplicationDelegate::Initialize(mojo::ApplicationImpl* app) { + app_ = app; + + mus_views_init_.reset(new MUSViewsInit(app)); + + // TODO(sky): total hack! This is necessary as WindowTypeLauncherView is + // created before AuraInit. WindowTypeLauncherView uses resources that are + // configured by MUSViewsInit once a View is created. By creating a Widget + // here we ensure the necessary state has been setup. + views::Widget::CreateWindow(new views::WidgetDelegateView); + + views::examples::ShowExamplesWindow(views::examples::DO_NOTHING_ON_CLOSE, + nullptr, nullptr); +} + +bool ViewsExamplesApplicationDelegate::ConfigureIncomingConnection( + mojo::ApplicationConnection* connection) { + return false; +} diff --git a/components/mus/example/client/client_application_delegate.h b/components/mus/example/views_examples/views_examples_application_delegate.h index dc304ad..0be126d 100644 --- a/components/mus/example/client/client_application_delegate.h +++ b/components/mus/example/views_examples/views_examples_application_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_MUS_EXAMPLE_CLIENT_CLIENT_APPLICATION_DELEGATE_H_ -#define COMPONENTS_MUS_EXAMPLE_CLIENT_CLIENT_APPLICATION_DELEGATE_H_ +#ifndef COMPONENTS_MUS_EXAMPLE_CLIENT_VIEWS_EXAMPLES_APPLICATION_DELEGATE_H_ +#define COMPONENTS_MUS_EXAMPLE_CLIENT_VIEWS_EXAMPLES_APPLICATION_DELEGATE_H_ #include "base/macros.h" #include "base/memory/scoped_ptr.h" @@ -12,10 +12,10 @@ class MUSViewsInit; -class ClientApplicationDelegate : public mojo::ApplicationDelegate { +class ViewsExamplesApplicationDelegate : public mojo::ApplicationDelegate { public: - ClientApplicationDelegate(); - ~ClientApplicationDelegate() override; + ViewsExamplesApplicationDelegate(); + ~ViewsExamplesApplicationDelegate() override; private: // ApplicationDelegate: @@ -27,7 +27,7 @@ class ClientApplicationDelegate : public mojo::ApplicationDelegate { scoped_ptr<MUSViewsInit> mus_views_init_; - DISALLOW_COPY_AND_ASSIGN(ClientApplicationDelegate); + DISALLOW_COPY_AND_ASSIGN(ViewsExamplesApplicationDelegate); }; -#endif // COMPONENTS_MUS_EXAMPLE_CLIENT_CLIENT_APPLICATION_DELEGATE_H_ +#endif // COMPONENTS_MUS_EXAMPLE_CLIENT_VIEWS_EXAMPLES_APPLICATION_DELEGATE_H_ diff --git a/components/mus/example/window_type_launcher/DEPS b/components/mus/example/window_type_launcher/DEPS deleted file mode 100644 index 7caf211..0000000 --- a/components/mus/example/window_type_launcher/DEPS +++ /dev/null @@ -1,4 +0,0 @@ -include_rules = [ - # TODO(sky): nuke this. Refactor mandoline/ui/aura into mojo. - "+mandoline/ui/aura", -] diff --git a/components/mus/example/window_type_launcher/window_type_launcher.cc b/components/mus/example/window_type_launcher/window_type_launcher.cc index f41c1dc..e7f0d74 100644 --- a/components/mus/example/window_type_launcher/window_type_launcher.cc +++ b/components/mus/example/window_type_launcher/window_type_launcher.cc @@ -349,7 +349,7 @@ WindowTypeLauncher::WindowTypeLauncher() : app_(nullptr) {} WindowTypeLauncher::~WindowTypeLauncher() {} bool WindowTypeLauncher::ConfigureIncomingConnection( - mojo::ApplicationConnection* connection) { + mojo::ApplicationConnection* connection) { return false; } diff --git a/mojo/application/public/cpp/application_impl.h b/mojo/application/public/cpp/application_impl.h index 01088f8..4184ccc 100644 --- a/mojo/application/public/cpp/application_impl.h +++ b/mojo/application/public/cpp/application_impl.h @@ -95,6 +95,8 @@ class ApplicationImpl : public Application { // Requests a new connection to an application. Returns a pointer to the // connection if the connection is permitted by this application's delegate, // or nullptr otherwise. Caller takes ownership. + scoped_ptr<ApplicationConnection> ConnectToApplication( + const std::string& url); scoped_ptr<ApplicationConnection> ConnectToApplication(URLRequestPtr request); scoped_ptr<ApplicationConnection> ConnectToApplicationWithCapabilityFilter( URLRequestPtr request, diff --git a/mojo/application/public/cpp/lib/application_impl.cc b/mojo/application/public/cpp/lib/application_impl.cc index aecd61c..31da811 100644 --- a/mojo/application/public/cpp/lib/application_impl.cc +++ b/mojo/application/public/cpp/lib/application_impl.cc @@ -46,6 +46,13 @@ ApplicationImpl::~ApplicationImpl() { } scoped_ptr<ApplicationConnection> ApplicationImpl::ConnectToApplication( + const std::string& url) { + mojo::URLRequestPtr request(mojo::URLRequest::New()); + request->url = url; + return ConnectToApplication(request.Pass()); +} + +scoped_ptr<ApplicationConnection> ApplicationImpl::ConnectToApplication( URLRequestPtr request) { return ConnectToApplicationWithCapabilityFilter(request.Pass(), nullptr); } diff --git a/ui/views/examples/examples_main.cc b/ui/views/examples/examples_main.cc index 0d083ea..70624fe 100644 --- a/ui/views/examples/examples_main.cc +++ b/ui/views/examples/examples_main.cc @@ -97,9 +97,8 @@ int main(int argc, char** argv) { #endif views::examples::ShowExamplesWindow( - views::examples::QUIT_ON_CLOSE, - NULL, - scoped_ptr<ScopedVector<views::examples::ExampleBase> >()); + views::examples::QUIT_ON_CLOSE, nullptr, + scoped_ptr<ScopedVector<views::examples::ExampleBase>>()); base::RunLoop().Run(); |