| 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/public/cpp/application/application.h" | 8 #include "mojo/public/cpp/application/application.h" |
| 9 #include "mojo/services/navigation/navigation.mojom.h" | 9 #include "mojo/services/navigation/navigation.mojom.h" |
| 10 #include "mojo/services/public/cpp/view_manager/node.h" | 10 #include "mojo/services/public/cpp/view_manager/node.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 printf("User entered this URL: %s\n", url.spec().c_str()); | 104 printf("User entered this URL: %s\n", url.spec().c_str()); |
| 105 navigation::NavigationDetailsPtr nav_details( | 105 navigation::NavigationDetailsPtr nav_details( |
| 106 navigation::NavigationDetails::New()); | 106 navigation::NavigationDetails::New()); |
| 107 nav_details->url = url.spec(); | 107 nav_details->url = url.spec(); |
| 108 navigator_host_->RequestNavigate(view_manager_->GetRoots().front()->id(), | 108 navigator_host_->RequestNavigate(view_manager_->GetRoots().front()->id(), |
| 109 nav_details.Pass()); | 109 nav_details.Pass()); |
| 110 } | 110 } |
| 111 return false; | 111 return false; |
| 112 } | 112 } |
| 113 | 113 |
| 114 virtual void ContentsChanged(views::Textfield* sender, | |
| 115 const base::string16& new_contents) OVERRIDE { | |
| 116 // Ghetto workaround for crbug.com/386256. | |
| 117 if (EndsWith(new_contents, base::ASCIIToUTF16("]"), false)) { | |
| 118 sender->SetText(new_contents.substr(0, new_contents.size() - 1)); | |
| 119 HandleKeyEvent(sender, ui::KeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_RETURN, | |
| 120 0, false)); | |
| 121 } | |
| 122 } | |
| 123 | |
| 124 scoped_ptr<ViewsInit> views_init_; | 114 scoped_ptr<ViewsInit> views_init_; |
| 125 | 115 |
| 126 view_manager::ViewManager* view_manager_; | 116 view_manager::ViewManager* view_manager_; |
| 127 view_manager::View* view_; | 117 view_manager::View* view_; |
| 128 navigation::NavigatorHostPtr navigator_host_; | 118 navigation::NavigatorHostPtr navigator_host_; |
| 129 | 119 |
| 130 DISALLOW_COPY_AND_ASSIGN(Browser); | 120 DISALLOW_COPY_AND_ASSIGN(Browser); |
| 131 }; | 121 }; |
| 132 | 122 |
| 133 } // namespace examples | 123 } // namespace examples |
| 134 | 124 |
| 135 // static | 125 // static |
| 136 Application* Application::Create() { | 126 Application* Application::Create() { |
| 137 return new examples::Browser; | 127 return new examples::Browser; |
| 138 } | 128 } |
| 139 | 129 |
| 140 } // namespace mojo | 130 } // namespace mojo |
| OLD | NEW |