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

Side by Side Diff: mojo/examples/wm_flow/wm/wm.cc

Issue 617503003: Mojo: MOJO_OVERRIDE -> override in mojo/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years, 2 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
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 <vector> 5 #include <vector>
6 6
7 #include "mojo/application/application_runner_chromium.h" 7 #include "mojo/application/application_runner_chromium.h"
8 #include "mojo/examples/wm_flow/wm/frame_controller.h" 8 #include "mojo/examples/wm_flow/wm/frame_controller.h"
9 #include "mojo/public/c/system/main.h" 9 #include "mojo/public/c/system/main.h"
10 #include "mojo/public/cpp/application/application_delegate.h" 10 #include "mojo/public/cpp/application/application_delegate.h"
(...skipping 17 matching lines...) Expand all
28 class WMFocusRules : public wm::FocusRules { 28 class WMFocusRules : public wm::FocusRules {
29 public: 29 public:
30 WMFocusRules(mojo::WindowManagerApp* window_manager_app, 30 WMFocusRules(mojo::WindowManagerApp* window_manager_app,
31 mojo::View* window_container) 31 mojo::View* window_container)
32 : window_container_(window_container), 32 : window_container_(window_container),
33 window_manager_app_(window_manager_app) {} 33 window_manager_app_(window_manager_app) {}
34 virtual ~WMFocusRules() {} 34 virtual ~WMFocusRules() {}
35 35
36 private: 36 private:
37 // Overridden from wm::FocusRules: 37 // Overridden from wm::FocusRules:
38 virtual bool IsToplevelWindow(aura::Window* window) const MOJO_OVERRIDE { 38 virtual bool IsToplevelWindow(aura::Window* window) const override {
39 return mojo::WindowManagerApp::GetViewForWindow(window)->parent() == 39 return mojo::WindowManagerApp::GetViewForWindow(window)->parent() ==
40 window_container_; 40 window_container_;
41 } 41 }
42 virtual bool CanActivateWindow(aura::Window* window) const MOJO_OVERRIDE { 42 virtual bool CanActivateWindow(aura::Window* window) const override {
43 return mojo::WindowManagerApp::GetViewForWindow(window)->parent() == 43 return mojo::WindowManagerApp::GetViewForWindow(window)->parent() ==
44 window_container_; 44 window_container_;
45 } 45 }
46 virtual bool CanFocusWindow(aura::Window* window) const MOJO_OVERRIDE { 46 virtual bool CanFocusWindow(aura::Window* window) const override {
47 return true; 47 return true;
48 } 48 }
49 virtual aura::Window* GetToplevelWindow( 49 virtual aura::Window* GetToplevelWindow(aura::Window* window) const override {
50 aura::Window* window) const MOJO_OVERRIDE {
51 mojo::View* view = mojo::WindowManagerApp::GetViewForWindow(window); 50 mojo::View* view = mojo::WindowManagerApp::GetViewForWindow(window);
52 while (view->parent() != window_container_) { 51 while (view->parent() != window_container_) {
53 view = view->parent(); 52 view = view->parent();
54 // Unparented hierarchy, there is no "top level" window. 53 // Unparented hierarchy, there is no "top level" window.
55 if (!view) 54 if (!view)
56 return NULL; 55 return NULL;
57 } 56 }
58 57
59 return window_manager_app_->GetWindowForViewId(view->id()); 58 return window_manager_app_->GetWindowForViewId(view->id());
60 } 59 }
61 virtual aura::Window* GetActivatableWindow( 60 virtual aura::Window* GetActivatableWindow(
62 aura::Window* window) const MOJO_OVERRIDE { 61 aura::Window* window) const override {
63 return GetToplevelWindow(window); 62 return GetToplevelWindow(window);
64 } 63 }
65 virtual aura::Window* GetFocusableWindow( 64 virtual aura::Window* GetFocusableWindow(
66 aura::Window* window) const MOJO_OVERRIDE { 65 aura::Window* window) const override {
67 return window; 66 return window;
68 } 67 }
69 virtual aura::Window* GetNextActivatableWindow( 68 virtual aura::Window* GetNextActivatableWindow(
70 aura::Window* ignore) const MOJO_OVERRIDE { 69 aura::Window* ignore) const override {
71 aura::Window* activatable = GetActivatableWindow(ignore); 70 aura::Window* activatable = GetActivatableWindow(ignore);
72 const aura::Window::Windows& children = activatable->parent()->children(); 71 const aura::Window::Windows& children = activatable->parent()->children();
73 for (aura::Window::Windows::const_reverse_iterator it = children.rbegin(); 72 for (aura::Window::Windows::const_reverse_iterator it = children.rbegin();
74 it != children.rend(); ++it) { 73 it != children.rend(); ++it) {
75 if (*it != ignore) 74 if (*it != ignore)
76 return *it; 75 return *it;
77 } 76 }
78 return NULL; 77 return NULL;
79 } 78 }
80 79
(...skipping 13 matching lines...) Expand all
94 SimpleWM() 93 SimpleWM()
95 : window_manager_app_(new mojo::WindowManagerApp(this, this)), 94 : window_manager_app_(new mojo::WindowManagerApp(this, this)),
96 view_manager_(NULL), 95 view_manager_(NULL),
97 root_(NULL), 96 root_(NULL),
98 window_container_(NULL), 97 window_container_(NULL),
99 next_window_origin_(10, 10) {} 98 next_window_origin_(10, 10) {}
100 virtual ~SimpleWM() {} 99 virtual ~SimpleWM() {}
101 100
102 private: 101 private:
103 // Overridden from mojo::ApplicationDelegate: 102 // Overridden from mojo::ApplicationDelegate:
104 virtual void Initialize(mojo::ApplicationImpl* impl) MOJO_OVERRIDE { 103 virtual void Initialize(mojo::ApplicationImpl* impl) override {
105 window_manager_app_->Initialize(impl); 104 window_manager_app_->Initialize(impl);
106 } 105 }
107 virtual bool ConfigureIncomingConnection( 106 virtual bool ConfigureIncomingConnection(
108 mojo::ApplicationConnection* connection) MOJO_OVERRIDE { 107 mojo::ApplicationConnection* connection) override {
109 window_manager_app_->ConfigureIncomingConnection(connection); 108 window_manager_app_->ConfigureIncomingConnection(connection);
110 return true; 109 return true;
111 } 110 }
112 111
113 // Overridden from mojo::ViewManagerDelegate: 112 // Overridden from mojo::ViewManagerDelegate:
114 virtual void OnEmbed( 113 virtual void OnEmbed(
115 mojo::ViewManager* view_manager, 114 mojo::ViewManager* view_manager,
116 mojo::View* root, 115 mojo::View* root,
117 mojo::ServiceProviderImpl* exported_services, 116 mojo::ServiceProviderImpl* exported_services,
118 scoped_ptr<mojo::ServiceProvider> remote_service_provider) MOJO_OVERRIDE { 117 scoped_ptr<mojo::ServiceProvider> remote_service_provider) override {
119 view_manager_ = view_manager; 118 view_manager_ = view_manager;
120 root_ = root; 119 root_ = root;
121 120
122 window_container_ = mojo::View::Create(view_manager_); 121 window_container_ = mojo::View::Create(view_manager_);
123 window_container_->SetBounds(root_->bounds()); 122 window_container_->SetBounds(root_->bounds());
124 root_->AddChild(window_container_); 123 root_->AddChild(window_container_);
125 124
126 window_manager_app_->InitFocus(new WMFocusRules(window_manager_app_.get(), 125 window_manager_app_->InitFocus(new WMFocusRules(window_manager_app_.get(),
127 window_container_)); 126 window_container_));
128 } 127 }
129 virtual void OnViewManagerDisconnected( 128 virtual void OnViewManagerDisconnected(
130 mojo::ViewManager* view_manager) MOJO_OVERRIDE { 129 mojo::ViewManager* view_manager) override {
131 view_manager_ = NULL; 130 view_manager_ = NULL;
132 root_ = NULL; 131 root_ = NULL;
133 } 132 }
134 133
135 // Overridden from mojo::WindowManagerDelegate: 134 // Overridden from mojo::WindowManagerDelegate:
136 virtual void Embed( 135 virtual void Embed(
137 const mojo::String& url, 136 const mojo::String& url,
138 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) 137 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) override {
139 MOJO_OVERRIDE {
140 mojo::View* app_view = NULL; 138 mojo::View* app_view = NULL;
141 mojo::View* frame_view = CreateTopLevelWindow(&app_view); 139 mojo::View* frame_view = CreateTopLevelWindow(&app_view);
142 window_container_->AddChild(frame_view); 140 window_container_->AddChild(frame_view);
143 141
144 // TODO(beng): We're dropping the |service_provider| passed from the client 142 // TODO(beng): We're dropping the |service_provider| passed from the client
145 // on the floor here and passing our own. Seems like we should 143 // on the floor here and passing our own. Seems like we should
146 // be sending both. I'm not yet sure how this sould work for 144 // be sending both. I'm not yet sure how this sould work for
147 // N levels of proxying. 145 // N levels of proxying.
148 app_view->Embed(url, scoped_ptr<mojo::ServiceProviderImpl>( 146 app_view->Embed(url, scoped_ptr<mojo::ServiceProviderImpl>(
149 new mojo::ServiceProviderImpl).Pass()); 147 new mojo::ServiceProviderImpl).Pass());
150 } 148 }
151 virtual void DispatchEvent(mojo::EventPtr event) MOJO_OVERRIDE {} 149 virtual void DispatchEvent(mojo::EventPtr event) override {}
152 150
153 // Overridden from mojo::ViewObserver: 151 // Overridden from mojo::ViewObserver:
154 virtual void OnViewInputEvent(mojo::View* view, 152 virtual void OnViewInputEvent(mojo::View* view,
155 const mojo::EventPtr& event) MOJO_OVERRIDE { 153 const mojo::EventPtr& event) override {
156 if (event->action == mojo::EVENT_TYPE_MOUSE_RELEASED && 154 if (event->action == mojo::EVENT_TYPE_MOUSE_RELEASED &&
157 event->flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON && 155 event->flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON &&
158 view->parent() == window_container_) { 156 view->parent() == window_container_) {
159 CloseWindow(view); 157 CloseWindow(view);
160 } 158 }
161 } 159 }
162 virtual void OnViewDestroyed(mojo::View* view) MOJO_OVERRIDE { 160 virtual void OnViewDestroyed(mojo::View* view) override {
163 view->RemoveObserver(this); 161 view->RemoveObserver(this);
164 } 162 }
165 163
166 void CloseWindow(mojo::View* view) { 164 void CloseWindow(mojo::View* view) {
167 mojo::View* first_child = view->children().front(); 165 mojo::View* first_child = view->children().front();
168 first_child->Destroy(); 166 first_child->Destroy();
169 view->Destroy(); 167 view->Destroy();
170 next_window_origin_.Offset(-50, -50); 168 next_window_origin_.Offset(-50, -50);
171 } 169 }
172 170
(...skipping 20 matching lines...) Expand all
193 DISALLOW_COPY_AND_ASSIGN(SimpleWM); 191 DISALLOW_COPY_AND_ASSIGN(SimpleWM);
194 }; 192 };
195 193
196 } // namespace examples 194 } // namespace examples
197 195
198 MojoResult MojoMain(MojoHandle shell_handle) { 196 MojoResult MojoMain(MojoHandle shell_handle) {
199 mojo::ViewsInit views_init; 197 mojo::ViewsInit views_init;
200 mojo::ApplicationRunnerChromium runner(new examples::SimpleWM); 198 mojo::ApplicationRunnerChromium runner(new examples::SimpleWM);
201 return runner.Run(shell_handle); 199 return runner.Run(shell_handle);
202 } 200 }
OLDNEW
« no previous file with comments | « mojo/examples/wm_flow/wm/frame_controller.h ('k') | mojo/public/c/system/tests/core_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698