summaryrefslogtreecommitdiffstats
path: root/mojo/examples
diff options
context:
space:
mode:
authorsky <sky@chromium.org>2014-10-07 12:53:08 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-07 19:53:38 +0000
commit9e877c0132baa5ac52186addf7bf31c4521b105b (patch)
treee32f2ca9858edb466df7ba5d21457c1ecedd5020 /mojo/examples
parent00425c257e1d5a9cf8c7f0bd9e4d05904cda3f5b (diff)
downloadchromium_src-9e877c0132baa5ac52186addf7bf31c4521b105b.zip
chromium_src-9e877c0132baa5ac52186addf7bf31c4521b105b.tar.gz
chromium_src-9e877c0132baa5ac52186addf7bf31c4521b105b.tar.bz2
Makes it so each mojo::View outputs a surface
I didn't remove SetContents yet. There is one consumer that needs to converted. I'll do that separately. BUG=none TEST=none R=ben@chromium.org, jamesr@chromium.org Review URL: https://codereview.chromium.org/618073005 Cr-Commit-Position: refs/heads/master@{#298546}
Diffstat (limited to 'mojo/examples')
-rw-r--r--mojo/examples/aura_demo/aura_demo.cc22
-rw-r--r--mojo/examples/browser/browser.cc11
-rw-r--r--mojo/examples/keyboard/keyboard.cc10
-rw-r--r--mojo/examples/media_viewer/media_viewer.cc16
-rw-r--r--mojo/examples/window_manager/debug_panel.cc36
-rw-r--r--mojo/examples/window_manager/debug_panel.h7
-rw-r--r--mojo/examples/window_manager/window_manager.cc8
-rw-r--r--mojo/examples/wm_flow/wm/frame_controller.cc4
-rw-r--r--mojo/examples/wm_flow/wm/frame_controller.h4
-rw-r--r--mojo/examples/wm_flow/wm/wm.cc10
10 files changed, 73 insertions, 55 deletions
diff --git a/mojo/examples/aura_demo/aura_demo.cc b/mojo/examples/aura_demo/aura_demo.cc
index 1895761..917ea61 100644
--- a/mojo/examples/aura_demo/aura_demo.cc
+++ b/mojo/examples/aura_demo/aura_demo.cc
@@ -8,10 +8,8 @@
#include "base/bind.h"
#include "base/macros.h"
#include "mojo/application/application_runner_chromium.h"
-#include "mojo/aura/context_factory_mojo.h"
#include "mojo/aura/screen_mojo.h"
#include "mojo/aura/window_tree_host_mojo.h"
-#include "mojo/aura/window_tree_host_mojo_delegate.h"
#include "mojo/public/c/system/main.h"
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h"
@@ -107,10 +105,10 @@ class DemoWindowTreeClient : public aura::client::WindowTreeClient {
};
class AuraDemo : public mojo::ApplicationDelegate,
- public mojo::WindowTreeHostMojoDelegate,
public mojo::ViewManagerDelegate {
public:
- AuraDemo() : window1_(NULL), window2_(NULL), window21_(NULL) {}
+ AuraDemo()
+ : shell_(nullptr), window1_(NULL), window2_(NULL), window21_(NULL) {}
virtual ~AuraDemo() {}
private:
@@ -123,7 +121,7 @@ class AuraDemo : public mojo::ApplicationDelegate,
// TODO(beng): this function could be called multiple times!
root_ = root;
- window_tree_host_.reset(new mojo::WindowTreeHostMojo(root, this));
+ window_tree_host_.reset(new mojo::WindowTreeHostMojo(shell_, root));
window_tree_host_->InitHost();
window_tree_client_.reset(
@@ -157,17 +155,11 @@ class AuraDemo : public mojo::ApplicationDelegate,
base::MessageLoop::current()->Quit();
}
- // WindowTreeHostMojoDelegate:
- virtual void CompositorContentsChanged(const SkBitmap& bitmap) override {
- root_->SetContents(bitmap);
- }
-
virtual void Initialize(mojo::ApplicationImpl* app) override {
+ shell_ = app->shell();
view_manager_client_factory_.reset(
- new mojo::ViewManagerClientFactory(app->shell(), this));
+ new mojo::ViewManagerClientFactory(shell_, this));
aura::Env::CreateInstance(true);
- context_factory_.reset(new mojo::ContextFactoryMojo);
- aura::Env::GetInstance()->set_context_factory(context_factory_.get());
screen_.reset(mojo::ScreenMojo::Create());
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
}
@@ -178,9 +170,9 @@ class AuraDemo : public mojo::ApplicationDelegate,
return true;
}
- scoped_ptr<DemoWindowTreeClient> window_tree_client_;
+ mojo::Shell* shell_;
- scoped_ptr<ui::ContextFactory> context_factory_;
+ scoped_ptr<DemoWindowTreeClient> window_tree_client_;
scoped_ptr<mojo::ScreenMojo> screen_;
diff --git a/mojo/examples/browser/browser.cc b/mojo/examples/browser/browser.cc
index 2a77f89..2f22d16 100644
--- a/mojo/examples/browser/browser.cc
+++ b/mojo/examples/browser/browser.cc
@@ -155,9 +155,7 @@ class Browser : public ApplicationDelegate,
public ViewObserver {
public:
Browser()
- : view_manager_(NULL),
- root_(NULL),
- widget_(NULL) {}
+ : shell_(nullptr), view_manager_(NULL), root_(NULL), widget_(NULL) {}
virtual ~Browser() {
if (root_)
@@ -167,8 +165,9 @@ class Browser : public ApplicationDelegate,
private:
// Overridden from ApplicationDelegate:
virtual void Initialize(ApplicationImpl* app) override {
+ shell_ = app->shell();
view_manager_client_factory_.reset(
- new ViewManagerClientFactory(app->shell(), this));
+ new ViewManagerClientFactory(shell_, this));
views_init_.reset(new ViewsInit);
app->ConnectToService("mojo:mojo_window_manager", &window_manager_);
}
@@ -193,7 +192,7 @@ class Browser : public ApplicationDelegate,
widget_ = new views::Widget;
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- params.native_widget = new NativeWidgetViewManager(widget_, view);
+ 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);
@@ -252,6 +251,8 @@ class Browser : public ApplicationDelegate,
root_ = NULL;
}
+ Shell* shell_;
+
scoped_ptr<ViewsInit> views_init_;
ViewManager* view_manager_;
diff --git a/mojo/examples/keyboard/keyboard.cc b/mojo/examples/keyboard/keyboard.cc
index 8eae684..3cd4a4e 100644
--- a/mojo/examples/keyboard/keyboard.cc
+++ b/mojo/examples/keyboard/keyboard.cc
@@ -51,7 +51,8 @@ class Keyboard : public ApplicationDelegate,
public KeyboardDelegate {
public:
Keyboard()
- : keyboard_service_factory_(this),
+ : shell_(nullptr),
+ keyboard_service_factory_(this),
view_manager_(NULL),
keyboard_service_(NULL),
target_(0) {}
@@ -68,8 +69,9 @@ class Keyboard : public ApplicationDelegate,
private:
// Overridden from ApplicationDelegate:
virtual void Initialize(ApplicationImpl* app) override {
+ shell_ = app->shell();
view_manager_client_factory_.reset(
- new ViewManagerClientFactory(app->shell(), this));
+ new ViewManagerClientFactory(shell_, this));
}
virtual bool ConfigureIncomingConnection(
@@ -88,7 +90,7 @@ class Keyboard : public ApplicationDelegate,
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- params.native_widget = new NativeWidgetViewManager(widget, view);
+ 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);
@@ -119,6 +121,8 @@ class Keyboard : public ApplicationDelegate,
event_flags);
}
+ Shell* shell_;
+
InterfaceFactoryImplWithContext<KeyboardServiceImpl, Keyboard>
keyboard_service_factory_;
diff --git a/mojo/examples/media_viewer/media_viewer.cc b/mojo/examples/media_viewer/media_viewer.cc
index 33cf200..9aece56 100644
--- a/mojo/examples/media_viewer/media_viewer.cc
+++ b/mojo/examples/media_viewer/media_viewer.cc
@@ -134,11 +134,12 @@ class ControlPanel : public views::ButtonListener {
virtual void ButtonPressed(ControlType type) = 0;
};
- ControlPanel(Delegate* delegate) : delegate_(delegate), buttons_() {}
+ explicit ControlPanel(Delegate* delegate)
+ : delegate_(delegate), shell_(nullptr), buttons_() {}
virtual ~ControlPanel() {}
- void Initialize(View* view) {
+ void Initialize(View* view, Shell* shell) {
const char* kNames[] = { "Zoom In", "Actual Size", "Zoom Out" };
views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView;
@@ -160,7 +161,7 @@ class ControlPanel : public views::ButtonListener {
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- params.native_widget = new NativeWidgetViewManager(widget, view);
+ params.native_widget = new NativeWidgetViewManager(widget, shell, view);
params.delegate = widget_delegate;
params.bounds = gfx::Rect(view->bounds().width(), view->bounds().height());
params.opacity = views::Widget::InitParams::OPAQUE_WINDOW;
@@ -181,6 +182,7 @@ class ControlPanel : public views::ButtonListener {
}
Delegate* delegate_;
+ Shell* shell_;
views::Button* buttons_[CONTROL_COUNT];
DISALLOW_COPY_AND_ASSIGN(ControlPanel);
@@ -193,7 +195,8 @@ class MediaViewer
public ViewObserver {
public:
MediaViewer()
- : app_(NULL),
+ : shell_(nullptr),
+ app_(NULL),
view_manager_(NULL),
root_view_(NULL),
control_view_(NULL),
@@ -213,6 +216,7 @@ class MediaViewer
// Overridden from ApplicationDelegate:
virtual void Initialize(ApplicationImpl* app) override {
+ shell_ = app->shell();
view_manager_client_factory_.reset(
new ViewManagerClientFactory(app->shell(), this));
app_ = app;
@@ -248,7 +252,7 @@ class MediaViewer
content_view_ = View::Create(view_manager_);
root_view_->AddChild(content_view_);
- control_panel_.Initialize(control_view_);
+ control_panel_.Initialize(control_view_, shell_);
LayoutViews();
root_view_->AddObserver(this);
@@ -297,6 +301,8 @@ class MediaViewer
return it != handler_map_.end() ? it->second : std::string();
}
+ Shell* shell_;
+
scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_;
ApplicationImpl* app_;
diff --git a/mojo/examples/window_manager/debug_panel.cc b/mojo/examples/window_manager/debug_panel.cc
index c65785c..7d86cfe 100644
--- a/mojo/examples/window_manager/debug_panel.cc
+++ b/mojo/examples/window_manager/debug_panel.cc
@@ -24,23 +24,27 @@ const int kNavigationTargetGroupId = 1;
} // namespace
-DebugPanel::DebugPanel(Delegate* delegate, View* view)
+DebugPanel::DebugPanel(Delegate* delegate, Shell* shell, View* view)
: delegate_(delegate),
view_(view),
- navigation_target_label_(new views::Label(
- base::ASCIIToUTF16("Navigation target:"))),
- navigation_target_new_(new views::RadioButton(
- base::ASCIIToUTF16("New window"), kNavigationTargetGroupId)),
- navigation_target_source_(new views::RadioButton(
- base::ASCIIToUTF16("Source window"), kNavigationTargetGroupId)),
- navigation_target_default_(new views::RadioButton(
- base::ASCIIToUTF16("Default"), kNavigationTargetGroupId)),
- colored_square_(new views::BlueButton(
- this, base::ASCIIToUTF16("Local nav test"))),
- close_last_(new views::BlueButton(
- this, base::ASCIIToUTF16("Close last window"))),
- cross_app_(new views::BlueButton(
- this, base::ASCIIToUTF16("Cross-app nav test"))) {
+ navigation_target_label_(
+ new views::Label(base::ASCIIToUTF16("Navigation target:"))),
+ navigation_target_new_(
+ new views::RadioButton(base::ASCIIToUTF16("New window"),
+ kNavigationTargetGroupId)),
+ navigation_target_source_(
+ new views::RadioButton(base::ASCIIToUTF16("Source window"),
+ kNavigationTargetGroupId)),
+ navigation_target_default_(
+ new views::RadioButton(base::ASCIIToUTF16("Default"),
+ kNavigationTargetGroupId)),
+ colored_square_(
+ new views::BlueButton(this, base::ASCIIToUTF16("Local nav test"))),
+ close_last_(
+ new views::BlueButton(this, base::ASCIIToUTF16("Close last window"))),
+ cross_app_(
+ new views::BlueButton(this,
+ base::ASCIIToUTF16("Cross-app nav test"))) {
navigation_target_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
navigation_target_default_->SetChecked(true);
@@ -59,7 +63,7 @@ DebugPanel::DebugPanel(Delegate* delegate, View* view)
views::Widget* widget = new views::Widget();
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- params.native_widget = new NativeWidgetViewManager(widget, view);
+ params.native_widget = new NativeWidgetViewManager(widget, shell, view);
params.delegate = widget_delegate;
params.bounds = gfx::Rect(view->bounds().size());
widget->Init(params);
diff --git a/mojo/examples/window_manager/debug_panel.h b/mojo/examples/window_manager/debug_panel.h
index 160e400..eec3067 100644
--- a/mojo/examples/window_manager/debug_panel.h
+++ b/mojo/examples/window_manager/debug_panel.h
@@ -20,13 +20,11 @@ class RadioButton;
namespace mojo {
+class Shell;
class View;
namespace examples {
-namespace {
-}
-
// A panel of controls intended to demonstrate the functionality of the window
// manager.
class DebugPanel : public views::LayoutManager, public views::ButtonListener {
@@ -42,7 +40,7 @@ class DebugPanel : public views::LayoutManager, public views::ButtonListener {
virtual ~Delegate(){}
};
- DebugPanel(Delegate* delegate, View* view);
+ DebugPanel(Delegate* delegate, Shell* shell, View* view);
virtual ~DebugPanel();
Target navigation_target() const;
@@ -57,6 +55,7 @@ class DebugPanel : public views::LayoutManager, public views::ButtonListener {
void Navigate(const std::string& url);
Delegate* delegate_;
+ Shell* shell_;
View* view_;
views::Label* navigation_target_label_;
diff --git a/mojo/examples/window_manager/window_manager.cc b/mojo/examples/window_manager/window_manager.cc
index 2cb5458..fbbf074 100644
--- a/mojo/examples/window_manager/window_manager.cc
+++ b/mojo/examples/window_manager/window_manager.cc
@@ -340,7 +340,8 @@ class WindowManager
public ui::EventHandler {
public:
WindowManager()
- : window_manager_factory_(this),
+ : shell_(nullptr),
+ window_manager_factory_(this),
launcher_ui_(NULL),
view_manager_(NULL),
window_manager_app_(new WindowManagerApp(this, this)),
@@ -408,6 +409,7 @@ class WindowManager
// Overridden from ApplicationDelegate:
virtual void Initialize(ApplicationImpl* app) override {
+ shell_ = app->shell();
app_ = app;
views_init_.reset(new ViewsInit);
window_manager_app_->Initialize(app);
@@ -558,7 +560,7 @@ class WindowManager
kTextfieldHeight);
view->SetBounds(bounds);
- debug_panel_ = new DebugPanel(this, view);
+ debug_panel_ = new DebugPanel(this, shell_, view);
return view->id();
}
@@ -573,6 +575,8 @@ class WindowManager
return windows_.end();
}
+ Shell* shell_;
+
InterfaceFactoryImplWithContext<WindowManagerConnection, WindowManager>
window_manager_factory_;
diff --git a/mojo/examples/wm_flow/wm/frame_controller.cc b/mojo/examples/wm_flow/wm/frame_controller.cc
index 7ed1dac..40ff041 100644
--- a/mojo/examples/wm_flow/wm/frame_controller.cc
+++ b/mojo/examples/wm_flow/wm/frame_controller.cc
@@ -95,6 +95,7 @@ class FrameController::FrameEventHandler : public ui::EventHandler {
// FrameController, public:
FrameController::FrameController(
+ mojo::Shell* shell,
mojo::View* view,
mojo::View** app_view,
aura::client::ActivationClient* activation_client,
@@ -117,7 +118,8 @@ FrameController::FrameController(
frame_view_->AddPreTargetHandler(frame_event_handler_.get());
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- params.native_widget = new mojo::NativeWidgetViewManager(widget_, view_);
+ params.native_widget =
+ new mojo::NativeWidgetViewManager(widget_, shell, view_);
params.bounds = gfx::Rect(view_->bounds().size());
widget_->Init(params);
widget_->SetContentsView(frame_view_);
diff --git a/mojo/examples/wm_flow/wm/frame_controller.h b/mojo/examples/wm_flow/wm/frame_controller.h
index 2c7d9e9..0add0a1 100644
--- a/mojo/examples/wm_flow/wm/frame_controller.h
+++ b/mojo/examples/wm_flow/wm/frame_controller.h
@@ -17,6 +17,7 @@ class ActivationClient;
namespace mojo {
class NativeWidgetViewManager;
+class Shell;
class View;
class WindowManagerApp;
}
@@ -31,7 +32,8 @@ class Widget;
// to any events targeted at it.
class FrameController : mojo::ViewObserver {
public:
- FrameController(mojo::View* view,
+ FrameController(mojo::Shell* shell,
+ mojo::View* view,
mojo::View** app_view,
aura::client::ActivationClient* activation_client,
mojo::WindowManagerApp* window_manager_app);
diff --git a/mojo/examples/wm_flow/wm/wm.cc b/mojo/examples/wm_flow/wm/wm.cc
index f2787fc..56d8b39 100644
--- a/mojo/examples/wm_flow/wm/wm.cc
+++ b/mojo/examples/wm_flow/wm/wm.cc
@@ -91,7 +91,8 @@ class SimpleWM : public mojo::ApplicationDelegate,
public mojo::ViewObserver {
public:
SimpleWM()
- : window_manager_app_(new mojo::WindowManagerApp(this, this)),
+ : shell_(nullptr),
+ window_manager_app_(new mojo::WindowManagerApp(this, this)),
view_manager_(NULL),
root_(NULL),
window_container_(NULL),
@@ -101,6 +102,7 @@ class SimpleWM : public mojo::ApplicationDelegate,
private:
// Overridden from mojo::ApplicationDelegate:
virtual void Initialize(mojo::ApplicationImpl* impl) override {
+ shell_ = impl->shell();
window_manager_app_->Initialize(impl);
}
virtual bool ConfigureIncomingConnection(
@@ -175,11 +177,13 @@ class SimpleWM : public mojo::ApplicationDelegate,
aura::client::ActivationClient* client = aura::client::GetActivationClient(
window_manager_app_->host()->window());
- new FrameController(frame_view, app_view, client,
- window_manager_app_.get());
+ new FrameController(
+ shell_, frame_view, app_view, client, window_manager_app_.get());
return frame_view;
}
+ mojo::Shell* shell_;
+
scoped_ptr<mojo::WindowManagerApp> window_manager_app_;
mojo::ViewManager* view_manager_;