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 "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/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/application/application_connection.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 view_manager_ = NULL; | 218 view_manager_ = NULL; |
219 base::MessageLoop::current()->Quit(); | 219 base::MessageLoop::current()->Quit(); |
220 } | 220 } |
221 | 221 |
222 // views::TextfieldController: | 222 // views::TextfieldController: |
223 virtual bool HandleKeyEvent(views::Textfield* sender, | 223 virtual bool HandleKeyEvent(views::Textfield* sender, |
224 const ui::KeyEvent& key_event) OVERRIDE { | 224 const ui::KeyEvent& key_event) OVERRIDE { |
225 if (key_event.key_code() == ui::VKEY_RETURN) { | 225 if (key_event.key_code() == ui::VKEY_RETURN) { |
226 GURL url(sender->text()); | 226 GURL url(sender->text()); |
227 printf("User entered this URL: %s\n", url.spec().c_str()); | 227 printf("User entered this URL: %s\n", url.spec().c_str()); |
228 navigation::NavigationDetailsPtr nav_details( | 228 NavigationDetailsPtr nav_details(NavigationDetails::New()); |
229 navigation::NavigationDetails::New()); | |
230 nav_details->url = String::From(url); | 229 nav_details->url = String::From(url); |
231 navigator_host_->RequestNavigate(view_manager_->GetRoots().front()->id(), | 230 navigator_host_->RequestNavigate(view_manager_->GetRoots().front()->id(), |
232 navigation::TARGET_NEW_NODE, | 231 TARGET_NEW_NODE, |
233 nav_details.Pass()); | 232 nav_details.Pass()); |
234 } | 233 } |
235 return false; | 234 return false; |
236 } | 235 } |
237 | 236 |
238 // NodeObserver: | 237 // NodeObserver: |
239 virtual void OnNodeFocusChanged(Node* gained_focus, | 238 virtual void OnNodeFocusChanged(Node* gained_focus, |
240 Node* lost_focus) OVERRIDE { | 239 Node* lost_focus) OVERRIDE { |
241 aura::client::FocusClient* focus_client = | 240 aura::client::FocusClient* focus_client = |
242 aura::client::GetFocusClient(widget_->GetNativeView()); | 241 aura::client::GetFocusClient(widget_->GetNativeView()); |
243 if (lost_focus == root_) | 242 if (lost_focus == root_) |
244 focus_client->FocusWindow(NULL); | 243 focus_client->FocusWindow(NULL); |
245 else if (gained_focus == root_) | 244 else if (gained_focus == root_) |
246 focus_client->FocusWindow(widget_->GetNativeView()); | 245 focus_client->FocusWindow(widget_->GetNativeView()); |
247 } | 246 } |
248 virtual void OnNodeDestroyed(Node* node) OVERRIDE { | 247 virtual void OnNodeDestroyed(Node* node) OVERRIDE { |
249 DCHECK_EQ(root_, node); | 248 DCHECK_EQ(root_, node); |
250 node->RemoveObserver(this); | 249 node->RemoveObserver(this); |
251 root_ = NULL; | 250 root_ = NULL; |
252 } | 251 } |
253 | 252 |
254 scoped_ptr<ViewsInit> views_init_; | 253 scoped_ptr<ViewsInit> views_init_; |
255 | 254 |
256 ViewManager* view_manager_; | 255 ViewManager* view_manager_; |
257 ViewManagerClientFactory view_manager_client_factory_; | 256 ViewManagerClientFactory view_manager_client_factory_; |
258 Node* root_; | 257 Node* root_; |
259 views::Widget* widget_; | 258 views::Widget* widget_; |
260 navigation::NavigatorHostPtr navigator_host_; | 259 NavigatorHostPtr navigator_host_; |
261 IWindowManagerPtr window_manager_; | 260 IWindowManagerPtr window_manager_; |
262 | 261 |
263 DISALLOW_COPY_AND_ASSIGN(Browser); | 262 DISALLOW_COPY_AND_ASSIGN(Browser); |
264 }; | 263 }; |
265 | 264 |
266 } // namespace examples | 265 } // namespace examples |
267 | 266 |
268 // static | 267 // static |
269 ApplicationDelegate* ApplicationDelegate::Create() { | 268 ApplicationDelegate* ApplicationDelegate::Create() { |
270 return new examples::Browser; | 269 return new examples::Browser; |
271 } | 270 } |
272 | 271 |
273 } // namespace mojo | 272 } // namespace mojo |
OLD | NEW |