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

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

Issue 413353002: Remove extraneous namespaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.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 20 matching lines...) Expand all
31 31
32 namespace mojo { 32 namespace mojo {
33 namespace examples { 33 namespace examples {
34 34
35 namespace { 35 namespace {
36 const char kEmbeddedAppURL[] = "mojo:mojo_embedded_app"; 36 const char kEmbeddedAppURL[] = "mojo:mojo_embedded_app";
37 } 37 }
38 38
39 class NestingApp; 39 class NestingApp;
40 40
41 class Navigator : public InterfaceImpl<navigation::Navigator> { 41 class Navigator : public InterfaceImpl<mojo::Navigator> {
darin (slow to review) 2014/07/25 03:37:29 nit: class NavigatorImpl
42 public: 42 public:
43 explicit Navigator(NestingApp* app) : app_(app) {} 43 explicit Navigator(NestingApp* app) : app_(app) {}
44 44
45 private: 45 private:
46 virtual void Navigate( 46 virtual void Navigate(
47 uint32 node_id, 47 uint32 node_id,
48 navigation::NavigationDetailsPtr navigation_details, 48 NavigationDetailsPtr navigation_details,
49 navigation::ResponseDetailsPtr response_details) OVERRIDE; 49 ResponseDetailsPtr response_details) OVERRIDE;
50 50
51 NestingApp* app_; 51 NestingApp* app_;
52 DISALLOW_COPY_AND_ASSIGN(Navigator); 52 DISALLOW_COPY_AND_ASSIGN(Navigator);
53 }; 53 };
54 54
55 // An app that embeds another app. 55 // An app that embeds another app.
56 // TODO(davemoore): Is this the right name? 56 // TODO(davemoore): Is this the right name?
57 class NestingApp : public ApplicationDelegate, 57 class NestingApp : public ApplicationDelegate,
58 public ViewManagerDelegate, 58 public ViewManagerDelegate,
59 public ViewObserver, 59 public ViewObserver,
60 public NodeObserver, 60 public NodeObserver,
61 public InterfaceFactoryWithContext<Navigator, NestingApp> { 61 public InterfaceFactoryWithContext<Navigator, NestingApp> {
62 public: 62 public:
63 NestingApp() 63 NestingApp()
64 : InterfaceFactoryWithContext(this), 64 : InterfaceFactoryWithContext(this),
65 nested_(NULL), 65 nested_(NULL),
66 view_manager_client_factory_(this) {} 66 view_manager_client_factory_(this) {}
67 virtual ~NestingApp() {} 67 virtual ~NestingApp() {}
68 68
69 void set_color(const std::string& color) { color_ = color; } 69 void set_color(const std::string& color) { color_ = color; }
70 70
71 void NavigateChild() { 71 void NavigateChild() {
72 if (!color_.empty() && nested_) { 72 if (!color_.empty() && nested_) {
73 navigation::NavigationDetailsPtr details( 73 NavigationDetailsPtr details(NavigationDetails::New());
74 navigation::NavigationDetails::New());
75 details->url = 74 details->url =
76 base::StringPrintf("%s/%s", kEmbeddedAppURL, color_.c_str()); 75 base::StringPrintf("%s/%s", kEmbeddedAppURL, color_.c_str());
77 navigation::ResponseDetailsPtr response_details( 76 ResponseDetailsPtr response_details(ResponseDetails::New());
78 navigation::ResponseDetails::New());
79 navigator_->Navigate( 77 navigator_->Navigate(
80 nested_->id(), details.Pass(), response_details.Pass()); 78 nested_->id(), details.Pass(), response_details.Pass());
81 } 79 }
82 } 80 }
83 81
84 private: 82 private:
85 // Overridden from ApplicationImpl: 83 // Overridden from ApplicationImpl:
86 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) 84 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
87 MOJO_OVERRIDE { 85 MOJO_OVERRIDE {
88 connection->ConnectToService(&window_manager_); 86 connection->ConnectToService(&window_manager_);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 121 }
124 122
125 // Overridden from NodeObserver: 123 // Overridden from NodeObserver:
126 virtual void OnNodeDestroyed(Node* node) OVERRIDE { 124 virtual void OnNodeDestroyed(Node* node) OVERRIDE {
127 // TODO(beng): reap views & child nodes. 125 // TODO(beng): reap views & child nodes.
128 nested_ = NULL; 126 nested_ = NULL;
129 } 127 }
130 128
131 std::string color_; 129 std::string color_;
132 Node* nested_; 130 Node* nested_;
133 navigation::NavigatorPtr navigator_; 131 NavigatorPtr navigator_;
134 IWindowManagerPtr window_manager_; 132 IWindowManagerPtr window_manager_;
135 ViewManagerClientFactory view_manager_client_factory_; 133 ViewManagerClientFactory view_manager_client_factory_;
136 134
137 DISALLOW_COPY_AND_ASSIGN(NestingApp); 135 DISALLOW_COPY_AND_ASSIGN(NestingApp);
138 }; 136 };
139 137
140 void Navigator::Navigate(uint32 node_id, 138 void Navigator::Navigate(uint32 node_id,
141 navigation::NavigationDetailsPtr navigation_details, 139 NavigationDetailsPtr navigation_details,
142 navigation::ResponseDetailsPtr response_details) { 140 ResponseDetailsPtr response_details) {
143 GURL url(navigation_details->url.To<std::string>()); 141 GURL url(navigation_details->url.To<std::string>());
144 if (!url.is_valid()) { 142 if (!url.is_valid()) {
145 LOG(ERROR) << "URL is invalid."; 143 LOG(ERROR) << "URL is invalid.";
146 return; 144 return;
147 } 145 }
148 app_->set_color(url.path().substr(1)); 146 app_->set_color(url.path().substr(1));
149 app_->NavigateChild(); 147 app_->NavigateChild();
150 } 148 }
151 149
152 } // namespace examples 150 } // namespace examples
153 151
154 // static 152 // static
155 ApplicationDelegate* ApplicationDelegate::Create() { 153 ApplicationDelegate* ApplicationDelegate::Create() {
156 return new examples::NestingApp; 154 return new examples::NestingApp;
157 } 155 }
158 156
159 } // namespace mojo 157 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698