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

Side by Side Diff: mojo/apps/js/application_delegate_impl.cc

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mojo/apps/js/application_delegate_impl.h"
6
7 #include "mojo/apps/js/js_app.h"
8 #include "mojo/public/cpp/application/application_impl.h"
9
10 namespace mojo {
11 namespace apps {
12
13 ContentHandlerImpl::ContentHandlerImpl(ApplicationDelegateImpl* app)
14 : content_handler_(app) {
15 }
16
17 ContentHandlerImpl::~ContentHandlerImpl() {
18 }
19
20 void ContentHandlerImpl::OnConnect(
21 const mojo::String& url,
22 URLResponsePtr content,
23 InterfaceRequest<ServiceProvider> service_provider) {
24 content_handler_->StartJSApp(url.To<std::string>(), content.Pass());
25 }
26
27 ApplicationDelegateImpl::ApplicationDelegateImpl()
28 : application_impl_(NULL), content_handler_factory_(this) {
29 }
30
31 void ApplicationDelegateImpl::Initialize(ApplicationImpl* app) {
32 application_impl_ = app;
33 }
34
35 ApplicationDelegateImpl::~ApplicationDelegateImpl() {
36 }
37
38 bool ApplicationDelegateImpl::ConfigureIncomingConnection(
39 ApplicationConnection* connection) {
40 connection->AddService(&content_handler_factory_);
41 return true;
42 }
43
44 void ApplicationDelegateImpl::StartJSApp(const std::string& url,
45 URLResponsePtr content) {
46 JSApp* app = new JSApp(this, url, content.Pass());
47 app_vector_.push_back(app);
48 // TODO(hansmuller): deal with the Start() return value.
49 app->Start();
50 }
51
52 void ApplicationDelegateImpl::QuitJSApp(JSApp* app) {
53 AppVector::iterator itr =
54 std::find(app_vector_.begin(), app_vector_.end(), app);
55 if (itr != app_vector_.end())
56 app_vector_.erase(itr);
57 }
58
59 void ApplicationDelegateImpl::ConnectToService(
60 ScopedMessagePipeHandle pipe_handle,
61 const std::string& application_url,
62 const std::string& interface_name) {
63 CHECK(application_impl_);
64 ServiceProvider* service_provider =
65 application_impl_->ConnectToApplication(application_url)
66 ->GetServiceProvider();
67 service_provider->ConnectToService(interface_name, pipe_handle.Pass());
68 }
69
70 } // namespace apps
71 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698