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

Side by Side Diff: mojo/shell/application_instance.h

Issue 1311353005: Adds a way to determine id of content handler that created app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweaks Created 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef MOJO_SHELL_APPLICATION_INSTANCE_H_ 5 #ifndef MOJO_SHELL_APPLICATION_INSTANCE_H_
6 #define MOJO_SHELL_APPLICATION_INSTANCE_H_ 6 #define MOJO_SHELL_APPLICATION_INSTANCE_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "mojo/application/public/interfaces/application.mojom.h" 11 #include "mojo/application/public/interfaces/application.mojom.h"
12 #include "mojo/application/public/interfaces/shell.mojom.h" 12 #include "mojo/application/public/interfaces/shell.mojom.h"
13 #include "mojo/public/cpp/bindings/binding.h" 13 #include "mojo/public/cpp/bindings/binding.h"
14 #include "mojo/shell/capability_filter.h" 14 #include "mojo/shell/capability_filter.h"
15 #include "mojo/shell/identity.h" 15 #include "mojo/shell/identity.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace mojo { 18 namespace mojo {
19 namespace shell { 19 namespace shell {
20 20
21 class ApplicationManager; 21 class ApplicationManager;
22 22
23 // Encapsulates a connection to an instance of an application, tracked by the 23 // Encapsulates a connection to an instance of an application, tracked by the
24 // shell's ApplicationManager. 24 // shell's ApplicationManager.
25 class ApplicationInstance : public Shell { 25 class ApplicationInstance : public Shell {
26 public: 26 public:
27 // |requesting_content_handler_id| is the id of the content handler that
28 // loaded this app. If the app was not loaded by a content handler the id
29 // is ApplicationManager::kInvalidContentHandlerID.
27 ApplicationInstance(ApplicationPtr application, 30 ApplicationInstance(ApplicationPtr application,
28 ApplicationManager* manager, 31 ApplicationManager* manager,
29 const Identity& originator_identity, 32 const Identity& originator_identity,
30 const Identity& resolved_identity, 33 const Identity& resolved_identity,
31 const CapabilityFilter& filter, 34 const CapabilityFilter& filter,
35 uint32_t requesting_content_handler_id,
32 const base::Closure& on_application_end); 36 const base::Closure& on_application_end);
33 37
34 ~ApplicationInstance() override; 38 ~ApplicationInstance() override;
35 39
36 void InitializeApplication(); 40 void InitializeApplication();
37 41
38 void ConnectToClient(ApplicationInstance* originator, 42 void ConnectToClient(ApplicationInstance* originator,
39 const GURL& requested_url, 43 const GURL& requested_url,
40 const GURL& requestor_url, 44 const GURL& requestor_url,
41 InterfaceRequest<ServiceProvider> services, 45 InterfaceRequest<ServiceProvider> services,
42 ServiceProviderPtr exposed_services, 46 ServiceProviderPtr exposed_services,
43 const CapabilityFilter& filter); 47 const CapabilityFilter& filter);
44 48
45 // Returns the set of interfaces this application instance is allowed to see 49 // Returns the set of interfaces this application instance is allowed to see
46 // from an instance with |identity|. 50 // from an instance with |identity|.
47 AllowedInterfaces GetAllowedInterfaces(const Identity& identity) const; 51 AllowedInterfaces GetAllowedInterfaces(const Identity& identity) const;
48 52
49 Application* application() { return application_.get(); } 53 Application* application() { return application_.get(); }
50 const Identity& identity() const { return identity_; } 54 const Identity& identity() const { return identity_; }
51 base::Closure on_application_end() const { return on_application_end_; } 55 base::Closure on_application_end() const { return on_application_end_; }
56 void set_requesting_content_handler_id(uint32_t id) {
57 requesting_content_handler_id_ = id;
58 }
59 uint32_t requesting_content_handler_id() const {
60 return requesting_content_handler_id_;
61 }
52 62
53 private: 63 private:
54 // Shell implementation: 64 // Shell implementation:
55 void ConnectToApplication(URLRequestPtr app_request, 65 void ConnectToApplication(
56 InterfaceRequest<ServiceProvider> services, 66 URLRequestPtr app_request,
57 ServiceProviderPtr exposed_services, 67 InterfaceRequest<ServiceProvider> services,
58 CapabilityFilterPtr filter) override; 68 ServiceProviderPtr exposed_services,
69 CapabilityFilterPtr filter,
70 const ConnectToApplicationCallback& callback) override;
59 void QuitApplication() override; 71 void QuitApplication() override;
60 72
61 void CallAcceptConnection(ApplicationInstance* originator, 73 void CallAcceptConnection(ApplicationInstance* originator,
62 const GURL& url, 74 const GURL& url,
63 InterfaceRequest<ServiceProvider> services, 75 InterfaceRequest<ServiceProvider> services,
64 ServiceProviderPtr exposed_services, 76 ServiceProviderPtr exposed_services,
65 const GURL& requested_url); 77 const GURL& requested_url);
66 78
67 void OnConnectionError(); 79 void OnConnectionError();
68 80
69 void OnQuitRequestedResult(bool can_quit); 81 void OnQuitRequestedResult(bool can_quit);
70 82
71 struct QueuedClientRequest { 83 struct QueuedClientRequest {
72 QueuedClientRequest(); 84 QueuedClientRequest();
73 ~QueuedClientRequest(); 85 ~QueuedClientRequest();
74 ApplicationInstance* originator; 86 ApplicationInstance* originator;
75 GURL requested_url; 87 GURL requested_url;
76 GURL requestor_url; 88 GURL requestor_url;
77 InterfaceRequest<ServiceProvider> services; 89 InterfaceRequest<ServiceProvider> services;
78 ServiceProviderPtr exposed_services; 90 ServiceProviderPtr exposed_services;
79 CapabilityFilter filter; 91 CapabilityFilter filter;
92 Shell::ConnectToApplicationCallback connect_callback;
Ben Goodger (Google) 2015/08/31 17:41:07 don't think you need the Shell:: here?
sky 2015/08/31 19:46:07 Done.
80 }; 93 };
81 94
82 ApplicationManager* const manager_; 95 ApplicationManager* const manager_;
83 const Identity originator_identity_; 96 const Identity originator_identity_;
84 const Identity identity_; 97 const Identity identity_;
85 const CapabilityFilter filter_; 98 const CapabilityFilter filter_;
86 const bool allow_any_application_; 99 const bool allow_any_application_;
100 uint32_t requesting_content_handler_id_;
87 base::Closure on_application_end_; 101 base::Closure on_application_end_;
88 ApplicationPtr application_; 102 ApplicationPtr application_;
89 Binding<Shell> binding_; 103 Binding<Shell> binding_;
90 bool queue_requests_; 104 bool queue_requests_;
91 std::vector<QueuedClientRequest*> queued_client_requests_; 105 std::vector<QueuedClientRequest*> queued_client_requests_;
92 106
93 DISALLOW_COPY_AND_ASSIGN(ApplicationInstance); 107 DISALLOW_COPY_AND_ASSIGN(ApplicationInstance);
94 }; 108 };
95 109
96 } // namespace shell 110 } // namespace shell
97 } // namespace mojo 111 } // namespace mojo
98 112
99 #endif // MOJO_SHELL_APPLICATION_INSTANCE_H_ 113 #endif // MOJO_SHELL_APPLICATION_INSTANCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698