| Index: examples/keyboard/keyboard.cc
|
| diff --git a/examples/keyboard/keyboard.cc b/examples/keyboard/keyboard.cc
|
| deleted file mode 100644
|
| index d1138b2bc50a3c69a18e85bcd1d420151e113dc6..0000000000000000000000000000000000000000
|
| --- a/examples/keyboard/keyboard.cc
|
| +++ /dev/null
|
| @@ -1,150 +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/keyboard/keyboard.mojom.h"
|
| -#include "examples/keyboard/keyboard_delegate.h"
|
| -#include "examples/keyboard/keyboard_view.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/navigation/public/interfaces/navigation.mojom.h"
|
| -#include "mojo/services/view_manager/public/cpp/view.h"
|
| -#include "mojo/services/view_manager/public/cpp/view_manager.h"
|
| -#include "mojo/services/view_manager/public/cpp/view_manager_client_factory.h"
|
| -#include "mojo/services/view_manager/public/cpp/view_manager_delegate.h"
|
| -#include "mojo/views/native_widget_view_manager.h"
|
| -#include "mojo/views/views_init.h"
|
| -#include "ui/events/event.h"
|
| -#include "ui/views/layout/fill_layout.h"
|
| -#include "ui/views/widget/widget.h"
|
| -#include "ui/views/widget/widget_delegate.h"
|
| -#include "url/gurl.h"
|
| -
|
| -namespace mojo {
|
| -namespace examples {
|
| -
|
| -class Keyboard;
|
| -
|
| -class KeyboardServiceImpl : public InterfaceImpl<KeyboardService> {
|
| - public:
|
| - explicit KeyboardServiceImpl(Keyboard* keyboard);
|
| - virtual ~KeyboardServiceImpl() {}
|
| -
|
| - // KeyboardService:
|
| - virtual void SetTarget(uint32_t view_id) override;
|
| -
|
| - private:
|
| - Keyboard* keyboard_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(KeyboardServiceImpl);
|
| -};
|
| -
|
| -class Keyboard : public ApplicationDelegate,
|
| - public ViewManagerDelegate,
|
| - public KeyboardDelegate {
|
| - public:
|
| - Keyboard()
|
| - : shell_(nullptr),
|
| - keyboard_service_factory_(this),
|
| - keyboard_service_(NULL),
|
| - target_(0) {}
|
| -
|
| - virtual ~Keyboard() {
|
| - }
|
| -
|
| - void set_target(Id id) { target_ = id; }
|
| -
|
| - void set_keyboard_service(KeyboardServiceImpl* keyboard) {
|
| - keyboard_service_ = keyboard;
|
| - }
|
| -
|
| - private:
|
| - // Overridden from ApplicationDelegate:
|
| - virtual void Initialize(ApplicationImpl* app) override {
|
| - shell_ = app->shell();
|
| - view_manager_client_factory_.reset(
|
| - new ViewManagerClientFactory(shell_, this));
|
| - }
|
| -
|
| - virtual bool ConfigureIncomingConnection(
|
| - ApplicationConnection* connection) override {
|
| - views_init_.reset(new ViewsInit);
|
| - connection->AddService(view_manager_client_factory_.get());
|
| - connection->AddService(&keyboard_service_factory_);
|
| - return true;
|
| - }
|
| -
|
| - void CreateWidget(View* view) {
|
| - views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView;
|
| - widget_delegate->GetContentsView()->AddChildView(new KeyboardView(this));
|
| - widget_delegate->GetContentsView()->SetLayoutManager(new views::FillLayout);
|
| -
|
| - views::Widget* widget = new views::Widget;
|
| - views::Widget::InitParams params(
|
| - views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
|
| - params.native_widget = new NativeWidgetViewManager(widget, shell_, view);
|
| - params.delegate = widget_delegate;
|
| - params.bounds = gfx::Rect(view->bounds().width, view->bounds().height);
|
| - widget->Init(params);
|
| - widget->Show();
|
| - }
|
| -
|
| - // ViewManagerDelegate:
|
| - virtual void OnEmbed(View* root,
|
| - ServiceProviderImpl* exported_services,
|
| - scoped_ptr<ServiceProvider> imported_services) override {
|
| - // TODO: deal with OnEmbed() being invoked multiple times.
|
| - CreateWidget(root);
|
| - }
|
| - virtual void OnViewManagerDisconnected(
|
| - ViewManager* view_manager) override {
|
| - base::MessageLoop::current()->Quit();
|
| - }
|
| -
|
| - // KeyboardDelegate:
|
| - virtual void OnKeyPressed(int key_code, int event_flags) override {
|
| - if (!target_)
|
| - return;
|
| - keyboard_service_->client()->OnKeyboardEvent(target_, key_code,
|
| - event_flags);
|
| - }
|
| -
|
| - Shell* shell_;
|
| -
|
| - InterfaceFactoryImplWithContext<KeyboardServiceImpl, Keyboard>
|
| - keyboard_service_factory_;
|
| -
|
| - scoped_ptr<ViewsInit> views_init_;
|
| -
|
| - scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_;
|
| -
|
| - KeyboardServiceImpl* keyboard_service_;
|
| -
|
| - Id target_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(Keyboard);
|
| -};
|
| -
|
| -KeyboardServiceImpl::KeyboardServiceImpl(Keyboard* keyboard)
|
| - : keyboard_(keyboard) {
|
| - keyboard_->set_keyboard_service(this);
|
| -}
|
| -
|
| -void KeyboardServiceImpl::SetTarget(uint32_t view_id) {
|
| - keyboard_->set_target(view_id);
|
| -}
|
| -
|
| -} // namespace examples
|
| -} // namespace mojo
|
| -
|
| -MojoResult MojoMain(MojoHandle shell_handle) {
|
| - mojo::ApplicationRunnerChromium runner(new mojo::examples::Keyboard);
|
| - return runner.Run(shell_handle);
|
| -}
|
|
|