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

Side by Side Diff: mojo/examples/browser/browser.cc

Issue 514063003: Update view_manager and window_manager to make use of content handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@viewman2
Patch Set: git cl format Created 6 years, 3 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 | « mojo/examples/aura_demo/aura_demo.cc ('k') | mojo/examples/embedded_app/embedded_app.cc » ('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 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/strings/string_util.h" 6 #include "base/strings/string_util.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "mojo/common/common_type_converters.h" 8 #include "mojo/common/common_type_converters.h"
9 #include "mojo/examples/window_manager/window_manager.mojom.h" 9 #include "mojo/examples/window_manager/window_manager.mojom.h"
10 #include "mojo/public/c/system/main.h" 10 #include "mojo/public/c/system/main.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 // This is the basics of creating a views widget with a textfield. 149 // This is the basics of creating a views widget with a textfield.
150 // TODO: cleanup! 150 // TODO: cleanup!
151 class Browser : public ApplicationDelegate, 151 class Browser : public ApplicationDelegate,
152 public ViewManagerDelegate, 152 public ViewManagerDelegate,
153 public views::TextfieldController, 153 public views::TextfieldController,
154 public ViewObserver { 154 public ViewObserver {
155 public: 155 public:
156 Browser() 156 Browser()
157 : view_manager_(NULL), 157 : view_manager_(NULL),
158 view_manager_client_factory_(this),
159 root_(NULL), 158 root_(NULL),
160 widget_(NULL) {} 159 widget_(NULL) {}
161 160
162 virtual ~Browser() { 161 virtual ~Browser() {
163 if (root_) 162 if (root_)
164 root_->RemoveObserver(this); 163 root_->RemoveObserver(this);
165 } 164 }
166 165
167 private: 166 private:
168 // Overridden from ApplicationDelegate: 167 // Overridden from ApplicationDelegate:
169 virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { 168 virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE {
169 view_manager_client_factory_.reset(
170 new ViewManagerClientFactory(app->shell(), this));
170 views_init_.reset(new ViewsInit); 171 views_init_.reset(new ViewsInit);
171 app->ConnectToService("mojo:mojo_window_manager", &navigator_host_); 172 app->ConnectToService("mojo:mojo_window_manager", &navigator_host_);
172 app->ConnectToService("mojo:mojo_window_manager", &window_manager_); 173 app->ConnectToService("mojo:mojo_window_manager", &window_manager_);
173 } 174 }
174 175
175 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) 176 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
176 MOJO_OVERRIDE { 177 MOJO_OVERRIDE {
177 connection->AddService(&view_manager_client_factory_); 178 connection->AddService(view_manager_client_factory_.get());
178 return true; 179 return true;
179 } 180 }
180 181
181 void CreateWidget(View* view) { 182 void CreateWidget(View* view) {
182 views::Textfield* textfield = new views::Textfield; 183 views::Textfield* textfield = new views::Textfield;
183 textfield->set_controller(this); 184 textfield->set_controller(this);
184 185
185 views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView; 186 views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView;
186 widget_delegate->GetContentsView()->set_background( 187 widget_delegate->GetContentsView()->set_background(
187 views::Background::CreateSolidBackground(SK_ColorBLUE)); 188 views::Background::CreateSolidBackground(SK_ColorBLUE));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 249 }
249 virtual void OnViewDestroyed(View* view) OVERRIDE { 250 virtual void OnViewDestroyed(View* view) OVERRIDE {
250 DCHECK_EQ(root_, view); 251 DCHECK_EQ(root_, view);
251 view->RemoveObserver(this); 252 view->RemoveObserver(this);
252 root_ = NULL; 253 root_ = NULL;
253 } 254 }
254 255
255 scoped_ptr<ViewsInit> views_init_; 256 scoped_ptr<ViewsInit> views_init_;
256 257
257 ViewManager* view_manager_; 258 ViewManager* view_manager_;
258 ViewManagerClientFactory view_manager_client_factory_; 259 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_;
259 View* root_; 260 View* root_;
260 views::Widget* widget_; 261 views::Widget* widget_;
261 NavigatorHostPtr navigator_host_; 262 NavigatorHostPtr navigator_host_;
262 IWindowManagerPtr window_manager_; 263 IWindowManagerPtr window_manager_;
263 264
264 DISALLOW_COPY_AND_ASSIGN(Browser); 265 DISALLOW_COPY_AND_ASSIGN(Browser);
265 }; 266 };
266 267
267 } // namespace examples 268 } // namespace examples
268 } // namespace mojo 269 } // namespace mojo
269 270
270 MojoResult MojoMain(MojoHandle shell_handle) { 271 MojoResult MojoMain(MojoHandle shell_handle) {
271 mojo::ApplicationRunnerChromium runner(new mojo::examples::Browser); 272 mojo::ApplicationRunnerChromium runner(new mojo::examples::Browser);
272 return runner.Run(shell_handle); 273 return runner.Run(shell_handle);
273 } 274 }
OLDNEW
« no previous file with comments | « mojo/examples/aura_demo/aura_demo.cc ('k') | mojo/examples/embedded_app/embedded_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698