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

Unified Diff: mojo/apps/js/application_delegate_impl.h

Issue 467263006: JavaScript Content Handler Version 0.0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/application_delegate_impl.h
diff --git a/mojo/apps/js/application_delegate_impl.h b/mojo/apps/js/application_delegate_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..7c9ec29b34de00eb432b89373b368bad431ee203
--- /dev/null
+++ b/mojo/apps/js/application_delegate_impl.h
@@ -0,0 +1,72 @@
+// 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.
+
+#ifndef MOJO_APPS_JS_CONTENT_HANDLER_H_
+#define MOJO_APPS_JS_CONTENT_HANDLER_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_vector.h"
+#include "mojo/public/cpp/application/application_delegate.h"
+#include "mojo/public/cpp/application/interface_factory_impl.h"
+#include "mojo/services/public/interfaces/content_handler/content_handler.mojom.h"
+
+namespace mojo {
+
+class ApplcationImpl;
+
+namespace apps {
+
+class ApplicationDelegateImpl;
+class JSApp;
+
+// Starts a new JSApp for each OnConnect call().
+
+class ContentHandlerImpl : public InterfaceImpl<ContentHandler> {
+ public:
+ ContentHandlerImpl(ApplicationDelegateImpl* content_handler);
+ virtual ~ContentHandlerImpl();
+
+ private:
+ virtual void OnConnect(const mojo::String& url,
+ URLResponsePtr content,
+ InterfaceRequest<ServiceProvider> service_provider)
+ MOJO_OVERRIDE;
+
+ ApplicationDelegateImpl* content_handler_;
+};
+
+// Manages the JSApps started by this content handler. This class owns the one
+// reference to the Mojo shell. JSApps post a task to the content handler's
+// thread to connect to a service or to quit.l
+
+class ApplicationDelegateImpl : public ApplicationDelegate {
+ public:
+ ApplicationDelegateImpl();
+ virtual ~ApplicationDelegateImpl();
+
+ void StartJSApp(const std::string& url, URLResponsePtr content);
+ void QuitJSApp(JSApp* app);
+
+ void ConnectToService(ScopedMessagePipeHandle pipe_handle,
+ const std::string& application_url,
+ const std::string& interface_name);
+
+ private:
+ typedef ScopedVector<JSApp> AppVector;
+
+ // ApplicationDelegate methods
+ virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE;
+ virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
+ MOJO_OVERRIDE;
+
+ ApplicationImpl* application_impl_;
+ InterfaceFactoryImplWithContext<ContentHandlerImpl, ApplicationDelegateImpl>
+ content_handler_factory_;
+ AppVector app_vector_;
+};
+
+} // namespace apps
+} // namespace mojo
+
+#endif // MOJO_APPS_JS_CONTENT_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698