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

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

Issue 331323007: Eliminate Launchable. Use Navigator instead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 6 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/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "mojo/examples/window_manager/window_manager.mojom.h" 8 #include "mojo/examples/window_manager/window_manager.mojom.h"
9 #include "mojo/public/cpp/application/application.h" 9 #include "mojo/public/cpp/application/application.h"
10 #include "mojo/services/navigation/navigation.mojom.h" 10 #include "mojo/services/navigation/navigation.mojom.h"
(...skipping 27 matching lines...) Expand all
38 public NodeObserver { 38 public NodeObserver {
39 public: 39 public:
40 NestingApp() : nested_(NULL) {} 40 NestingApp() : nested_(NULL) {}
41 virtual ~NestingApp() {} 41 virtual ~NestingApp() {}
42 42
43 private: 43 private:
44 class Navigator : public InterfaceImpl<navigation::Navigator> { 44 class Navigator : public InterfaceImpl<navigation::Navigator> {
45 public: 45 public:
46 explicit Navigator(NestingApp* app) : app_(app) {} 46 explicit Navigator(NestingApp* app) : app_(app) {}
47 private: 47 private:
48 virtual void Navigate(uint32 node_id, 48 virtual void Navigate(
49 navigation::NavigationDetailsPtr details) OVERRIDE { 49 uint32 node_id,
50 GURL url(details->url.To<std::string>()); 50 navigation::NavigationDetailsPtr navigation_details,
51 navigation::ResponseDetailsPtr response_details) OVERRIDE {
52 GURL url(navigation_details->url.To<std::string>());
51 if (!url.is_valid()) { 53 if (!url.is_valid()) {
52 LOG(ERROR) << "URL is invalid."; 54 LOG(ERROR) << "URL is invalid.";
53 return; 55 return;
54 } 56 }
55 app_->color_ = url.path().substr(1); 57 app_->color_ = url.path().substr(1);
56 app_->NavigateChild(); 58 app_->NavigateChild();
57 } 59 }
58 NestingApp* app_; 60 NestingApp* app_;
59 DISALLOW_COPY_AND_ASSIGN(Navigator); 61 DISALLOW_COPY_AND_ASSIGN(Navigator);
60 }; 62 };
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // TODO(beng): reap views & child nodes. 103 // TODO(beng): reap views & child nodes.
102 nested_ = NULL; 104 nested_ = NULL;
103 } 105 }
104 106
105 void NavigateChild() { 107 void NavigateChild() {
106 if (!color_.empty() && nested_) { 108 if (!color_.empty() && nested_) {
107 navigation::NavigationDetailsPtr details( 109 navigation::NavigationDetailsPtr details(
108 navigation::NavigationDetails::New()); 110 navigation::NavigationDetails::New());
109 details->url = 111 details->url =
110 base::StringPrintf("%s/%s", kEmbeddedAppURL, color_.c_str()); 112 base::StringPrintf("%s/%s", kEmbeddedAppURL, color_.c_str());
111 navigator_->Navigate(nested_->id(), details.Pass()); 113 navigation::ResponseDetailsPtr response_details(
114 navigation::ResponseDetails::New());
115 navigator_->Navigate(nested_->id(),
116 details.Pass(),
117 response_details.Pass());
112 } 118 }
113 } 119 }
114 120
115 std::string color_; 121 std::string color_;
116 Node* nested_; 122 Node* nested_;
117 navigation::NavigatorPtr navigator_; 123 navigation::NavigatorPtr navigator_;
118 IWindowManagerPtr window_manager_; 124 IWindowManagerPtr window_manager_;
119 125
120 DISALLOW_COPY_AND_ASSIGN(NestingApp); 126 DISALLOW_COPY_AND_ASSIGN(NestingApp);
121 }; 127 };
122 128
123 } // namespace examples 129 } // namespace examples
124 130
125 // static 131 // static
126 Application* Application::Create() { 132 Application* Application::Create() {
127 return new examples::NestingApp; 133 return new examples::NestingApp;
128 } 134 }
129 135
130 } // namespace mojo 136 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/examples/image_viewer/image_viewer.cc ('k') | mojo/examples/window_manager/window_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698