| Index: sky/tools/debugger/debugger.cc
|
| diff --git a/sky/tools/debugger/debugger.cc b/sky/tools/debugger/debugger.cc
|
| index 82b0ea154f6d9d0c188006229cf73f46390f322e..a764ae59571c80c91cabd70c5865ccbdc5109406 100644
|
| --- a/sky/tools/debugger/debugger.cc
|
| +++ b/sky/tools/debugger/debugger.cc
|
| @@ -2,141 +2,110 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#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/connect.h"
|
| -#include "mojo/public/cpp/application/service_provider_impl.h"
|
| -#include "mojo/services/public/cpp/view_manager/view_manager.h"
|
| -#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
|
| -#include "mojo/services/public/cpp/view_manager/view_observer.h"
|
| -#include "mojo/services/public/interfaces/input_events/input_events.mojom.h"
|
| -#include "mojo/services/window_manager/window_manager_app.h"
|
| -#include "mojo/services/window_manager/window_manager_delegate.h"
|
| -#include "sky/tools/debugger/focus_rules.h"
|
| -#include "sky/tools/debugger/debugger.mojom.h"
|
| -#include "sky/viewer/services/inspector.mojom.h"
|
| +#include "sky/tools/debugger/debugger.h"
|
|
|
| namespace sky {
|
| +namespace debugger {
|
| +
|
| +SkyDebugger::SkyDebugger()
|
| + : window_manager_app_(new mojo::WindowManagerApp(this, nullptr)),
|
| + view_manager_(nullptr),
|
| + root_(nullptr),
|
| + content_(nullptr),
|
| + navigator_host_factory_(this),
|
| + weak_factory_(this) {
|
| +}
|
|
|
| -class SkyDebugger : public mojo::ApplicationDelegate,
|
| - public mojo::ViewManagerDelegate,
|
| - public mojo::ViewObserver,
|
| - public mojo::InterfaceFactory<Debugger>,
|
| - public mojo::InterfaceImpl<Debugger> {
|
| - public:
|
| - SkyDebugger()
|
| - : window_manager_app_(new mojo::WindowManagerApp(this, nullptr)),
|
| - view_manager_(nullptr),
|
| - root_(nullptr),
|
| - content_(nullptr) {}
|
| - virtual ~SkyDebugger() {}
|
| -
|
| - private:
|
| - // Overridden from mojo::ApplicationDelegate:
|
| - virtual void Initialize(mojo::ApplicationImpl* app) override {
|
| - window_manager_app_->Initialize(app);
|
| - app->ConnectToApplication("mojo:sky_debugger_prompt");
|
| - }
|
| -
|
| - virtual bool ConfigureIncomingConnection(
|
| - mojo::ApplicationConnection* connection) override {
|
| - window_manager_app_->ConfigureIncomingConnection(connection);
|
| - connection->AddService(this);
|
| - return true;
|
| - }
|
| -
|
| - virtual bool ConfigureOutgoingConnection(
|
| - mojo::ApplicationConnection* connection) override {
|
| - window_manager_app_->ConfigureOutgoingConnection(connection);
|
| - connection->AddService(this);
|
| - return true;
|
| - }
|
| +SkyDebugger::~SkyDebugger() {
|
| +}
|
|
|
| - // Overridden from mojo::ViewManagerDelegate:
|
| - virtual void OnEmbed(
|
| - mojo::ViewManager* view_manager,
|
| - mojo::View* root,
|
| - mojo::ServiceProviderImpl* exported_services,
|
| - scoped_ptr<mojo::ServiceProvider> imported_services) override {
|
| - view_manager_ = view_manager;
|
| +base::WeakPtr<SkyDebugger> SkyDebugger::GetWeakPtr() {
|
| + return weak_factory_.GetWeakPtr();
|
| +}
|
|
|
| - root_ = root;
|
| - root_->AddObserver(this);
|
| +void SkyDebugger::Initialize(mojo::ApplicationImpl* app) {
|
| + window_manager_app_->Initialize(app);
|
| + app->ConnectToApplication("mojo:sky_debugger_prompt");
|
| +}
|
|
|
| - window_manager_app_->SetViewportSize(gfx::Size(320, 640));
|
| +bool SkyDebugger::ConfigureIncomingConnection(
|
| + mojo::ApplicationConnection* connection) {
|
| + window_manager_app_->ConfigureIncomingConnection(connection);
|
| + connection->AddService(this);
|
| + return true;
|
| +}
|
|
|
| - content_ = mojo::View::Create(view_manager_);
|
| - content_->SetBounds(root_->bounds());
|
| - root_->AddChild(content_);
|
| +bool SkyDebugger::ConfigureOutgoingConnection(
|
| + mojo::ApplicationConnection* connection) {
|
| + window_manager_app_->ConfigureOutgoingConnection(connection);
|
| + connection->AddService(this);
|
| + return true;
|
| +}
|
|
|
| - window_manager_app_->InitFocus(
|
| - new FocusRules(window_manager_app_.get(), content_));
|
| +void SkyDebugger::OnEmbed(
|
| + mojo::ViewManager* view_manager,
|
| + mojo::View* root,
|
| + mojo::ServiceProviderImpl* exported_services,
|
| + scoped_ptr<mojo::ServiceProvider> imported_services) {
|
| + view_manager_ = view_manager;
|
|
|
| - if (!pending_url_.empty())
|
| - NavigateToURL(pending_url_);
|
| - }
|
| + root_ = root;
|
| + root_->AddObserver(this);
|
|
|
| - virtual void OnViewManagerDisconnected(
|
| - mojo::ViewManager* view_manager) override {
|
| - CHECK(false); // FIXME: This is dead code, why?
|
| - view_manager_ = nullptr;
|
| - root_ = nullptr;
|
| - }
|
| + window_manager_app_->SetViewportSize(gfx::Size(320, 640));
|
|
|
| - virtual void OnViewDestroyed(mojo::View* view) override {
|
| - CHECK(false); // FIXME: This is dead code, why?
|
| - view->RemoveObserver(this);
|
| - }
|
| + content_ = mojo::View::Create(view_manager_);
|
| + content_->SetBounds(root_->bounds());
|
| + root_->AddChild(content_);
|
|
|
| - virtual void OnViewBoundsChanged(mojo::View* view,
|
| - const mojo::Rect& old_bounds,
|
| - const mojo::Rect& new_bounds) override {
|
| - content_->SetBounds(new_bounds);
|
| - }
|
| + window_manager_app_->InitFocus(
|
| + new FocusRules(window_manager_app_.get(), content_));
|
|
|
| - // Overridden from InterfaceFactory<Debugger>
|
| - virtual void Create(mojo::ApplicationConnection* connection,
|
| - mojo::InterfaceRequest<Debugger> request) override {
|
| - mojo::WeakBindToRequest(this, &request);
|
| - }
|
| + if (!pending_url_.empty())
|
| + NavigateToURL(pending_url_);
|
| +}
|
|
|
| - // Overridden from Debugger
|
| - virtual void NavigateToURL(const mojo::String& url) override {
|
| - // We can get Navigate commands before we've actually been
|
| - // embedded into the view and content_ created.
|
| - // Just save the last one.
|
| - if (content_) {
|
| - scoped_ptr<mojo::ServiceProviderImpl> exported_services(
|
| - new mojo::ServiceProviderImpl());
|
| - viewer_services_ = content_->Embed(url, exported_services.Pass());
|
| - } else {
|
| - pending_url_ = url;
|
| - }
|
| - }
|
| +void SkyDebugger::OnViewManagerDisconnected(mojo::ViewManager* view_manager) {
|
| + CHECK(false); // FIXME: This is dead code, why?
|
| + view_manager_ = nullptr;
|
| + root_ = nullptr;
|
| +}
|
|
|
| - virtual void InjectInspector() override {
|
| - InspectorServicePtr inspector_service;
|
| - mojo::ConnectToService(viewer_services_.get(), &inspector_service);
|
| - inspector_service->Inject();
|
| - }
|
| +void SkyDebugger::OnViewDestroyed(mojo::View* view) {
|
| + CHECK(false); // FIXME: This is dead code, why?
|
| + view->RemoveObserver(this);
|
| +}
|
|
|
| - scoped_ptr<mojo::WindowManagerApp> window_manager_app_;
|
| +void SkyDebugger::OnViewBoundsChanged(mojo::View* view,
|
| + const mojo::Rect& old_bounds,
|
| + const mojo::Rect& new_bounds) {
|
| + content_->SetBounds(new_bounds);
|
| +}
|
|
|
| - mojo::ViewManager* view_manager_;
|
| - mojo::View* root_;
|
| - mojo::View* content_;
|
| - std::string pending_url_;
|
| +void SkyDebugger::Create(mojo::ApplicationConnection* connection,
|
| + mojo::InterfaceRequest<Debugger> request) {
|
| + mojo::WeakBindToRequest(this, &request);
|
| +}
|
|
|
| - scoped_ptr<mojo::ServiceProvider> viewer_services_;
|
| +void SkyDebugger::NavigateToURL(const mojo::String& url) {
|
| + // We can get Navigate commands before we've actually been
|
| + // embedded into the view and content_ created.
|
| + // Just save the last one.
|
| + if (content_) {
|
| + scoped_ptr<mojo::ServiceProviderImpl> exported_services(
|
| + new mojo::ServiceProviderImpl());
|
| + exported_services->AddService(&navigator_host_factory_);
|
| + viewer_services_ = content_->Embed(url, exported_services.Pass());
|
| + } else {
|
| + pending_url_ = url;
|
| + }
|
| +}
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(SkyDebugger);
|
| -};
|
| +void SkyDebugger::InjectInspector() {
|
| + InspectorServicePtr inspector_service;
|
| + mojo::ConnectToService(viewer_services_.get(), &inspector_service);
|
| + inspector_service->Inject();
|
| +}
|
|
|
| +} // namespace debugger
|
| } // namespace sky
|
| -
|
| -MojoResult MojoMain(MojoHandle shell_handle) {
|
| - mojo::ApplicationRunnerChromium runner(new sky::SkyDebugger);
|
| - return runner.Run(shell_handle);
|
| -}
|
|
|