Remove wm_flow, browser, nesting_app examples
These aren't used or maintained.
R=viettrungluu@chromium.org
Review URL: https://codereview.chromium.org/1397563003 .
diff --git a/examples/BUILD.gn b/examples/BUILD.gn
index cfcef6f..84c9d23 100644
--- a/examples/BUILD.gn
+++ b/examples/BUILD.gn
@@ -9,7 +9,6 @@
deps = [
"//examples/apptest",
- "//examples/browser",
"//examples/content_handler_demo",
"//examples/dart",
"//examples/echo",
@@ -22,7 +21,6 @@
"//examples/keyboard_client",
"//examples/moterm_example_app",
"//examples/native_run_app",
- "//examples/nesting_app",
"//examples/nfc_sender",
"//examples/notification_generator",
"//examples/png_viewer",
@@ -46,11 +44,7 @@
}
if (is_linux || is_android) {
- deps += [
- "//examples/surfaces_app",
- "//examples/window_manager",
- "//examples/wm_flow",
- ]
+ deps += [ "//examples/surfaces_app" ]
}
if (defined(go_build_tool) && go_build_tool != "") {
diff --git a/examples/browser/BUILD.gn b/examples/browser/BUILD.gn
deleted file mode 100644
index 84dccc3..0000000
--- a/examples/browser/BUILD.gn
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 2014 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("//mojo/public/tools/bindings/mojom.gni")
-
-mojo_native_application("browser") {
- sources = [
- "browser.cc",
- ]
-
- deps = [
- ":bindings",
- "//base",
- "//examples/window_manager:bindings",
- "//mojo/application",
- "//mojo/converters/geometry",
- "//mojo/services/geometry/interfaces",
- "//mojo/services/navigation/interfaces",
- "//mojo/services/view_manager/cpp",
- "//mojo/services/view_manager/interfaces",
- "//third_party/icu",
- "//url",
- ]
-}
-
-mojom("bindings") {
- sources = [
- "browser_host.mojom",
- ]
-}
diff --git a/examples/browser/browser.cc b/examples/browser/browser.cc
deleted file mode 100644
index 33572c5..0000000
--- a/examples/browser/browser.cc
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright 2014 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 "base/macros.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "examples/browser/browser_host.mojom.h"
-#include "examples/window_manager/window_manager.mojom.h"
-#include "mojo/application/application_runner_chromium.h"
-#include "mojo/converters/geometry/geometry_type_converters.h"
-#include "mojo/public/c/system/main.h"
-#include "mojo/public/cpp/application/application_connection.h"
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/connect.h"
-#include "mojo/public/cpp/application/service_provider_impl.h"
-#include "mojo/services/navigation/interfaces/navigation.mojom.h"
-#include "mojo/services/view_manager/cpp/view.h"
-#include "mojo/services/view_manager/cpp/view_manager.h"
-#include "mojo/services/view_manager/cpp/view_manager_client_factory.h"
-#include "mojo/services/view_manager/cpp/view_manager_delegate.h"
-#include "mojo/services/view_manager/cpp/view_observer.h"
-#include "url/gurl.h"
-
-namespace mojo {
-namespace examples {
-
-// This is the basics of creating a views widget with a textfield.
-// TODO: cleanup!
-class Browser : public ApplicationDelegate,
- public ViewManagerDelegate,
- public ViewObserver,
- public examples::BrowserHost,
- public mojo::InterfaceFactory<examples::BrowserHost> {
- public:
- Browser() : shell_(nullptr), root_(NULL), binding_(this) {
- browser_host_services_impl_.AddService(this);
- }
-
- ~Browser() override {
- if (root_)
- root_->RemoveObserver(this);
- }
-
- private:
- // Overridden from ApplicationDelegate:
- void Initialize(ApplicationImpl* app) override {
- shell_ = app->shell();
- view_manager_client_factory_.reset(
- new ViewManagerClientFactory(shell_, this));
- app->ConnectToService("mojo:window_manager", &window_manager_);
-
- // FIXME: Mojo applications don't know their URLs yet:
- // https://docs.google.com/a/chromium.org/document/d/1AQ2y6ekzvbdaMF5WrUQmneyXJnke-MnYYL4Gz1AKDos
- url_ = GURL(app->args()[1]);
- }
-
- bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
- connection->AddService(view_manager_client_factory_.get());
- return true;
- }
-
- // ViewManagerDelegate:
- void OnEmbed(View* root,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services) override {
- // TODO: deal with OnEmbed() being invoked multiple times.
- ConnectToService(exposed_services.get(), &navigator_host_);
- root_ = root;
- root_->AddObserver(this);
- root_->SetFocus();
-
- // Create a child view for our sky document.
- View* view = root->view_manager()->CreateView();
- root->AddChild(view);
- Rect bounds;
- bounds.x = 0;
- bounds.y = 0;
- bounds.width = root->bounds().width;
- bounds.height = root->bounds().height;
- view->SetBounds(bounds);
- view->SetVisible(true);
- root->SetVisible(true);
-
- ServiceProviderPtr browser_host_services;
- browser_host_services_impl_.Bind(GetProxy(&browser_host_services));
-
- GURL frame_url = url_.Resolve("/examples/browser/browser.sky");
- view->Embed(frame_url.spec(), nullptr, browser_host_services.Pass());
- }
-
- void OnViewManagerDisconnected(ViewManager* view_manager) override {
- base::MessageLoop::current()->Quit();
- }
-
- // ViewObserver:
- void OnViewDestroyed(View* view) override {
- DCHECK_EQ(root_, view);
- view->RemoveObserver(this);
- root_ = NULL;
- }
-
- // examples::BrowserHost:
- void NavigateTo(const mojo::String& url) override {
- URLRequestPtr request(URLRequest::New());
- request->url = url;
- navigator_host_->RequestNavigate(Target::NEW_NODE, request.Pass());
- }
-
- // mojo::InterfaceFactory<examples::BrowserHost> implementation.
- void Create(mojo::ApplicationConnection* connection,
- mojo::InterfaceRequest<examples::BrowserHost> request) override {
- binding_.Bind(request.Pass());
- }
-
- Shell* shell_;
-
- scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_;
- View* root_;
- NavigatorHostPtr navigator_host_;
- ::examples::IWindowManagerPtr window_manager_;
- ServiceProviderImpl browser_host_services_impl_;
-
- GURL url_;
-
- mojo::Binding<examples::BrowserHost> binding_;
-
- DISALLOW_COPY_AND_ASSIGN(Browser);
-};
-
-} // namespace examples
-} // namespace mojo
-
-MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunnerChromium runner(new mojo::examples::Browser);
- return runner.Run(application_request);
-}
diff --git a/examples/browser/browser.sky b/examples/browser/browser.sky
deleted file mode 100644
index ce10859..0000000
--- a/examples/browser/browser.sky
+++ /dev/null
@@ -1,42 +0,0 @@
-#!mojo mojo:sky_viewer
-<!--
-// Copyright 2014 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.
--->
-<sky>
-
-<import src="/gen/examples/browser/browser_host.mojom.sky" as="example" />
-
-<import src="/packages/sky/framework/embedder.sky" as="embedder" />
-<import src="/packages/sky/framework/sky-box.sky"/>
-<import src="/packages/sky/framework/sky-element/sky-element.sky" as="SkyElement" />
-<import src="/packages/sky/framework/sky-input.sky" />
-
-<sky-element name="browser-panel">
-<template>
- <style>
- div {
- display: flex;
- }
- </style>
-
- <sky-input id="text" value="{{ url }}" on-keydown="handleKeyDown" />
-</template>
-<script>
-module.exports = class extends SkyElement {
- created() {
- this.embedder = embedder.connectToEmbedderService(example.BrowserHost)
- this.url = "http://";
- }
-
- handleKeyDown(event) {
- if (event.key == 0xD)
- this.embedder.navigateTo(this.url);
- }
-}.register();
-</script>
-</sky-element>
-
-<browser-panel />
-</sky>
diff --git a/examples/browser/browser_host.mojom b/examples/browser/browser_host.mojom
deleted file mode 100644
index 04d789b..0000000
--- a/examples/browser/browser_host.mojom
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 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.
-
-module mojo.examples;
-
-interface BrowserHost {
- // Performs a navigation
- NavigateTo(string url);
-};
diff --git a/examples/moterm_example_app/BUILD.gn b/examples/moterm_example_app/BUILD.gn
index 8ed0c0e..0737a99 100644
--- a/examples/moterm_example_app/BUILD.gn
+++ b/examples/moterm_example_app/BUILD.gn
@@ -11,7 +11,6 @@
deps = [
"//base",
- "//examples/window_manager:bindings",
"//mojo/application",
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/utility",
diff --git a/examples/nesting_app/BUILD.gn b/examples/nesting_app/BUILD.gn
deleted file mode 100644
index 67107a1..0000000
--- a/examples/nesting_app/BUILD.gn
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright 2014 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("//mojo/public/mojo_application.gni")
-
-mojo_native_application("nesting_app") {
- sources = [
- "nesting_app.cc",
- ]
-
- deps = [
- "//base",
- "//examples/bitmap_uploader",
- "//examples/window_manager:bindings",
- "//mojo/application",
- "//mojo/public/cpp/bindings",
- "//mojo/public/cpp/utility",
- "//mojo/services/geometry/interfaces",
- "//mojo/services/navigation/interfaces",
- "//mojo/services/view_manager/cpp",
- "//skia",
- "//url",
- ]
-}
diff --git a/examples/nesting_app/nesting_app.cc b/examples/nesting_app/nesting_app.cc
deleted file mode 100644
index a13b086..0000000
--- a/examples/nesting_app/nesting_app.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright 2014 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 "base/bind.h"
-#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
-#include "base/strings/stringprintf.h"
-#include "examples/bitmap_uploader/bitmap_uploader.h"
-#include "examples/window_manager/window_manager.mojom.h"
-#include "mojo/application/application_runner_chromium.h"
-#include "mojo/public/c/system/main.h"
-#include "mojo/public/cpp/application/application_connection.h"
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/interface_factory_impl.h"
-#include "mojo/services/view_manager/cpp/view.h"
-#include "mojo/services/view_manager/cpp/view_manager.h"
-#include "mojo/services/view_manager/cpp/view_manager_client_factory.h"
-#include "mojo/services/view_manager/cpp/view_manager_delegate.h"
-#include "mojo/services/view_manager/cpp/view_observer.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "url/gurl.h"
-
-namespace mojo {
-namespace examples {
-
-namespace {
-const char kEmbeddedAppURL[] = "mojo:embedded_app";
-}
-
-class NestingApp;
-
-// An app that embeds another app.
-// TODO(davemoore): Is this the right name?
-class NestingApp
- : public ApplicationDelegate,
- public ViewManagerDelegate,
- public ViewObserver {
- public:
- NestingApp() : nested_(nullptr), shell_(nullptr) {}
- ~NestingApp() override {}
-
- private:
- // Overridden from ApplicationDelegate:
- void Initialize(ApplicationImpl* app) override {
- shell_ = app->shell();
- view_manager_client_factory_.reset(
- new ViewManagerClientFactory(app->shell(), this));
- }
-
- // Overridden from ApplicationImpl:
- bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
- connection->ConnectToService(&window_manager_);
- connection->AddService(view_manager_client_factory_.get());
- return true;
- }
-
- // Overridden from ViewManagerDelegate:
- void OnEmbed(View* root,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services) override {
- root->AddObserver(this);
- bitmap_uploader_.reset(new BitmapUploader(root));
- bitmap_uploader_->Init(shell_);
- bitmap_uploader_->SetColor(SK_ColorCYAN);
-
- nested_ = root->view_manager()->CreateView();
- root->AddChild(nested_);
- Rect rect;
- rect.x = rect.y = 20;
- rect.width = rect.height = 50;
- nested_->SetBounds(rect);
- nested_->SetVisible(true);
- nested_->Embed(kEmbeddedAppURL);
- }
- void OnViewManagerDisconnected(ViewManager* view_manager) override {
- base::MessageLoop::current()->Quit();
- }
-
- // Overridden from ViewObserver:
- void OnViewDestroyed(View* view) override {
- // TODO(beng): reap views & child Views.
- nested_ = NULL;
- }
- void OnViewInputEvent(View* view, const EventPtr& event) override {
- if (event->action == EventType::POINTER_UP)
- window_manager_->CloseWindow(view->id());
- }
-
- scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_;
-
- View* nested_;
- Shell* shell_;
- ::examples::IWindowManagerPtr window_manager_;
- scoped_ptr<BitmapUploader> bitmap_uploader_;
-
- DISALLOW_COPY_AND_ASSIGN(NestingApp);
-};
-
-} // namespace examples
-} // namespace mojo
-
-MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunnerChromium runner(new mojo::examples::NestingApp);
- return runner.Run(application_request);
-}
diff --git a/examples/window_manager/BUILD.gn b/examples/window_manager/BUILD.gn
deleted file mode 100644
index 1e4ccc7..0000000
--- a/examples/window_manager/BUILD.gn
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2014 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("//mojo/public/tools/bindings/mojom.gni")
-
-mojo_native_application("window_manager") {
- output_name = "example_window_manager"
-
- sources = [
- "window_manager.cc",
- ]
-
- deps = [
- ":bindings",
- "//base",
- "//mojo/application",
- "//mojo/common:common",
- "//mojo/converters/geometry",
- "//mojo/converters/input_events",
- "//mojo/public/cpp/bindings",
- "//mojo/public/cpp/utility",
- "//mojo/services/geometry/interfaces",
- "//mojo/services/input_events/interfaces",
- "//mojo/services/navigation/interfaces",
- "//mojo/services/view_manager/cpp",
- "//services/window_manager:lib",
- "//ui/events:events",
- "//url:url",
- ]
-}
-
-mojom("bindings") {
- sources = [
- "debug_panel_host.mojom",
- "window_manager.mojom",
- ]
- import_dirs = [ get_path_info("../../mojo/services", "abspath") ]
- deps = [
- "//mojo/services/geometry/interfaces",
- "//mojo/services/navigation/interfaces",
- "//mojo/services/network/interfaces",
- ]
-}
diff --git a/examples/window_manager/debug_panel.sky b/examples/window_manager/debug_panel.sky
deleted file mode 100644
index 4eb6eeb..0000000
--- a/examples/window_manager/debug_panel.sky
+++ /dev/null
@@ -1,70 +0,0 @@
-#!mojo mojo:sky_viewer
-<!--
-// Copyright 2014 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.
--->
-<sky>
-
-<import src="/gen/examples/window_manager/debug_panel_host.mojom.sky" as="example" />
-<import src="/mojo/services/navigation/interfaces/navigation.mojom.sky" as="navigation" />
-
-<import src="/sky/framework/embedder.sky" as="embedder" />
-<import src="/sky/framework/sky-box.sky" as="SkyBox" />
-<import src="/sky/framework/sky-button.sky" as="SkyButton" />
-<import src="/sky/framework/sky-checkbox.sky" as="SkyCheckbox" />
-<import src="/sky/framework/sky-element/sky-element.sky" as="SkyElement" />
-<import src="/sky/framework/sky-radio.sky" as="SkyRadio" />
-
-<sky-element name="debug-panel">
-<template>
- <style>
- div { display: paragraph; }
- </style>
-
- <sky-box title='Navigation target:'>
- <div><sky-radio group='nav-target' selected='true'
- on-click="handleRadioDefault"/>Default</div>
- <div><sky-radio group='nav-target' on-click="handleRadioNewWindow"/>New window</div>
- <div><sky-radio group='nav-target' on-click="handleRadioSourceWindow"/>Source window</div>
- </sky-box>
-
- <sky-button on-click="handleLocalNavClick">Local nav test</sky-button>
- <sky-button on-click="handleCloseLastWindow">Close last window</sky-button>
- <sky-button on-click="handleCrossAppNavTest">Cross-app nav test</sky-button>
-</template>
-<script>
-module.exports = class extends SkyElement {
- created() {
- this.embedder = embedder.connectToEmbedderService(example.DebugPanelHost)
- }
-
- handleRadioDefault(event) {
- this.embedder.setNavigationTarget(navigation.Target.DEFAULT);
- }
-
- handleRadioNewWindow(event) {
- this.embedder.setNavigationTarget(navigation.Target.NEW_NODE);
- }
-
- handleRadioSourceWindow(event) {
- this.embedder.setNavigationTarget(navigation.Target.SOURCE_NODE);
- }
-
- handleLocalNavClick(event) {
- this.embedder.navigateTo("mojo:embedded_app");
- }
-
- handleCloseLastWindow(event) {
- this.embedder.closeTopWindow();
- }
-
- handleCrossAppNavTest(event) {
- this.embedder.navigateTo("http://www.aaronboodman.com/z_dropbox/test.html");
- }
-}.register();
-</script>
-</sky-element>
-
-<debug-panel />
-</sky>
diff --git a/examples/window_manager/debug_panel_host.mojom b/examples/window_manager/debug_panel_host.mojom
deleted file mode 100644
index 68073c8..0000000
--- a/examples/window_manager/debug_panel_host.mojom
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2014 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.
-
-module mojo.examples;
-
-import "mojo/services/navigation/interfaces/navigation.mojom";
-
-interface DebugPanelHost {
- // Closes the top.
- CloseTopWindow();
-
- // Sends a navigate request.
- NavigateTo(string url);
-
- // Sets the navigation target.
- SetNavigationTarget(mojo.Target target);
-};
diff --git a/examples/window_manager/window_manager.cc b/examples/window_manager/window_manager.cc
deleted file mode 100644
index 1fbd491..0000000
--- a/examples/window_manager/window_manager.cc
+++ /dev/null
@@ -1,560 +0,0 @@
-// Copyright 2014 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 "base/bind.h"
-#include "base/macros.h"
-#include "examples/window_manager/debug_panel_host.mojom.h"
-#include "examples/window_manager/window_manager.mojom.h"
-#include "mojo/application/application_runner_chromium.h"
-#include "mojo/common/binding_set.h"
-#include "mojo/converters/geometry/geometry_type_converters.h"
-#include "mojo/converters/input_events/input_events_type_converters.h"
-#include "mojo/public/c/system/main.h"
-#include "mojo/public/cpp/application/application_connection.h"
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/service_provider_impl.h"
-#include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/services/input_events/interfaces/input_events.mojom.h"
-#include "mojo/services/navigation/interfaces/navigation.mojom.h"
-#include "mojo/services/view_manager/cpp/view.h"
-#include "mojo/services/view_manager/cpp/view_manager.h"
-#include "mojo/services/view_manager/cpp/view_manager_delegate.h"
-#include "mojo/services/view_manager/cpp/view_observer.h"
-#include "services/window_manager/basic_focus_rules.h"
-#include "services/window_manager/view_target.h"
-#include "services/window_manager/window_manager_app.h"
-#include "services/window_manager/window_manager_delegate.h"
-#include "services/window_manager/window_manager_root.h"
-#include "ui/events/event.h"
-#include "ui/events/event_constants.h"
-#include "url/gurl.h"
-
-#if defined CreateWindow
-#undef CreateWindow
-#endif
-
-namespace mojo {
-namespace examples {
-
-class WindowManagerController;
-
-namespace {
-
-const int kBorderInset = 25;
-const int kControlPanelWidth = 200;
-const int kTextfieldHeight = 39;
-
-} // namespace
-
-class WindowManagerConnection : public ::examples::IWindowManager {
- public:
- WindowManagerConnection(WindowManagerController* window_manager,
- InterfaceRequest<::examples::IWindowManager> request)
- : window_manager_(window_manager), binding_(this, request.Pass()) {}
- ~WindowManagerConnection() override {}
-
- private:
- // Overridden from ::examples::IWindowManager:
- void CloseWindow(Id view_id) override;
-
- WindowManagerController* window_manager_;
- StrongBinding<::examples::IWindowManager> binding_;
-
- DISALLOW_COPY_AND_ASSIGN(WindowManagerConnection);
-};
-
-class NavigatorHostImpl : public NavigatorHost {
- public:
- NavigatorHostImpl(WindowManagerController* window_manager, Id view_id)
- : window_manager_(window_manager),
- view_id_(view_id),
- current_index_(-1) {}
- ~NavigatorHostImpl() override {}
-
- void Bind(InterfaceRequest<NavigatorHost> request) {
- bindings_.AddBinding(this, request.Pass());
- }
-
- void RecordNavigation(const std::string& url);
-
- private:
- void DidNavigateLocally(const mojo::String& url) override;
- void RequestNavigate(Target target, URLRequestPtr request) override;
- void RequestNavigateHistory(int32_t delta) override;
-
- WindowManagerController* window_manager_;
- Id view_id_;
- std::vector<std::string> history_;
- int32_t current_index_;
-
- BindingSet<NavigatorHost> bindings_;
-
- DISALLOW_COPY_AND_ASSIGN(NavigatorHostImpl);
-};
-
-class RootLayoutManager : public ViewObserver {
- public:
- RootLayoutManager(ViewManager* view_manager,
- View* root,
- Id content_view_id,
- Id launcher_ui_view_id,
- Id control_panel_view_id)
- : root_(root),
- view_manager_(view_manager),
- content_view_id_(content_view_id),
- launcher_ui_view_id_(launcher_ui_view_id),
- control_panel_view_id_(control_panel_view_id) {}
- ~RootLayoutManager() override {
- if (root_)
- root_->RemoveObserver(this);
- }
-
- private:
- // Overridden from ViewObserver:
- void OnViewBoundsChanged(View* view,
- const Rect& old_bounds,
- const Rect& new_bounds) override {
- DCHECK_EQ(view, root_);
-
- View* content_view = view_manager_->GetViewById(content_view_id_);
- content_view->SetBounds(new_bounds);
-
- int delta_width = new_bounds.width - old_bounds.width;
- int delta_height = new_bounds.height - old_bounds.height;
-
- View* launcher_ui_view = view_manager_->GetViewById(launcher_ui_view_id_);
- Rect launcher_ui_bounds(launcher_ui_view->bounds());
- launcher_ui_bounds.width += delta_width;
- launcher_ui_view->SetBounds(launcher_ui_bounds);
-
- View* control_panel_view =
- view_manager_->GetViewById(control_panel_view_id_);
- Rect control_panel_bounds(control_panel_view->bounds());
- control_panel_bounds.x += delta_width;
- control_panel_view->SetBounds(control_panel_bounds);
-
- const View::Children& content_views = content_view->children();
- View::Children::const_iterator iter = content_views.begin();
- for (; iter != content_views.end(); ++iter) {
- View* view = *iter;
- if (view->id() == control_panel_view->id() ||
- view->id() == launcher_ui_view->id())
- continue;
- Rect view_bounds(view->bounds());
- view_bounds.width += delta_width;
- view_bounds.height += delta_height;
- view->SetBounds(view_bounds);
- }
- }
- void OnViewDestroyed(View* view) override {
- DCHECK_EQ(view, root_);
- root_->RemoveObserver(this);
- root_ = NULL;
- }
-
- View* root_;
- ViewManager* view_manager_;
- const Id content_view_id_;
- const Id launcher_ui_view_id_;
- const Id control_panel_view_id_;
-
- DISALLOW_COPY_AND_ASSIGN(RootLayoutManager);
-};
-
-class Window : public InterfaceFactory<NavigatorHost> {
- public:
- Window(WindowManagerController* window_manager, View* view)
- : window_manager_(window_manager),
- view_(view),
- navigator_host_(window_manager_, view_->id()) {
- exposed_services_impl_.AddService<NavigatorHost>(this);
- }
-
- ~Window() override {}
-
- View* view() const { return view_; }
-
- NavigatorHost* navigator_host() { return &navigator_host_; }
-
- void Embed(const std::string& url) {
- // TODO: Support embedding multiple times?
- ServiceProviderPtr exposed_services;
- exposed_services_impl_.Bind(GetProxy(&exposed_services));
- view_->Embed(url, nullptr, exposed_services.Pass());
- navigator_host_.RecordNavigation(url);
- }
-
- private:
- // InterfaceFactory<NavigatorHost>
- void Create(ApplicationConnection* connection,
- InterfaceRequest<NavigatorHost> request) override {
- navigator_host_.Bind(request.Pass());
- }
-
- WindowManagerController* window_manager_;
- View* view_;
- ServiceProviderImpl exposed_services_impl_;
- NavigatorHostImpl navigator_host_;
-};
-
-class WindowManagerController
- : public examples::DebugPanelHost,
- public window_manager::WindowManagerController,
- public ui::EventHandler,
- public ui::AcceleratorTarget,
- public mojo::InterfaceFactory<examples::DebugPanelHost>,
- public InterfaceFactory<::examples::IWindowManager> {
- public:
- WindowManagerController(Shell* shell,
- ApplicationImpl* app,
- ApplicationConnection* connection,
- window_manager::WindowManagerRoot* wm_root)
- : shell_(shell),
- launcher_ui_(NULL),
- view_manager_(NULL),
- window_manager_root_(wm_root),
- navigation_target_(Target::DEFAULT),
- app_(app),
- binding_(this) {
- connection->AddService<::examples::IWindowManager>(this);
- }
-
- ~WindowManagerController() override {
- // host() may be destroyed by the time we get here.
- // TODO: figure out a way to always cleanly remove handler.
-
- // TODO(erg): In the aura version, we removed ourselves from the
- // PreTargetHandler list here. We may need to do something analogous when
- // we get event handling without aura working.
- }
-
- void CloseWindow(Id view_id) {
- WindowVector::iterator iter = GetWindowByViewId(view_id);
- DCHECK(iter != windows_.end());
- Window* window = *iter;
- windows_.erase(iter);
- window->view()->Destroy();
- }
-
- void DidNavigateLocally(uint32 source_view_id, const mojo::String& url) {
- LOG(ERROR) << "DidNavigateLocally: source_view_id: " << source_view_id
- << " url: " << url.To<std::string>();
- }
-
- void RequestNavigate(uint32 source_view_id,
- Target target,
- const mojo::String& url) {
- OnLaunch(source_view_id, target, url);
- }
-
- // Overridden from mojo::DebugPanelHost:
- void CloseTopWindow() override {
- if (!windows_.empty())
- CloseWindow(windows_.back()->view()->id());
- }
-
- void NavigateTo(const String& url) override {
- OnLaunch(control_panel_id_, Target::NEW_NODE, url);
- }
-
- void SetNavigationTarget(Target t) override { navigation_target_ = t; }
-
- // mojo::InterfaceFactory<examples::DebugPanelHost> implementation.
- void Create(
- mojo::ApplicationConnection* connection,
- mojo::InterfaceRequest<examples::DebugPanelHost> request) override {
- binding_.Bind(request.Pass());
- }
-
- // mojo::InterfaceFactory<::examples::IWindowManager> implementation.
- void Create(
- mojo::ApplicationConnection* connection,
- mojo::InterfaceRequest<::examples::IWindowManager> request) override {
- new WindowManagerConnection(this, request.Pass());
- }
-
- private:
- typedef std::vector<Window*> WindowVector;
-
- // Overridden from ViewManagerDelegate:
- void OnEmbed(View* root,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services) override {
- DCHECK(!view_manager_);
- view_manager_ = root->view_manager();
-
- View* view = view_manager_->CreateView();
- root->AddChild(view);
- Rect rect;
- rect.width = root->bounds().width;
- rect.height = root->bounds().height;
- view->SetBounds(rect);
- view->SetVisible(true);
- content_view_id_ = view->id();
-
- Id launcher_ui_id = CreateLauncherUI();
- control_panel_id_ = CreateControlPanel(view);
-
- root_layout_manager_.reset(
- new RootLayoutManager(view_manager_, root, content_view_id_,
- launcher_ui_id, control_panel_id_));
- root->AddObserver(root_layout_manager_.get());
-
- // TODO(erg): In the aura version, we explicitly added ourselves as a
- // PreTargetHandler to the window() here. We probably have to do something
- // analogous here.
-
- window_manager_root_->InitFocus(
- make_scoped_ptr(new window_manager::BasicFocusRules(root)));
- window_manager_root_->accelerator_manager()->Register(
- ui::Accelerator(ui::VKEY_BROWSER_BACK, 0),
- ui::AcceleratorManager::kNormalPriority, this);
- }
- void OnViewManagerDisconnected(ViewManager* view_manager) override {
- DCHECK_EQ(view_manager_, view_manager);
- view_manager_ = NULL;
- base::MessageLoop::current()->Quit();
- }
-
- // Overridden from WindowManagerDelegate:
- void Embed(const String& url,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services) override {
- const Id kInvalidSourceViewId = 0;
- OnLaunch(kInvalidSourceViewId, Target::DEFAULT, url);
- }
-
- // Overridden from ui::EventHandler:
- void OnEvent(ui::Event* event) override {
- View* view =
- static_cast<window_manager::ViewTarget*>(event->target())->view();
- if (event->type() == ui::ET_MOUSE_PRESSED)
- view->SetFocus();
- }
-
- // Overriden from ui::AcceleratorTarget:
- bool AcceleratorPressed(const ui::Accelerator& accelerator,
- mojo::View* view) override {
- if (accelerator.key_code() != ui::VKEY_BROWSER_BACK)
- return false;
-
- WindowVector::iterator iter = GetWindowByViewId(view->id());
- DCHECK(iter != windows_.end());
- Window* window = *iter;
- window->navigator_host()->RequestNavigateHistory(-1);
- return true;
- }
-
- // Overriden from ui::AcceleratorTarget:
- bool CanHandleAccelerators() const override { return true; }
-
- void OnLaunch(uint32 source_view_id,
- Target requested_target,
- const mojo::String& url) {
- Target target = navigation_target_;
- if (target == Target::DEFAULT) {
- if (requested_target != Target::DEFAULT) {
- target = requested_target;
- } else {
- // TODO(aa): Should be Target::NEW_NODE if source origin and dest origin
- // are different?
- target = Target::SOURCE_NODE;
- }
- }
-
- Window* dest_view = NULL;
- if (target == Target::SOURCE_NODE) {
- WindowVector::iterator source_view = GetWindowByViewId(source_view_id);
- bool app_initiated = source_view != windows_.end();
- if (app_initiated)
- dest_view = *source_view;
- else if (!windows_.empty())
- dest_view = windows_.back();
- }
-
- if (!dest_view) {
- dest_view = CreateWindow();
- windows_.push_back(dest_view);
- }
-
- dest_view->Embed(url);
- }
-
- // TODO(beng): proper layout manager!!
- Id CreateLauncherUI() {
- View* view = view_manager_->GetViewById(content_view_id_);
- Rect bounds = view->bounds();
- bounds.x += kBorderInset;
- bounds.y += kBorderInset;
- bounds.width -= 2 * kBorderInset;
- bounds.height = kTextfieldHeight;
- launcher_ui_ = CreateWindow(bounds);
- launcher_ui_->Embed("mojo:browser");
- return launcher_ui_->view()->id();
- }
-
- Window* CreateWindow() {
- View* view = view_manager_->GetViewById(content_view_id_);
- Rect bounds;
- bounds.x = kBorderInset;
- bounds.y = 2 * kBorderInset + kTextfieldHeight;
- bounds.width = view->bounds().width - 3 * kBorderInset - kControlPanelWidth;
- bounds.height =
- view->bounds().height - (3 * kBorderInset + kTextfieldHeight);
- if (!windows_.empty()) {
- bounds.x = windows_.back()->view()->bounds().x + 35;
- bounds.y = windows_.back()->view()->bounds().y + 35;
- }
- return CreateWindow(bounds);
- }
-
- Window* CreateWindow(const Rect& bounds) {
- View* content = view_manager_->GetViewById(content_view_id_);
- View* view = view_manager_->CreateView();
- content->AddChild(view);
- view->SetBounds(bounds);
- view->SetVisible(true);
- view->SetFocus();
- return new Window(this, view);
- }
-
- Id CreateControlPanel(View* root) {
- View* view = view_manager_->CreateView();
- root->AddChild(view);
-
- Rect bounds;
- bounds.x = root->bounds().width - kControlPanelWidth - kBorderInset;
- bounds.y = kBorderInset * 2 + kTextfieldHeight;
- bounds.width = kControlPanelWidth;
- bounds.height = root->bounds().height - kBorderInset * 3 - kTextfieldHeight;
- view->SetBounds(bounds);
- view->SetVisible(true);
-
- ServiceProviderPtr exposed_services;
- control_panel_exposed_services_impl_.Bind(GetProxy(&exposed_services));
- control_panel_exposed_services_impl_.AddService<::examples::IWindowManager>(
- this);
-
- GURL frame_url = url_.Resolve("/examples/window_manager/debug_panel.sky");
- view->Embed(frame_url.spec(), nullptr, exposed_services.Pass());
-
- return view->id();
- }
-
- WindowVector::iterator GetWindowByViewId(Id view_id) {
- for (std::vector<Window*>::iterator iter = windows_.begin();
- iter != windows_.end(); ++iter) {
- if ((*iter)->view()->id() == view_id) {
- return iter;
- }
- }
- return windows_.end();
- }
-
- Shell* shell_;
-
- Window* launcher_ui_;
- WindowVector windows_;
- ViewManager* view_manager_;
- scoped_ptr<RootLayoutManager> root_layout_manager_;
- ServiceProviderImpl control_panel_exposed_services_impl_;
-
- window_manager::WindowManagerRoot* window_manager_root_;
-
- // Id of the view most content is added to.
- Id content_view_id_;
-
- // Id of the debug panel.
- Id control_panel_id_;
-
- GURL url_;
- Target navigation_target_;
-
- ApplicationImpl* app_;
-
- mojo::Binding<examples::DebugPanelHost> binding_;
-
- DISALLOW_COPY_AND_ASSIGN(WindowManagerController);
-};
-
-class WindowManager : public ApplicationDelegate,
- public window_manager::WindowManagerControllerFactory {
- public:
- WindowManager()
- : window_manager_app_(new window_manager::WindowManagerApp(this)) {}
-
- scoped_ptr<window_manager::WindowManagerController>
- CreateWindowManagerController(
- ApplicationConnection* connection,
- window_manager::WindowManagerRoot* wm_root) override {
- return scoped_ptr<WindowManagerController>(
- new WindowManagerController(shell_, app_, connection, wm_root));
- }
-
- private:
- // Overridden from ApplicationDelegate:
- void Initialize(ApplicationImpl* app) override {
- window_manager_app_.reset(new window_manager::WindowManagerApp(this));
- shell_ = app->shell();
- app_ = app;
- // FIXME: Mojo applications don't know their URLs yet:
- // https://docs.google.com/a/chromium.org/document/d/1AQ2y6ekzvbdaMF5WrUQmneyXJnke-MnYYL4Gz1AKDos
- url_ = GURL(app->args()[1]);
- window_manager_app_->Initialize(app);
- }
-
- bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
- window_manager_app_->ConfigureIncomingConnection(connection);
- return true;
- }
-
- ApplicationImpl* app_;
- Shell* shell_;
- GURL url_;
-
- scoped_ptr<window_manager::WindowManagerApp> window_manager_app_;
- DISALLOW_COPY_AND_ASSIGN(WindowManager);
-};
-
-void WindowManagerConnection::CloseWindow(Id view_id) {
- window_manager_->CloseWindow(view_id);
-}
-
-void NavigatorHostImpl::DidNavigateLocally(const mojo::String& url) {
- window_manager_->DidNavigateLocally(view_id_, url);
- RecordNavigation(url);
-}
-
-void NavigatorHostImpl::RequestNavigate(Target target, URLRequestPtr request) {
- window_manager_->RequestNavigate(view_id_, target, request->url);
-}
-
-void NavigatorHostImpl::RequestNavigateHistory(int32_t delta) {
- if (history_.empty())
- return;
- current_index_ =
- std::max(0, std::min(current_index_ + delta,
- static_cast<int32_t>(history_.size()) - 1));
- window_manager_->RequestNavigate(view_id_, Target::SOURCE_NODE,
- history_[current_index_]);
-}
-
-void NavigatorHostImpl::RecordNavigation(const std::string& url) {
- if (current_index_ >= 0 && history_[current_index_] == url) {
- // This is a navigation to the current entry, ignore.
- return;
- }
- history_.erase(history_.begin() + (current_index_ + 1), history_.end());
- history_.push_back(url);
- ++current_index_;
-}
-
-} // namespace examples
-} // namespace mojo
-
-MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunnerChromium runner(new mojo::examples::WindowManager);
- return runner.Run(application_request);
-}
diff --git a/examples/window_manager/window_manager.mojom b/examples/window_manager/window_manager.mojom
deleted file mode 100644
index d2e161f..0000000
--- a/examples/window_manager/window_manager.mojom
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2014 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.
-
-module examples;
-
-import "mojo/services/geometry/interfaces/geometry.mojom";
-
-interface IWindowManager {
- CloseWindow(uint32 node_id);
-};
diff --git a/examples/wm_flow/BUILD.gn b/examples/wm_flow/BUILD.gn
deleted file mode 100644
index d2dab6f..0000000
--- a/examples/wm_flow/BUILD.gn
+++ /dev/null
@@ -1,99 +0,0 @@
-# Copyright 2014 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("//mojo/public/tools/bindings/mojom.gni")
-
-group("wm_flow") {
- deps = [
- ":app",
- ":embedded",
- ":wm",
- ]
-}
-
-mojo_native_application("wm") {
- output_name = "wm_flow_wm"
-
- sources = [
- "wm/frame_controller.cc",
- "wm/frame_controller.h",
- "wm/wm.cc",
- ]
-
- deps = [
- ":wm_bindings",
- "//base",
- "//mojo/application",
- "//mojo/converters/geometry",
- "//mojo/public/interfaces/application",
- "//mojo/services/input_events/interfaces",
- "//mojo/services/view_manager/cpp",
- "//services/window_manager:lib",
- "//skia",
- "//ui/gfx/geometry",
- "//url",
- ]
-}
-
-mojo_native_application("app") {
- output_name = "wm_flow_app"
-
- sources = [
- "app/app.cc",
- ]
-
- deps = [
- ":embedder_bindings",
- ":embeddee_bindings",
- "//base",
- "//examples/bitmap_uploader",
- "//mojo/application",
- "//mojo/common",
- "//mojo/public/interfaces/application:application",
- "//mojo/services/view_manager/cpp",
- "//services/window_manager:lib",
- "//skia",
- "//url",
- ]
-}
-
-mojo_native_application("embedded") {
- output_name = "wm_flow_embedded"
-
- sources = [
- "embedded/embedded.cc",
- ]
-
- deps = [
- ":embeddee_bindings",
- ":embedder_bindings",
- "//base",
- "//examples/bitmap_uploader",
- "//mojo/application",
- "//mojo/services/view_manager/cpp",
- "//services/window_manager:lib",
- "//skia",
- "//url",
- ]
-}
-
-mojom("wm_bindings") {
- sources = [
- "wm/window_frame_host.mojom",
- ]
-}
-
-mojom("embedder_bindings") {
- sources = [
- "app/embedder.mojom",
- ]
-}
-
-mojom("embeddee_bindings") {
- sources = [
- "embedded/embeddee.mojom",
- ]
-}
diff --git a/examples/wm_flow/app/app.cc b/examples/wm_flow/app/app.cc
deleted file mode 100644
index 163bd1a..0000000
--- a/examples/wm_flow/app/app.cc
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright 2014 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 <map>
-
-#include "base/bind.h"
-#include "base/macros.h"
-#include "base/stl_util.h"
-#include "examples/bitmap_uploader/bitmap_uploader.h"
-#include "examples/wm_flow/app/embedder.mojom.h"
-#include "examples/wm_flow/embedded/embeddee.mojom.h"
-#include "mojo/application/application_runner_chromium.h"
-#include "mojo/common/binding_set.h"
-#include "mojo/public/c/system/main.h"
-#include "mojo/public/cpp/application/application_connection.h"
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/connect.h"
-#include "mojo/public/cpp/application/interface_factory_impl.h"
-#include "mojo/public/cpp/application/service_provider_impl.h"
-#include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/public/interfaces/application/service_provider.mojom.h"
-#include "mojo/services/view_manager/cpp/view.h"
-#include "mojo/services/view_manager/cpp/view_manager.h"
-#include "mojo/services/view_manager/cpp/view_manager_client_factory.h"
-#include "mojo/services/view_manager/cpp/view_manager_context.h"
-#include "mojo/services/view_manager/cpp/view_manager_delegate.h"
-#include "mojo/services/view_manager/cpp/view_observer.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "url/gurl.h"
-
-namespace examples {
-namespace {
-
-// TODO(johngro) : investigate extending mojom with a formal flags type which it
-// generates good bindings for, so we don't need to resort to this.
-static inline constexpr bool operator &(const mojo::EventFlags& f1,
- const mojo::EventFlags& f2) {
- return ((static_cast<uint32_t>(f1) & static_cast<uint32_t>(f2)) != 0);
-}
-
-const SkColor kColors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorYELLOW };
-
-class EmbedderImpl : public Embedder {
- public:
- explicit EmbedderImpl(mojo::InterfaceRequest<Embedder> request)
- : binding_(this, request.Pass()) {}
- ~EmbedderImpl() override {}
-
- private:
- // Overridden from Embedder:
- void HelloWorld(const mojo::Callback<void()>& callback) override {
- callback.Run();
- }
-
- mojo::StrongBinding<Embedder> binding_;
- DISALLOW_COPY_AND_ASSIGN(EmbedderImpl);
-};
-
-class EmbedderImplProvider : public mojo::ServiceProvider {
- public:
- EmbedderImplProvider() {}
- ~EmbedderImplProvider() override {}
-
- void AddBinding(mojo::InterfaceRequest<mojo::ServiceProvider> request) {
- embeddee_exposed_services_.AddBinding(this, request.Pass());
- }
-
- private:
- // mojo::ServiceProvider implementation
- void ConnectToService(const mojo::String& interface_name,
- mojo::ScopedMessagePipeHandle pipe_handle) override {
- if (interface_name != Embedder::Name_)
- return;
- new EmbedderImpl(mojo::MakeRequest<Embedder>(pipe_handle.Pass()));
- }
-
- mojo::BindingSet<mojo::ServiceProvider> embeddee_exposed_services_;
-
- DISALLOW_COPY_AND_ASSIGN(EmbedderImplProvider);
-};
-
-} // namespace
-
-// This app starts its life via Connect() rather than by being embed, so it does
-// not start with a connection to the ViewManager service. It has to obtain a
-// connection by connecting to the ViewManagerInit service and asking to be
-// embed without a view context.
-class WMFlowApp : public mojo::ApplicationDelegate,
- public mojo::ViewManagerDelegate,
- public mojo::ViewObserver {
- public:
- WMFlowApp() : shell_(nullptr), embed_count_(0) {}
- ~WMFlowApp() override { STLDeleteValues(&uploaders_); }
-
- private:
- typedef std::map<mojo::View*, mojo::BitmapUploader*> ViewToUploader;
-
- // Overridden from ApplicationDelegate:
- void Initialize(mojo::ApplicationImpl* app) override {
- shell_ = app->shell();
- view_manager_client_factory_.reset(
- new mojo::ViewManagerClientFactory(app->shell(), this));
- view_manager_context_.reset(new mojo::ViewManagerContext(app));
- // FIXME: Mojo applications don't know their URLs yet:
- // https://docs.google.com/a/chromium.org/document/d/1AQ2y6ekzvbdaMF5WrUQmneyXJnke-MnYYL4Gz1AKDos
- url_ = GURL(app->args()[1]);
- OpenNewWindow();
- OpenNewWindow();
- OpenNewWindow();
- }
- bool ConfigureIncomingConnection(
- mojo::ApplicationConnection* connection) override {
- connection->AddService(view_manager_client_factory_.get());
- return true;
- }
-
- // Overridden from mojo::ViewManagerDelegate:
- void OnEmbed(mojo::View* root,
- mojo::InterfaceRequest<mojo::ServiceProvider> services,
- mojo::ServiceProviderPtr exposed_services) override {
- root->AddObserver(this);
- mojo::BitmapUploader* uploader = new mojo::BitmapUploader(root);
- uploaders_[root] = uploader;
- uploader->Init(shell_);
- // BitmapUploader does not track view size changes, we would
- // need to subscribe to OnViewBoundsChanged and tell the bitmap uploader
- // to invalidate itself. This is better done once if had a per-view
- // object instead of holding per-view state on the ApplicationDelegate.
- uploader->SetColor(kColors[embed_count_++ % arraysize(kColors)]);
-
- mojo::View* embed = root->view_manager()->CreateView();
- root->AddChild(embed);
- mojo::Rect bounds;
- bounds.x = bounds.y = 25;
- bounds.width = root->bounds().width - 50;
- bounds.height = root->bounds().height - 50;
- embed->SetBounds(bounds);
- embed->SetVisible(true);
-
- mojo::ServiceProviderPtr embedee_exposed_services;
- embeddee_provider_.AddBinding(GetProxy(&embedee_exposed_services));
-
- GURL embedded_app_url = url_.Resolve("wm_flow_embedded.mojo");
- mojo::ServiceProviderPtr imported;
- embed->Embed(embedded_app_url.spec(), GetProxy(&imported),
- embedee_exposed_services.Pass());
- // FIXME: This is wrong. We're storing per-view state on this per-app
- // delegate. Every time a new view is created embedee_ is replaced
- // causing the previous one to shut down. This class should not
- // be a ViewManagerDelegate, but rather a separate object should be
- // created for each embedding.
- mojo::ConnectToService(imported.get(), &embeddee_);
- embeddee_->HelloBack(base::Bind(&WMFlowApp::HelloBackAck,
- base::Unretained(this)));
- }
- void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override {
- STLDeleteValues(&uploaders_);
- }
-
- // Overridden from mojo::ViewObserver:
- void OnViewInputEvent(mojo::View* view,
- const mojo::EventPtr& event) override {
- if (event->action == mojo::EventType::POINTER_UP &&
- event->flags & mojo::EventFlags::LEFT_MOUSE_BUTTON) {
- OpenNewWindow();
- }
- }
- void OnViewDestroyed(mojo::View* view) override {
- if (uploaders_.find(view) != uploaders_.end()) {
- delete uploaders_[view];
- uploaders_.erase(view);
- }
- --embed_count_;
- view->RemoveObserver(this);
- }
-
- void HelloBackAck() {
- printf("HelloBack() ack'ed\n");
- }
-
- void OpenNewWindow() { view_manager_context_->Embed(url_.spec()); }
-
- mojo::Shell* shell_;
- int embed_count_;
- scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_;
- scoped_ptr<mojo::ViewManagerContext> view_manager_context_;
- EmbeddeePtr embeddee_;
- EmbedderImplProvider embeddee_provider_;
- ViewToUploader uploaders_;
- GURL url_;
-
- DISALLOW_COPY_AND_ASSIGN(WMFlowApp);
-};
-
-} // namespace examples
-
-MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunnerChromium runner(new examples::WMFlowApp);
- return runner.Run(application_request);
-}
diff --git a/examples/wm_flow/app/embedder.mojom b/examples/wm_flow/app/embedder.mojom
deleted file mode 100644
index ee9b4a7..0000000
--- a/examples/wm_flow/app/embedder.mojom
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2014 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.
-
-module examples;
-
-interface Embedder {
- HelloWorld() => ();
-};
diff --git a/examples/wm_flow/embedded/embedded.cc b/examples/wm_flow/embedded/embedded.cc
deleted file mode 100644
index f7c67f8..0000000
--- a/examples/wm_flow/embedded/embedded.cc
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright 2014 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 "base/bind.h"
-#include "base/macros.h"
-#include "examples/bitmap_uploader/bitmap_uploader.h"
-#include "examples/wm_flow/app/embedder.mojom.h"
-#include "examples/wm_flow/embedded/embeddee.mojom.h"
-#include "mojo/application/application_runner_chromium.h"
-#include "mojo/public/c/system/main.h"
-#include "mojo/public/cpp/application/application_connection.h"
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/connect.h"
-#include "mojo/public/cpp/application/service_provider_impl.h"
-#include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/services/view_manager/cpp/view.h"
-#include "mojo/services/view_manager/cpp/view_manager.h"
-#include "mojo/services/view_manager/cpp/view_manager_client_factory.h"
-#include "mojo/services/view_manager/cpp/view_manager_delegate.h"
-#include "third_party/skia/include/core/SkColor.h"
-
-namespace examples {
-
-namespace {
-
-class EmbeddeeImpl : public Embeddee {
- public:
- explicit EmbeddeeImpl(mojo::InterfaceRequest<Embeddee> request)
- : binding_(this, request.Pass()) {}
- ~EmbeddeeImpl() override {}
-
- private:
- // Overridden from Embeddee:
- void HelloBack(const mojo::Callback<void()>& callback) override {
- callback.Run();
- }
-
- mojo::StrongBinding<Embeddee> binding_;
- DISALLOW_COPY_AND_ASSIGN(EmbeddeeImpl);
-};
-
-} // namespace
-
-class WMFlowEmbedded : public mojo::ApplicationDelegate,
- public mojo::ViewManagerDelegate,
- public mojo::InterfaceFactory<Embeddee> {
- public:
- WMFlowEmbedded() : shell_(nullptr) {
- embeddee_provider_impl_.AddService(this);
- }
- ~WMFlowEmbedded() override {}
-
- private:
- // Overridden from Application:
- void Initialize(mojo::ApplicationImpl* app) override {
- shell_ = app->shell();
- view_manager_client_factory_.reset(
- new mojo::ViewManagerClientFactory(app->shell(), this));
- }
- bool ConfigureIncomingConnection(
- mojo::ApplicationConnection* connection) override {
- connection->AddService(view_manager_client_factory_.get());
- return true;
- }
-
- // Overridden from mojo::ViewManagerDelegate:
- void OnEmbed(mojo::View* root,
- mojo::InterfaceRequest<mojo::ServiceProvider> services,
- mojo::ServiceProviderPtr exposed_services) override {
- bitmap_uploader_.reset(new mojo::BitmapUploader(root));
- bitmap_uploader_->Init(shell_);
- // BitmapUploader does not track view size changes, we would
- // need to subscribe to OnViewBoundsChanged and tell the bitmap uploader
- // to invalidate itself. This is better done once if had a per-view
- // object instead of holding per-view state on the ApplicationDelegate.
- bitmap_uploader_->SetColor(SK_ColorMAGENTA);
-
- embeddee_provider_impl_.Bind(services.Pass());
- // FIXME: embedder_ is wrong for the same reason the embedee_ storage is
- // wrong in app.cc. We need separate per-instance storage not on the
- // application delegate.
- mojo::ConnectToService(exposed_services.get(), &embedder_);
- embedder_->HelloWorld(base::Bind(&WMFlowEmbedded::HelloWorldAck,
- base::Unretained(this)));
- }
- void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override {}
-
- // Overridden from mojo::InterfaceFactory<Embeddee>:
- void Create(mojo::ApplicationConnection* app,
- mojo::InterfaceRequest<Embeddee> request) override {
- new EmbeddeeImpl(request.Pass());
- }
-
- void HelloWorldAck() {
- printf("HelloWorld() ack'ed\n");
- }
-
- mojo::Shell* shell_;
- scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_;
- EmbedderPtr embedder_;
- mojo::ServiceProviderImpl embeddee_provider_impl_;
- scoped_ptr<mojo::BitmapUploader> bitmap_uploader_;
-
- DISALLOW_COPY_AND_ASSIGN(WMFlowEmbedded);
-};
-
-} // namespace examples
-
-MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunnerChromium runner(new examples::WMFlowEmbedded);
- return runner.Run(application_request);
-}
-
diff --git a/examples/wm_flow/embedded/embeddee.mojom b/examples/wm_flow/embedded/embeddee.mojom
deleted file mode 100644
index 097efdf..0000000
--- a/examples/wm_flow/embedded/embeddee.mojom
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2014 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.
-
-module examples;
-
-interface Embeddee {
- HelloBack() => ();
-};
diff --git a/examples/wm_flow/wm/frame_controller.cc b/examples/wm_flow/wm/frame_controller.cc
deleted file mode 100644
index c3ec629..0000000
--- a/examples/wm_flow/wm/frame_controller.cc
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2014 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 "examples/wm_flow/wm/frame_controller.h"
-
-#include "base/macros.h"
-#include "base/strings/utf_string_conversions.h"
-#include "mojo/converters/geometry/geometry_type_converters.h"
-#include "mojo/public/interfaces/application/service_provider.mojom.h"
-#include "mojo/services/view_manager/cpp/view.h"
-#include "mojo/services/view_manager/cpp/view_manager.h"
-#include "services/window_manager/capture_controller.h"
-#include "services/window_manager/window_manager_root.h"
-#include "url/gurl.h"
-
-////////////////////////////////////////////////////////////////////////////////
-// FrameController, public:
-
-FrameController::FrameController(
- const GURL& frame_app_url,
- mojo::View* view,
- mojo::View** app_view,
- window_manager::WindowManagerRoot* window_manager_root)
- : view_(view),
- app_view_(view->view_manager()->CreateView()),
- maximized_(false),
- window_manager_root_(window_manager_root),
- binding_(this) {
- view_->AddObserver(this);
- view_->SetVisible(true); // FIXME: This should not be our responsibility?
- *app_view = app_view_;
-
- viewer_services_impl_.AddService(this);
- mojo::ServiceProviderPtr viewer_services;
- viewer_services_impl_.Bind(GetProxy(&viewer_services));
-
- view_->Embed(frame_app_url.spec(), nullptr, viewer_services.Pass());
-
- // We weren't observing when our initial bounds was set:
- OnViewBoundsChanged(view, view->bounds(), view->bounds());
-
- // Add the child view after embedding sky, since embed clears children.
- view_->AddChild(app_view_);
- app_view_->SetVisible(true);
-}
-
-FrameController::~FrameController() {}
-
-void FrameController::Create(
- mojo::ApplicationConnection* connection,
- mojo::InterfaceRequest<examples::WindowFrameHost> request) {
- binding_.Bind(request.Pass());
-}
-
-void FrameController::CloseWindow() {
- // This destroys |app_view_| as it is a child of |view_|.
- view_->Destroy();
-}
-
-void FrameController::ToggleMaximize() {
- if (!maximized_)
- restored_bounds_ = view_->bounds().To<gfx::Rect>();
- maximized_ = !maximized_;
- if (maximized_)
- view_->SetBounds(view_->parent()->bounds());
- else
- view_->SetBounds(*mojo::Rect::From(restored_bounds_));
-}
-
-void FrameController::ActivateWindow() {
- window_manager_root_->focus_controller()->ActivateView(view_);
-}
-
-void FrameController::SetCapture(bool frame_has_capture) {
- if (frame_has_capture)
- window_manager_root_->capture_controller()->SetCapture(view_);
- else
- window_manager_root_->capture_controller()->ReleaseCapture(view_);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// FrameController, mojo::ViewObserver implementation:
-
-void FrameController::OnViewDestroyed(mojo::View* view) {
- view_->RemoveObserver(this);
- delete this;
-}
-
-void FrameController::OnViewBoundsChanged(mojo::View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) {
- CHECK(view == view_);
- // Statically size the embedded view. Unclear if we should use a
- // sky iframe to participate in sky layout or not.
- const int kTopControlsAdditionalInset = 15;
- const int kDefaultInset = 25;
- mojo::Rect bounds;
- bounds.x = bounds.y = kDefaultInset;
- bounds.y += kTopControlsAdditionalInset;
- bounds.width = view_->bounds().width - kDefaultInset * 2;
- bounds.height =
- view_->bounds().height - kDefaultInset * 2 - kTopControlsAdditionalInset;
- app_view_->SetBounds(bounds);
-}
diff --git a/examples/wm_flow/wm/frame_controller.h b/examples/wm_flow/wm/frame_controller.h
deleted file mode 100644
index 5472459..0000000
--- a/examples/wm_flow/wm/frame_controller.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2014 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 EXAMPLES_WM_FLOW_WM_FRAME_CONTROLLER_H_
-#define EXAMPLES_WM_FLOW_WM_FRAME_CONTROLLER_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "examples/wm_flow/wm/window_frame_host.mojom.h"
-#include "mojo/public/cpp/application/interface_factory.h"
-#include "mojo/public/cpp/application/service_provider_impl.h"
-#include "mojo/services/view_manager/cpp/view_observer.h"
-#include "services/window_manager/focus_controller.h"
-#include "ui/gfx/geometry/rect.h"
-
-class GURL;
-
-namespace mojo {
-class NativeWidgetViewManager;
-class View;
-}
-
-namespace window_manager {
-class WindowManagerRoot;
-}
-
-// FrameController encapsulates the window manager's frame additions to a window
-// created by an application. It renders the content of the frame and responds
-// to any events targeted at it.
-class FrameController
- : public examples::WindowFrameHost,
- public mojo::ViewObserver,
- public mojo::InterfaceFactory<examples::WindowFrameHost> {
- public:
- FrameController(const GURL& frame_app_url,
- mojo::View* view,
- mojo::View** app_view,
- window_manager::WindowManagerRoot* window_manager_root);
- ~FrameController() override;
-
- // mojo::InterfaceFactory<examples::WindowFrameHost> implementation.
- void Create(
- mojo::ApplicationConnection* connection,
- mojo::InterfaceRequest<examples::WindowFrameHost> request) override;
-
- // examples::WindowFrameHost
- void CloseWindow() override;
- void ToggleMaximize() override;
- void ActivateWindow() override;
- void SetCapture(bool frame_has_capture) override;
-
- private:
- void OnViewDestroyed(mojo::View* view) override;
- void OnViewBoundsChanged(mojo::View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) override;
-
- mojo::View* view_;
- mojo::View* app_view_;
- bool maximized_;
- gfx::Rect restored_bounds_;
- window_manager::WindowManagerRoot* window_manager_root_;
- mojo::ServiceProviderImpl viewer_services_impl_;
-
- mojo::Binding<examples::WindowFrameHost> binding_;
-
- DISALLOW_COPY_AND_ASSIGN(FrameController);
-};
-
-#endif // EXAMPLES_WM_FLOW_WM_FRAME_CONTROLLER_H_
diff --git a/examples/wm_flow/wm/window_frame.sky b/examples/wm_flow/wm/window_frame.sky
deleted file mode 100644
index 4e2267a..0000000
--- a/examples/wm_flow/wm/window_frame.sky
+++ /dev/null
@@ -1,84 +0,0 @@
-#!mojo mojo:sky_viewer
-<!--
-// 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.
--->
-<sky>
-<import src="/gen/examples/wm_flow/wm/window_frame_host.mojom.sky" as="example" />
-<import src="/sky/framework/embedder.sky" as="embedder" />
-<import src="/sky/framework/sky-button.sky"/>
-<import src="/sky/framework/sky-checkbox.sky"/>
-<import src="/sky/framework/sky-element/sky-element.sky" as="SkyElement"/>
-
-<style>
-/* FIXME: Hack until the requirement of a single root element is lifted. */
-sky { height: 100%; }
-</style>
-
-<sky-element name="window-frame">
-<template>
- <style>
- :host {
- height: 100%;
- background-color: lightgrey;
- }
- /* Nest two flexboxes and make the right side take up as much as possible */
- window-bar {
- display: flex;
- }
- left {
- flex: 1;
- display: flex;
- align-content: flex-start;
- }
- /* Also making the checkbox and label a flexbox for convenience */
- right {
- display: flex;
- }
-
- /* Style sky controls to make them look more like ui/views */
- sky-button {
- border: none;
- border: 1px solid blue;
- padding: 2px;
- }
- sky-button:hover {
- border: 1px solid lightblue;
- background-color: darkgrey;
- }
- </style>
- <window-bar>
- <left>
- <sky-checkbox on-click="handleCaptureClick" />Capture
- </left>
- <right>
- <sky-button on-click="handleEmbiggenClick">Embiggen</sky-button>
- <sky-button on-click="handleBegoneClick">Begone</sky-button>
- </right>
- </window-bar>
-</template>
-<script>
-module.exports = class extends SkyElement {
- created() {
- this.embedder = embedder.connectToEmbedderService(example.WindowFrameHost);
- this.addEventListener('mousedown', function() {
- this.embedder.activateWindow();
- }.bind(this));
- }
- handleCaptureClick(event) {
- this.embedder.setCapture(event.target.checked);
- }
- handleEmbiggenClick(event) {
- this.embedder.toggleMaximize();
- }
- handleBegoneClick(event) {
- this.embedder.closeWindow();
- }
-}.register();
-</script>
-</sky-element>
-
-<window-frame />
-
-</sky>
diff --git a/examples/wm_flow/wm/window_frame_host.mojom b/examples/wm_flow/wm/window_frame_host.mojom
deleted file mode 100644
index 9b09fcd..0000000
--- a/examples/wm_flow/wm/window_frame_host.mojom
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2014 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.
-
-module examples;
-
-interface WindowFrameHost {
- ActivateWindow();
- CloseWindow();
- SetCapture(bool frame_has_capture);
- ToggleMaximize();
-};
diff --git a/examples/wm_flow/wm/wm.cc b/examples/wm_flow/wm/wm.cc
deleted file mode 100644
index f5b4286..0000000
--- a/examples/wm_flow/wm/wm.cc
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright 2014 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 "examples/wm_flow/wm/frame_controller.h"
-#include "mojo/application/application_runner_chromium.h"
-#include "mojo/public/c/system/main.h"
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/service_provider_impl.h"
-#include "mojo/services/input_events/interfaces/input_events.mojom.h"
-#include "mojo/services/view_manager/cpp/view_manager.h"
-#include "mojo/services/view_manager/cpp/view_manager_delegate.h"
-#include "mojo/services/view_manager/cpp/view_observer.h"
-#include "services/window_manager/basic_focus_rules.h"
-#include "services/window_manager/window_manager_app.h"
-#include "services/window_manager/window_manager_delegate.h"
-#include "services/window_manager/window_manager_root.h"
-#include "url/gurl.h"
-
-namespace examples {
-
-// TODO(johngro) : investigate extending mojom with a formal flags type which it
-// generates good bindings for, so we don't need to resort to this.
-static inline constexpr bool operator &(const mojo::EventFlags& f1,
- const mojo::EventFlags& f2) {
- return ((static_cast<uint32_t>(f1) & static_cast<uint32_t>(f2)) != 0);
-}
-
-class SimpleWMController : public window_manager::WindowManagerController,
- public mojo::ViewObserver {
- public:
- SimpleWMController(window_manager::WindowManagerRoot* wm_root)
- : window_manager_root_(wm_root),
- root_(NULL),
- window_container_(NULL),
- next_window_origin_(10, 10) {}
- ~SimpleWMController() override {}
-
- private:
- // Overridden from mojo::ViewManagerDelegate:
- void OnEmbed(mojo::View* root,
- mojo::InterfaceRequest<mojo::ServiceProvider> services,
- mojo::ServiceProviderPtr exposed_services) override {
- root_ = root;
-
- window_container_ = root->view_manager()->CreateView();
- window_container_->SetBounds(root_->bounds());
- root_->AddChild(window_container_);
- window_container_->SetVisible(true);
-
- window_manager_root_->InitFocus(make_scoped_ptr(
- new window_manager::BasicFocusRules(window_container_)));
- }
- void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override {
- root_ = NULL;
- }
-
- // Overridden from mojo::WindowManagerDelegate:
- void Embed(const mojo::String& url,
- mojo::InterfaceRequest<mojo::ServiceProvider> services,
- mojo::ServiceProviderPtr exposed_services) override {
- DCHECK(root_);
- mojo::View* app_view = NULL;
- CreateTopLevelWindow(&app_view);
- app_view->Embed(url, services.Pass(), exposed_services.Pass());
- }
-
- // Overridden from mojo::ViewObserver:
- void OnViewInputEvent(mojo::View* view,
- const mojo::EventPtr& event) override {
- if (event->action == mojo::EventType::POINTER_UP &&
- event->flags & mojo::EventFlags::RIGHT_MOUSE_BUTTON &&
- view->parent() == window_container_) {
- CloseWindow(view);
- }
- }
- void OnViewDestroyed(mojo::View* view) override {
- view->RemoveObserver(this);
- }
-
- void CloseWindow(mojo::View* view) {
- mojo::View* first_child = view->children().front();
- first_child->Destroy();
- view->Destroy();
- next_window_origin_.Offset(-50, -50);
- }
-
- mojo::View* CreateTopLevelWindow(mojo::View** app_view) {
- mojo::View* frame_view = root_->view_manager()->CreateView();
- // Add the View to it's parent before showing so that animations can happen.
- window_container_->AddChild(frame_view);
- mojo::Rect rect;
- rect.x = next_window_origin_.x();
- rect.y = next_window_origin_.y();
- rect.width = rect.height = 400;
- frame_view->SetBounds(rect);
- next_window_origin_.Offset(50, 50);
-
- GURL frame_url = url_.Resolve("/examples/wm_flow/wm/window_frame.sky");
- new FrameController(frame_url, frame_view, app_view, window_manager_root_);
- return frame_view;
- }
-
- window_manager::WindowManagerRoot* window_manager_root_;
-
- GURL url_;
- mojo::View* root_;
- mojo::View* window_container_;
-
- gfx::Point next_window_origin_;
-
- DISALLOW_COPY_AND_ASSIGN(SimpleWMController);
-};
-
-class SimpleWM : public mojo::ApplicationDelegate,
- public window_manager::WindowManagerControllerFactory {
- public:
- SimpleWM()
- : window_manager_app_(new window_manager::WindowManagerApp(this)) {}
-
- protected:
- ~SimpleWM() override {}
-
- private:
- // Overridden from mojo::ApplicationDelegate:
- void Initialize(mojo::ApplicationImpl* impl) override {
- // FIXME: Mojo applications don't know their URLs yet:
- // https://docs.google.com/a/chromium.org/document/d/1AQ2y6ekzvbdaMF5WrUQmneyXJnke-MnYYL4Gz1AKDos
- url_ = GURL(impl->args()[1]);
- window_manager_app_->Initialize(impl);
- }
-
- bool ConfigureIncomingConnection(
- mojo::ApplicationConnection* connection) override {
- window_manager_app_->ConfigureIncomingConnection(connection);
- return true;
- }
-
- scoped_ptr<window_manager::WindowManagerController>
- CreateWindowManagerController(
- mojo::ApplicationConnection* connection,
- window_manager::WindowManagerRoot* wm_root) override {
- return scoped_ptr<window_manager::WindowManagerController>(
- new SimpleWMController(wm_root));
- }
-
- scoped_ptr<window_manager::WindowManagerApp> window_manager_app_;
- GURL url_;
-
- DISALLOW_COPY_AND_ASSIGN(SimpleWM);
-};
-
-} // namespace examples
-
-MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunnerChromium runner(new examples::SimpleWM);
- return runner.Run(application_request);
-}