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

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

Issue 665743003: Mojo JS Bindings: Simplify sharing services for content-provided JS applications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 #include "base/files/file_util.h" 5 #include "base/files/file_util.h"
6 #include "base/i18n/icu_util.h" 6 #include "base/i18n/icu_util.h"
7 #include "mojo/application/application_runner_chromium.h" 7 #include "mojo/application/application_runner_chromium.h"
8 #include "mojo/apps/js/application_delegate_impl.h" 8 #include "mojo/apps/js/application_delegate_impl.h"
9 #include "mojo/apps/js/js_app.h" 9 #include "mojo/apps/js/js_app.h"
10 #include "mojo/public/c/system/main.h" 10 #include "mojo/public/c/system/main.h"
11 #include "mojo/public/cpp/application/application_delegate.h" 11 #include "mojo/public/cpp/application/application_delegate.h"
12 #include "mojo/public/cpp/application/application_impl.h" 12 #include "mojo/public/cpp/application/application_impl.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 namespace apps { 15 namespace apps {
16 16
17 class StandaloneJSApp : public JSApp { 17 class StandaloneJSApp : public JSApp {
18 public: 18 public:
19 StandaloneJSApp(ApplicationDelegateImpl* app_delegate_impl, 19 StandaloneJSApp(ApplicationDelegateImpl* app_delegate_impl,
20 const base::FilePath& path) 20 const base::FilePath& path)
21 : JSApp(app_delegate_impl), 21 : JSApp(app_delegate_impl),
22 path_(path) { 22 path_(path) {
23 } 23 }
24 24
25 bool Load(std::string* source, std::string* file_name) override { 25 bool Load(std::string* source, std::string* file_name) override {
26 *file_name = path_.AsUTF8Unsafe(); 26 *file_name = path_.AsUTF8Unsafe();
27 return ReadFileToString(path_, source); 27 return ReadFileToString(path_, source);
28 } 28 }
29 29
30 virtual Handle RequestorMessagePipeHandle() override {
31 return Handle();
32 }
33
30 private: 34 private:
31 base::FilePath path_; 35 base::FilePath path_;
32 }; 36 };
33 37
34 class StandaloneApplicationDelegateImpl : public ApplicationDelegateImpl { 38 class StandaloneApplicationDelegateImpl : public ApplicationDelegateImpl {
35 private: 39 private:
36 void Initialize(ApplicationImpl* app) override { 40 void Initialize(ApplicationImpl* app) override {
37 base::i18n::InitializeICU(); 41 base::i18n::InitializeICU();
38 ApplicationDelegateImpl::Initialize(app); 42 ApplicationDelegateImpl::Initialize(app);
39 43
40 for (size_t i = 1; i < app->args().size(); i++) { 44 for (size_t i = 1; i < app->args().size(); i++) {
41 base::FilePath path(base::FilePath::FromUTF8Unsafe(app->args()[i])); 45 base::FilePath path(base::FilePath::FromUTF8Unsafe(app->args()[i]));
42 scoped_ptr<JSApp> js_app(new StandaloneJSApp(this, path)); 46 scoped_ptr<JSApp> js_app(new StandaloneJSApp(this, path));
43 StartJSApp(js_app.Pass()); 47 StartJSApp(js_app.Pass());
44 } 48 }
45 } 49 }
46 }; 50 };
47 51
48 } // namespace apps 52 } // namespace apps
49 } // namespace mojo 53 } // namespace mojo
50 54
51 MojoResult MojoMain(MojoHandle shell_handle) { 55 MojoResult MojoMain(MojoHandle shell_handle) {
52 mojo::ApplicationRunnerChromium runner( 56 mojo::ApplicationRunnerChromium runner(
53 new mojo::apps::StandaloneApplicationDelegateImpl()); 57 new mojo::apps::StandaloneApplicationDelegateImpl());
54 return runner.Run(shell_handle); 58 return runner.Run(shell_handle);
55 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698