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

Side by Side Diff: examples/forwarding_content_handler/forwarding_content_handler.cc

Issue 943053003: Simple multi-url support for mojo apps (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
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/macros.h" 5 #include "base/macros.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "mojo/application/application_runner_chromium.h" 7 #include "mojo/application/application_runner_chromium.h"
8 #include "mojo/application/content_handler_factory.h" 8 #include "mojo/application/content_handler_factory.h"
9 #include "mojo/common/data_pipe_utils.h" 9 #include "mojo/common/data_pipe_utils.h"
10 #include "mojo/public/c/system/main.h" 10 #include "mojo/public/c/system/main.h"
11 #include "mojo/public/cpp/application/application_connection.h" 11 #include "mojo/public/cpp/application/application_connection.h"
12 #include "mojo/public/cpp/application/application_delegate.h" 12 #include "mojo/public/cpp/application/application_delegate.h"
13 #include "mojo/public/cpp/application/interface_factory_impl.h" 13 #include "mojo/public/cpp/application/interface_factory_impl.h"
14 #include "mojo/public/cpp/bindings/binding.h" 14 #include "mojo/public/cpp/bindings/binding.h"
15 #include "mojo/public/cpp/utility/run_loop.h" 15 #include "mojo/public/cpp/utility/run_loop.h"
16 #include "mojo/public/interfaces/application/application.mojom.h" 16 #include "mojo/public/interfaces/application/application.mojom.h"
17 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom. h" 17 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom. h"
18 18
19 namespace mojo { 19 namespace mojo {
20 namespace examples { 20 namespace examples {
21 21
22 class ForwardingApplicationImpl : public Application { 22 class ForwardingApplicationImpl : public Application {
23 public: 23 public:
24 ForwardingApplicationImpl(InterfaceRequest<Application> request, 24 ForwardingApplicationImpl(InterfaceRequest<Application> request,
25 std::string target_url) 25 std::string target_url)
qsr 2015/02/27 15:01:40 I don't understand this change. This content hand
Aaron Boodman 2015/02/27 16:54:44 Whoopsie. fixed.
26 : binding_(this, request.Pass()), 26 : binding_(this, request.Pass()) {}
27 target_url_(target_url) {
28 }
29 27
30 private: 28 private:
31 // Application: 29 // Application:
32 void Initialize(ShellPtr shell, 30 void Initialize(ShellPtr shell,
33 Array<String> args, 31 Array<String> args,
34 const mojo::String& url) override { 32 const mojo::String& url) override {
35 shell_ = shell.Pass(); 33 shell_ = shell.Pass();
36 } 34 }
37 void AcceptConnection(const String& requestor_url, 35 void AcceptConnection(const String& requestor_url,
38 InterfaceRequest<ServiceProvider> services, 36 InterfaceRequest<ServiceProvider> services,
39 ServiceProviderPtr exposed_services) override { 37 ServiceProviderPtr exposed_services,
40 shell_->ConnectToApplication(target_url_, services.Pass(), 38 const String& url) override {
41 exposed_services.Pass()); 39 shell_->ConnectToApplication(url, services.Pass(), exposed_services.Pass());
42 } 40 }
43 void RequestQuit() override { 41 void RequestQuit() override {
44 RunLoop::current()->Quit(); 42 RunLoop::current()->Quit();
45 } 43 }
46 44
47 Binding<Application> binding_; 45 Binding<Application> binding_;
48 std::string target_url_;
49 ShellPtr shell_; 46 ShellPtr shell_;
50 }; 47 };
51 48
52 class ForwardingContentHandler : public ApplicationDelegate, 49 class ForwardingContentHandler : public ApplicationDelegate,
53 public ContentHandlerFactory::ManagedDelegate { 50 public ContentHandlerFactory::ManagedDelegate {
54 public: 51 public:
55 ForwardingContentHandler() : content_handler_factory_(this) {} 52 ForwardingContentHandler() : content_handler_factory_(this) {}
56 53
57 private: 54 private:
58 // Overridden from ApplicationDelegate: 55 // Overridden from ApplicationDelegate:
(...skipping 24 matching lines...) Expand all
83 }; 80 };
84 81
85 } // namespace examples 82 } // namespace examples
86 } // namespace mojo 83 } // namespace mojo
87 84
88 MojoResult MojoMain(MojoHandle shell_handle) { 85 MojoResult MojoMain(MojoHandle shell_handle) {
89 mojo::ApplicationRunnerChromium runner( 86 mojo::ApplicationRunnerChromium runner(
90 new mojo::examples::ForwardingContentHandler()); 87 new mojo::examples::ForwardingContentHandler());
91 return runner.Run(shell_handle); 88 return runner.Run(shell_handle);
92 } 89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698