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

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

Issue 413353002: Remove extraneous namespaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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/bind.h" 6 #include "base/bind.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "mojo/public/cpp/application/application_connection.h" 10 #include "mojo/public/cpp/application/application_connection.h"
(...skipping 17 matching lines...) Expand all
28 using mojo::view_manager::View; 28 using mojo::view_manager::View;
29 using mojo::view_manager::ViewManager; 29 using mojo::view_manager::ViewManager;
30 using mojo::view_manager::ViewManagerDelegate; 30 using mojo::view_manager::ViewManagerDelegate;
31 using mojo::view_manager::ViewManagerClientFactory; 31 using mojo::view_manager::ViewManagerClientFactory;
32 using mojo::view_manager::ViewObserver; 32 using mojo::view_manager::ViewObserver;
33 33
34 namespace mojo { 34 namespace mojo {
35 namespace examples { 35 namespace examples {
36 class EmbeddedApp; 36 class EmbeddedApp;
37 37
38 class Navigator : public InterfaceImpl<navigation::Navigator> { 38 class Navigator : public InterfaceImpl<mojo::Navigator> {
darin (slow to review) 2014/07/25 03:37:29 nit: this class should really be named NavigatorIm
39 public: 39 public:
40 explicit Navigator(EmbeddedApp* app) : app_(app) {} 40 explicit Navigator(EmbeddedApp* app) : app_(app) {}
41 41
42 private: 42 private:
43 virtual void Navigate( 43 virtual void Navigate(
44 uint32 node_id, 44 uint32 node_id,
45 navigation::NavigationDetailsPtr navigation_details, 45 NavigationDetailsPtr navigation_details,
46 navigation::ResponseDetailsPtr response_details) OVERRIDE; 46 ResponseDetailsPtr response_details) OVERRIDE;
47 47
48 EmbeddedApp* app_; 48 EmbeddedApp* app_;
49 DISALLOW_COPY_AND_ASSIGN(Navigator); 49 DISALLOW_COPY_AND_ASSIGN(Navigator);
50 }; 50 };
51 51
52 class EmbeddedApp : public ApplicationDelegate, 52 class EmbeddedApp : public ApplicationDelegate,
53 public ViewManagerDelegate, 53 public ViewManagerDelegate,
54 public ViewObserver, 54 public ViewObserver,
55 public NodeObserver, 55 public NodeObserver,
56 public InterfaceFactoryWithContext<Navigator, EmbeddedApp> { 56 public InterfaceFactoryWithContext<Navigator, EmbeddedApp> {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 ProcessPendingNodeColor(root->id()); 96 ProcessPendingNodeColor(root->id());
97 } 97 }
98 virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE { 98 virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE {
99 base::MessageLoop::current()->Quit(); 99 base::MessageLoop::current()->Quit();
100 } 100 }
101 101
102 // Overridden from ViewObserver: 102 // Overridden from ViewObserver:
103 virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE { 103 virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE {
104 if (event->action == EVENT_TYPE_MOUSE_RELEASED) { 104 if (event->action == EVENT_TYPE_MOUSE_RELEASED) {
105 if (event->flags & EVENT_FLAGS_LEFT_MOUSE_BUTTON) { 105 if (event->flags & EVENT_FLAGS_LEFT_MOUSE_BUTTON) {
106 navigation::NavigationDetailsPtr nav_details( 106 NavigationDetailsPtr nav_details(NavigationDetails::New());
107 navigation::NavigationDetails::New());
108 nav_details->url = "http://www.aaronboodman.com/z_dropbox/test.html"; 107 nav_details->url = "http://www.aaronboodman.com/z_dropbox/test.html";
109 navigator_host_->RequestNavigate(view->node()->id(), 108 navigator_host_->RequestNavigate(view->node()->id(),
110 navigation::TARGET_SOURCE_NODE, 109 TARGET_SOURCE_NODE,
111 nav_details.Pass()); 110 nav_details.Pass());
112 } 111 }
113 } 112 }
114 } 113 }
115 114
116 // Overridden from NodeObserver: 115 // Overridden from NodeObserver:
117 virtual void OnNodeActiveViewChanged(Node* node, 116 virtual void OnNodeActiveViewChanged(Node* node,
118 View* old_view, 117 View* old_view,
119 View* new_view) OVERRIDE { 118 View* new_view) OVERRIDE {
120 if (new_view == 0) 119 if (new_view == 0)
(...skipping 14 matching lines...) Expand all
135 134
136 PendingNodeColors::iterator color = pending_node_colors_.find(node_id); 135 PendingNodeColors::iterator color = pending_node_colors_.find(node_id);
137 if (color == pending_node_colors_.end()) 136 if (color == pending_node_colors_.end())
138 return; 137 return;
139 138
140 root->second->active_view()->SetColor(color->second); 139 root->second->active_view()->SetColor(color->second);
141 pending_node_colors_.erase(color); 140 pending_node_colors_.erase(color);
142 } 141 }
143 142
144 view_manager::ViewManager* view_manager_; 143 view_manager::ViewManager* view_manager_;
145 navigation::NavigatorHostPtr navigator_host_; 144 NavigatorHostPtr navigator_host_;
146 std::map<Node*, View*> views_to_reap_; 145 std::map<Node*, View*> views_to_reap_;
147 ViewManagerClientFactory view_manager_client_factory_; 146 ViewManagerClientFactory view_manager_client_factory_;
148 147
149 typedef std::map<view_manager::Id, Node*> RootMap; 148 typedef std::map<view_manager::Id, Node*> RootMap;
150 RootMap roots_; 149 RootMap roots_;
151 150
152 // We can receive navigations for nodes we don't have yet. 151 // We can receive navigations for nodes we don't have yet.
153 typedef std::map<uint32, SkColor> PendingNodeColors; 152 typedef std::map<uint32, SkColor> PendingNodeColors;
154 PendingNodeColors pending_node_colors_; 153 PendingNodeColors pending_node_colors_;
155 154
156 DISALLOW_COPY_AND_ASSIGN(EmbeddedApp); 155 DISALLOW_COPY_AND_ASSIGN(EmbeddedApp);
157 }; 156 };
158 157
159 void Navigator::Navigate(uint32 node_id, 158 void Navigator::Navigate(uint32 node_id,
160 navigation::NavigationDetailsPtr navigation_details, 159 NavigationDetailsPtr navigation_details,
161 navigation::ResponseDetailsPtr response_details) { 160 ResponseDetailsPtr response_details) {
162 GURL url(navigation_details->url.To<std::string>()); 161 GURL url(navigation_details->url.To<std::string>());
163 if (!url.is_valid()) { 162 if (!url.is_valid()) {
164 LOG(ERROR) << "URL is invalid."; 163 LOG(ERROR) << "URL is invalid.";
165 return; 164 return;
166 } 165 }
167 // TODO(aa): Verify new URL is same origin as current origin. 166 // TODO(aa): Verify new URL is same origin as current origin.
168 SkColor color = 0x00; 167 SkColor color = 0x00;
169 if (!base::HexStringToUInt(url.path().substr(1), &color)) { 168 if (!base::HexStringToUInt(url.path().substr(1), &color)) {
170 LOG(ERROR) << "Invalid URL, path not convertible to integer"; 169 LOG(ERROR) << "Invalid URL, path not convertible to integer";
171 return; 170 return;
172 } 171 }
173 app_->SetNodeColor(node_id, color); 172 app_->SetNodeColor(node_id, color);
174 } 173 }
175 174
176 } // namespace examples 175 } // namespace examples
177 176
178 // static 177 // static
179 ApplicationDelegate* ApplicationDelegate::Create() { 178 ApplicationDelegate* ApplicationDelegate::Create() {
180 return new examples::EmbeddedApp; 179 return new examples::EmbeddedApp;
181 } 180 }
182 181
183 } // namespace mojo 182 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698