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

Side by Side Diff: mojo/services/window_manager/main.cc

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 years, 8 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/memory/scoped_ptr.h"
6 #include "mojo/application/application_runner_chromium.h"
7 #include "mojo/common/tracing_impl.h"
8 #include "mojo/public/c/system/main.h"
9 #include "mojo/public/cpp/application/application_delegate.h"
10 #include "mojo/public/cpp/application/service_provider_impl.h"
11 #include "mojo/services/window_manager/basic_focus_rules.h"
12 #include "mojo/services/window_manager/window_manager_app.h"
13 #include "mojo/services/window_manager/window_manager_delegate.h"
14 #include "third_party/mojo_services/src/view_manager/public/cpp/view_manager.h"
15 #include "third_party/mojo_services/src/view_manager/public/cpp/view_manager_del egate.h"
16
17 // ApplicationDelegate implementation file for WindowManager users (e.g.
18 // core window manager tests) that do not want to provide their own
19 // ApplicationDelegate::Create().
20
21 using mojo::View;
22 using mojo::ViewManager;
23
24 namespace window_manager {
25
26 class DefaultWindowManager : public mojo::ApplicationDelegate,
27 public mojo::ViewManagerDelegate,
28 public WindowManagerDelegate {
29 public:
30 DefaultWindowManager()
31 : window_manager_app_(new WindowManagerApp(this, this)),
32 root_(nullptr),
33 window_offset_(10) {
34 }
35 ~DefaultWindowManager() override {}
36
37 private:
38 // Overridden from mojo::ApplicationDelegate:
39 void Initialize(mojo::ApplicationImpl* impl) override {
40 window_manager_app_->Initialize(impl);
41 tracing_.Initialize(impl);
42 }
43 bool ConfigureIncomingConnection(
44 mojo::ApplicationConnection* connection) override {
45 window_manager_app_->ConfigureIncomingConnection(connection);
46 return true;
47 }
48
49 // Overridden from ViewManagerDelegate:
50 void OnEmbed(View* root,
51 mojo::InterfaceRequest<mojo::ServiceProvider> services,
52 mojo::ServiceProviderPtr exposed_services) override {
53 root_ = root;
54 window_manager_app_->InitFocus(
55 make_scoped_ptr(new window_manager::BasicFocusRules(root_)));
56 }
57 void OnViewManagerDisconnected(ViewManager* view_manager) override {}
58
59 // Overridden from WindowManagerDelegate:
60 void Embed(const mojo::String& url,
61 mojo::InterfaceRequest<mojo::ServiceProvider> services,
62 mojo::ServiceProviderPtr exposed_services) override {
63 DCHECK(root_);
64 View* view = root_->view_manager()->CreateView();
65 root_->AddChild(view);
66
67 mojo::Rect rect;
68 rect.x = rect.y = window_offset_;
69 rect.width = rect.height = 100;
70 view->SetBounds(rect);
71 window_offset_ += 10;
72
73 view->SetVisible(true);
74 view->Embed(url, services.Pass(), exposed_services.Pass());
75 }
76
77 scoped_ptr<WindowManagerApp> window_manager_app_;
78
79 View* root_;
80 int window_offset_;
81 mojo::TracingImpl tracing_;
82
83 MOJO_DISALLOW_COPY_AND_ASSIGN(DefaultWindowManager);
84 };
85
86 } // namespace window_manager
87
88 MojoResult MojoMain(MojoHandle shell_handle) {
89 mojo::ApplicationRunnerChromium runner(
90 new window_manager::DefaultWindowManager);
91 return runner.Run(shell_handle);
92 }
OLDNEW
« no previous file with comments | « mojo/services/window_manager/hit_test.h ('k') | mojo/services/window_manager/native_viewport_event_dispatcher_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698