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

Unified Diff: mojo/examples/nesting_app/nesting_app.cc

Issue 514063003: Update view_manager and window_manager to make use of content handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@viewman2
Patch Set: rebase Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: mojo/examples/nesting_app/nesting_app.cc
diff --git a/mojo/examples/nesting_app/nesting_app.cc b/mojo/examples/nesting_app/nesting_app.cc
index d97bcd2c40a1e015c34b0090fcb699c48c893a4c..629e64bb9f6fcb46ab21e8a86b9026533bc0b5c8 100644
--- a/mojo/examples/nesting_app/nesting_app.cc
+++ b/mojo/examples/nesting_app/nesting_app.cc
@@ -10,6 +10,7 @@
#include "mojo/public/c/system/main.h"
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h"
+#include "mojo/public/cpp/application/application_impl.h"
#include "mojo/public/cpp/application/application_runner_chromium.h"
#include "mojo/public/cpp/application/interface_factory_impl.h"
#include "mojo/services/public/cpp/view_manager/view.h"
@@ -17,7 +18,6 @@
#include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h"
#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
#include "mojo/services/public/cpp/view_manager/view_observer.h"
-#include "mojo/services/public/interfaces/navigation/navigation.mojom.h"
#include "ui/events/event_constants.h"
#include "url/gurl.h"
@@ -30,20 +30,6 @@ const char kEmbeddedAppURL[] = "mojo:mojo_embedded_app";
class NestingApp;
-class NavigatorImpl : public InterfaceImpl<Navigator> {
- public:
- explicit NavigatorImpl(NestingApp* app) : app_(app) {}
-
- private:
- virtual void Navigate(
- uint32 node_id,
- NavigationDetailsPtr navigation_details,
- ResponseDetailsPtr response_details) OVERRIDE;
-
- NestingApp* app_;
- DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
-};
-
// An app that embeds another app.
// TODO(davemoore): Is this the right name?
class NestingApp
@@ -52,36 +38,21 @@ class NestingApp
public ViewObserver {
public:
NestingApp()
- : navigator_factory_(this),
- view_manager_client_factory_(this),
- nested_(NULL) {}
+ : nested_(NULL) {}
virtual ~NestingApp() {}
- void set_color(const std::string& color) { color_ = color; }
-
- void NavigateChild() {
- if (!color_.empty() && nested_) {
- NavigationDetailsPtr details(NavigationDetails::New());
- details->request->url =
- base::StringPrintf("%s/%s", kEmbeddedAppURL, color_.c_str());
- ResponseDetailsPtr response_details(ResponseDetails::New());
- navigator_->Navigate(
- nested_->id(), details.Pass(), response_details.Pass());
- }
+ private:
+ // Overridden from ApplicationDelegate:
+ virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE {
+ view_manager_client_factory_.reset(
+ new ViewManagerClientFactory(app->shell(), this));
}
- private:
// Overridden from ApplicationImpl:
virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
MOJO_OVERRIDE {
connection->ConnectToService(&window_manager_);
- connection->AddService(&view_manager_client_factory_);
- connection->AddService(&navigator_factory_);
- // TODO(davemoore): Is this ok?
- if (!navigator_) {
- connection->ConnectToApplication(
- kEmbeddedAppURL)->ConnectToService(&navigator_);
- }
+ connection->AddService(view_manager_client_factory_.get());
return true;
}
@@ -97,8 +68,6 @@ class NestingApp
root->AddChild(nested_);
nested_->SetBounds(gfx::Rect(20, 20, 50, 50));
nested_->Embed(kEmbeddedAppURL);
-
- NavigateChild();
}
virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE {
base::MessageLoop::current()->Quit();
@@ -114,29 +83,14 @@ class NestingApp
window_manager_->CloseWindow(view->id());
}
- InterfaceFactoryImplWithContext<NavigatorImpl, NestingApp> navigator_factory_;
- ViewManagerClientFactory view_manager_client_factory_;
+ scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_;
- std::string color_;
View* nested_;
- NavigatorPtr navigator_;
IWindowManagerPtr window_manager_;
DISALLOW_COPY_AND_ASSIGN(NestingApp);
};
-void NavigatorImpl::Navigate(uint32 node_id,
- NavigationDetailsPtr navigation_details,
- ResponseDetailsPtr response_details) {
- GURL url(navigation_details->request->url.To<std::string>());
- if (!url.is_valid()) {
- LOG(ERROR) << "URL is invalid.";
- return;
- }
- app_->set_color(url.path().substr(1));
- app_->NavigateChild();
-}
-
} // namespace examples
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698