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

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

Issue 687273002: mojo: Update content handler API (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Use the new content handler mechanism for js Created 6 years, 1 month 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
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 5
6 #include "base/i18n/icu_util.h" 6 #include "base/i18n/icu_util.h"
7 #include "mojo/application/application_runner_chromium.h" 7 #include "gin/array_buffer.h"
8 #include "mojo/apps/js/application_delegate_impl.h" 8 #include "gin/public/isolate_holder.h"
9 #include "mojo/apps/js/content_handler_impl.h" 9 #include "mojo/application/content_handler.h"
10 #include "mojo/apps/js/js_app.h"
10 #include "mojo/public/c/system/main.h" 11 #include "mojo/public/c/system/main.h"
11 #include "mojo/public/cpp/application/application_impl.h" 12 #include "mojo/public/cpp/application/application_impl.h"
12 #include "mojo/public/cpp/application/interface_factory_impl.h" 13 #include "mojo/public/cpp/application/interface_factory_impl.h"
13 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom. h"
14 14
15 namespace mojo { 15 namespace mojo {
16 namespace apps { 16 namespace apps {
17 17
18 class ContentHandlerApplicationDelegateImpl : public ApplicationDelegateImpl { 18 class JsContentHandler : public ContentHandlerDelegate {
19 public:
20 ContentHandlerApplicationDelegateImpl() : content_handler_factory_(this) {
21 }
22
23 private: 19 private:
20 // From ContentHandlerDelegate:
24 void Initialize(ApplicationImpl* app) override { 21 void Initialize(ApplicationImpl* app) override {
25 base::i18n::InitializeICU(); 22 base::i18n::InitializeICU();
26 ApplicationDelegateImpl::Initialize(app); 23 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
24 gin::ArrayBufferAllocator::SharedInstance());
27 } 25 }
28 26 virtual scoped_ptr<mojo::InterfaceImpl<mojo::Application>> CreateApplication(
29 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 27 ShellPtr shell,
30 connection->AddService(&content_handler_factory_); 28 URLResponsePtr response) override {
31 return true; 29 return make_scoped_ptr(new JSApp(shell.Pass(), response.Pass()));
32 } 30 }
33
34 InterfaceFactoryImplWithContext<ContentHandlerImpl, ApplicationDelegateImpl>
35 content_handler_factory_;
36 }; 31 };
37 32
38 } // namespace apps 33 } // namespace apps
39 } // namespace mojo 34 } // namespace mojo
40 35
41 MojoResult MojoMain(MojoHandle shell_handle) { 36 MojoResult MojoMain(MojoHandle shell_handle) {
42 mojo::ApplicationRunnerChromium runner( 37 return mojo::ContentHandlerRunner::Run(
43 new mojo::apps::ContentHandlerApplicationDelegateImpl()); 38 shell_handle, make_scoped_ptr(new mojo::apps::JsContentHandler));
44 return runner.Run(shell_handle);
45 } 39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698