OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/application/application_runner_chromium.h" | 5 #include "mojo/application/application_runner_chromium.h" |
6 #include "mojo/public/c/system/main.h" | 6 #include "mojo/public/c/system/main.h" |
7 #include "mojo/public/cpp/application/application_delegate.h" | 7 #include "mojo/public/cpp/application/application_delegate.h" |
8 #include "mojo/public/cpp/application/application_impl.h" | 8 #include "mojo/public/cpp/application/application_impl.h" |
9 #include "mojo/public/cpp/application/connect.h" | 9 #include "mojo/public/cpp/application/connect.h" |
10 #include "mojo/public/cpp/application/service_provider_impl.h" | 10 #include "mojo/public/cpp/application/service_provider_impl.h" |
11 #include "mojo/services/public/cpp/view_manager/view_manager.h" | 11 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
12 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 12 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
13 #include "mojo/services/public/cpp/view_manager/view_observer.h" | 13 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
14 #include "mojo/services/public/interfaces/input_events/input_events.mojom.h" | 14 #include "mojo/services/public/interfaces/input_events/input_events.mojom.h" |
15 #include "mojo/services/window_manager/window_manager_app.h" | 15 #include "mojo/services/window_manager/window_manager_app.h" |
16 #include "mojo/services/window_manager/window_manager_delegate.h" | 16 #include "mojo/services/window_manager/window_manager_delegate.h" |
17 #include "sky/tools/debugger/focus_rules.h" | 17 #include "sky/tools/debugger/focus_rules.h" |
18 #include "sky/tools/debugger/debugger.mojom.h" | 18 #include "sky/tools/debugger/debugger.mojom.h" |
| 19 #include "sky/viewer/services/inspector.mojom.h" |
19 | 20 |
20 namespace sky { | 21 namespace sky { |
21 | 22 |
22 class SkyDebugger : public mojo::ApplicationDelegate, | 23 class SkyDebugger : public mojo::ApplicationDelegate, |
23 public mojo::ViewManagerDelegate, | 24 public mojo::ViewManagerDelegate, |
24 public mojo::ViewObserver, | 25 public mojo::ViewObserver, |
25 public mojo::InterfaceFactory<Debugger>, | 26 public mojo::InterfaceFactory<Debugger>, |
26 public mojo::InterfaceImpl<Debugger> { | 27 public mojo::InterfaceImpl<Debugger> { |
27 public: | 28 public: |
28 SkyDebugger() | 29 SkyDebugger() |
(...skipping 22 matching lines...) Expand all Loading... |
51 window_manager_app_->ConfigureOutgoingConnection(connection); | 52 window_manager_app_->ConfigureOutgoingConnection(connection); |
52 connection->AddService(this); | 53 connection->AddService(this); |
53 return true; | 54 return true; |
54 } | 55 } |
55 | 56 |
56 // Overridden from mojo::ViewManagerDelegate: | 57 // Overridden from mojo::ViewManagerDelegate: |
57 virtual void OnEmbed( | 58 virtual void OnEmbed( |
58 mojo::ViewManager* view_manager, | 59 mojo::ViewManager* view_manager, |
59 mojo::View* root, | 60 mojo::View* root, |
60 mojo::ServiceProviderImpl* exported_services, | 61 mojo::ServiceProviderImpl* exported_services, |
61 scoped_ptr<mojo::ServiceProvider> remote_service_provider) override { | 62 scoped_ptr<mojo::ServiceProvider> imported_services) override { |
62 view_manager_ = view_manager; | 63 view_manager_ = view_manager; |
63 | 64 |
64 root_ = root; | 65 root_ = root; |
65 root_->AddObserver(this); | 66 root_->AddObserver(this); |
66 | 67 |
67 content_ = mojo::View::Create(view_manager_); | 68 content_ = mojo::View::Create(view_manager_); |
68 content_->SetBounds(root_->bounds()); | 69 content_->SetBounds(root_->bounds()); |
69 root_->AddChild(content_); | 70 root_->AddChild(content_); |
70 | 71 |
71 window_manager_app_->InitFocus( | 72 window_manager_app_->InitFocus( |
(...skipping 25 matching lines...) Expand all Loading... |
97 virtual void Create(mojo::ApplicationConnection* connection, | 98 virtual void Create(mojo::ApplicationConnection* connection, |
98 mojo::InterfaceRequest<Debugger> request) override { | 99 mojo::InterfaceRequest<Debugger> request) override { |
99 mojo::WeakBindToRequest(this, &request); | 100 mojo::WeakBindToRequest(this, &request); |
100 } | 101 } |
101 | 102 |
102 // Overridden from Debugger | 103 // Overridden from Debugger |
103 virtual void NavigateToURL(const mojo::String& url) override { | 104 virtual void NavigateToURL(const mojo::String& url) override { |
104 // We can get Navigate commands before we've actually been | 105 // We can get Navigate commands before we've actually been |
105 // embedded into the view and content_ created. | 106 // embedded into the view and content_ created. |
106 // Just save the last one. | 107 // Just save the last one. |
107 if (content_) | 108 if (content_) { |
108 content_->Embed(url); | 109 scoped_ptr<mojo::ServiceProviderImpl> exported_services( |
109 else | 110 new mojo::ServiceProviderImpl()); |
| 111 viewer_services_ = content_->Embed(url, exported_services.Pass()); |
| 112 } else { |
110 pending_url_ = url; | 113 pending_url_ = url; |
| 114 } |
| 115 } |
| 116 |
| 117 virtual void InjectInspector() override { |
| 118 InspectorServicePtr inspector_service; |
| 119 mojo::ConnectToService(viewer_services_.get(), &inspector_service); |
| 120 inspector_service->Inject(); |
111 } | 121 } |
112 | 122 |
113 scoped_ptr<mojo::WindowManagerApp> window_manager_app_; | 123 scoped_ptr<mojo::WindowManagerApp> window_manager_app_; |
114 | 124 |
115 mojo::ViewManager* view_manager_; | 125 mojo::ViewManager* view_manager_; |
116 mojo::View* root_; | 126 mojo::View* root_; |
117 mojo::View* content_; | 127 mojo::View* content_; |
118 std::string pending_url_; | 128 std::string pending_url_; |
119 | 129 |
| 130 scoped_ptr<mojo::ServiceProvider> viewer_services_; |
| 131 |
120 DISALLOW_COPY_AND_ASSIGN(SkyDebugger); | 132 DISALLOW_COPY_AND_ASSIGN(SkyDebugger); |
121 }; | 133 }; |
122 | 134 |
123 } // namespace sky | 135 } // namespace sky |
124 | 136 |
125 MojoResult MojoMain(MojoHandle shell_handle) { | 137 MojoResult MojoMain(MojoHandle shell_handle) { |
126 mojo::ApplicationRunnerChromium runner(new sky::SkyDebugger); | 138 mojo::ApplicationRunnerChromium runner(new sky::SkyDebugger); |
127 return runner.Run(shell_handle); | 139 return runner.Run(shell_handle); |
128 } | 140 } |
OLD | NEW |