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

Unified Diff: mojo/apps/js/js_content_handler_app.cc

Issue 467263006: JavaScript Content Handler Version 0.0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Working and relatively complete 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/apps/js/js_content_handler_app.cc
diff --git a/mojo/apps/js/js_content_handler_app.cc b/mojo/apps/js/js_content_handler_app.cc
new file mode 100644
index 0000000000000000000000000000000000000000..df26600284248aaa8faa4fbbc614934bea8698b4
--- /dev/null
+++ b/mojo/apps/js/js_content_handler_app.cc
@@ -0,0 +1,66 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/apps/js/js_app.h"
+#include "mojo/apps/js/js_content_handler_app.h"
+
+namespace mojo {
+namespace apps {
+
+JSContentHandlerApp::JSContentHandlerApp()
+ : applicationImpl_(NULL), content_handler_factory_(this) {
+}
+
+void JSContentHandlerApp::Initialize(ApplicationImpl* app) {
+ applicationImpl_ = app;
+}
+
+JSContentHandlerApp::~JSContentHandlerApp() {
+}
+
+bool JSContentHandlerApp::ConfigureIncomingConnection(
+ ApplicationConnection* connection) {
+ connection->AddService(&content_handler_factory_);
+ return true;
+}
+
+void JSContentHandlerApp::StartJSApp(
+ const std::string& url, URLResponsePtr content) {
+ JSApp* app = new JSApp(this, url, content.Pass());
+ apps_.push_back(app);
Aaron Boodman 2014/09/10 02:22:09 There does not seem to be any instance of JSConten
hansmuller 2014/09/11 00:26:17 At the moment the apps_ list entries defined the l
+ // TODO(hansmuller): deal with the Start() return value.
+ app->Start();
+}
+
+void JSContentHandlerApp::QuitJSApp(JSApp* app) {
+ Apps::iterator itr = std::find(apps_.begin(), apps_.end(), app);
+ if (itr != apps_.end())
+ apps_.erase(itr);
+}
+
+void JSContentHandlerApp::ConnectToService(ScopedMessagePipeHandle pipe_handle1,
Aaron Boodman 2014/09/10 02:22:09 Since there is only one pipe handle here, you don'
hansmuller 2014/09/11 00:26:17 That was just a reminder that the caller was holdi
+ const std::string& application_url, const std::string& interface_name)
+{
+ CHECK(applicationImpl_);
+ ServiceProvider *service_provider = applicationImpl_->ConnectToApplication(
Aaron Boodman 2014/09/10 02:22:09 Instead of saving the ptr to ApplicationImpl*, sav
hansmuller 2014/09/11 00:26:17 ApplicationImpl::ConnectToApplication() updates an
Aaron Boodman 2014/09/11 05:24:53 Huh. I'm not really sure. I guess this can be part
+ application_url)->GetServiceProvider();
+ service_provider->ConnectToService(interface_name, pipe_handle1.Pass());
+}
+
+JSContentHandlerImpl::JSContentHandlerImpl(JSContentHandlerApp* app)
+ : content_handler_app_(app) {
+}
+
+JSContentHandlerImpl::~JSContentHandlerImpl() {
+}
+
+void JSContentHandlerImpl::OnConnect(
+ const mojo::String& url,
+ URLResponsePtr content,
+ InterfaceRequest<ServiceProvider> service_provider) {
+ content_handler_app_->StartJSApp(url.To<std::string>(), content.Pass());
Aaron Boodman 2014/09/10 02:22:09 I'm not sure this is the right lifetime for these
Aaron Boodman 2014/09/11 05:24:53 We still need to figure this out. I suppose in can
+}
+
+} // namespace apps
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698