Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: services/ui/launcher/launch_instance.cc

Issue 2003003002: Update launcher API. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Follow review Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/launcher/launch_instance.h ('k') | services/ui/launcher/launcher.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/ui/launcher/launch_instance.h" 5 #include "services/ui/launcher/launch_instance.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
11 #include "mojo/application/application_runner_chromium.h" 11 #include "mojo/application/application_runner_chromium.h"
12 #include "mojo/public/c/system/main.h" 12 #include "mojo/public/c/system/main.h"
13 #include "mojo/public/cpp/application/application_impl.h" 13 #include "mojo/public/cpp/application/application_impl.h"
14 #include "mojo/public/cpp/application/connect.h" 14 #include "mojo/public/cpp/application/connect.h"
15 #include "mojo/services/ui/views/interfaces/view_provider.mojom.h"
16 #include "services/ui/launcher/launcher_view_tree.h" 15 #include "services/ui/launcher/launcher_view_tree.h"
17 16
18 namespace launcher { 17 namespace launcher {
19 18
20 LaunchInstance::LaunchInstance(mojo::ApplicationImpl* app_impl, 19 LaunchInstance::LaunchInstance(mojo::ApplicationImpl* app_impl,
21 const std::string& app_url, 20 mojo::NativeViewportPtr viewport,
21 mojo::ui::ViewProviderPtr view_provider,
22 mojo::gfx::composition::Compositor* compositor, 22 mojo::gfx::composition::Compositor* compositor,
23 mojo::ui::ViewManager* view_manager, 23 mojo::ui::ViewManager* view_manager,
24 const base::Closure& shutdown_callback) 24 const base::Closure& shutdown_callback)
25 : app_impl_(app_impl), 25 : app_impl_(app_impl),
26 app_url_(app_url), 26 viewport_(viewport.Pass()),
27 view_provider_(view_provider.Pass()),
27 compositor_(compositor), 28 compositor_(compositor),
28 view_manager_(view_manager), 29 view_manager_(view_manager),
29 shutdown_callback_(shutdown_callback), 30 shutdown_callback_(shutdown_callback),
30 viewport_event_dispatcher_binding_(this) {} 31 viewport_event_dispatcher_binding_(this) {}
31 32
32 LaunchInstance::~LaunchInstance() {} 33 LaunchInstance::~LaunchInstance() {}
33 34
34 void LaunchInstance::Launch() { 35 void LaunchInstance::Launch() {
35 DVLOG(1) << "Launching " << app_url_;
36 TRACE_EVENT0("launcher", __func__); 36 TRACE_EVENT0("launcher", __func__);
37 37
38 InitViewport(); 38 InitViewport();
39 39
40 mojo::ui::ViewProviderPtr client_view_provider; 40 view_provider_->CreateView(GetProxy(&client_view_owner_), nullptr);
41 mojo::ConnectToService(app_impl_->shell(), app_url_, 41 view_provider_.reset();
42 GetProxy(&client_view_provider));
43
44 client_view_provider->CreateView(GetProxy(&client_view_owner_), nullptr);
45 } 42 }
46 43
47 void LaunchInstance::InitViewport() { 44 void LaunchInstance::InitViewport() {
48 mojo::ConnectToService(app_impl_->shell(), "mojo:native_viewport_service",
49 GetProxy(&viewport_));
50 viewport_.set_connection_error_handler(base::Bind( 45 viewport_.set_connection_error_handler(base::Bind(
51 &LaunchInstance::OnViewportConnectionError, base::Unretained(this))); 46 &LaunchInstance::OnViewportConnectionError, base::Unretained(this)));
52 47
53 mojo::NativeViewportEventDispatcherPtr dispatcher; 48 mojo::NativeViewportEventDispatcherPtr dispatcher;
54 viewport_event_dispatcher_binding_.Bind(GetProxy(&dispatcher)); 49 viewport_event_dispatcher_binding_.Bind(GetProxy(&dispatcher));
55 viewport_->SetEventDispatcher(dispatcher.Pass()); 50 viewport_->SetEventDispatcher(dispatcher.Pass());
56 51
57 // Match the Nexus 5 aspect ratio initially. 52 // Match the Nexus 5 aspect ratio initially.
58 auto size = mojo::Size::New(); 53 auto size = mojo::Size::New();
59 size->width = 320; 54 size->width = 320;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 93 }
99 94
100 void LaunchInstance::OnEvent(mojo::EventPtr event, 95 void LaunchInstance::OnEvent(mojo::EventPtr event,
101 const mojo::Callback<void()>& callback) { 96 const mojo::Callback<void()>& callback) {
102 if (view_tree_) 97 if (view_tree_)
103 view_tree_->DispatchEvent(event.Pass()); 98 view_tree_->DispatchEvent(event.Pass());
104 callback.Run(); 99 callback.Run();
105 } 100 }
106 101
107 } // namespace launcher 102 } // namespace launcher
OLDNEW
« no previous file with comments | « services/ui/launcher/launch_instance.h ('k') | services/ui/launcher/launcher.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698