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