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

Side by Side Diff: mojo/application/public/cpp/lib/application_impl.cc

Issue 1474563002: Make CapabilityFilter non-nullable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years 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 "mojo/application/public/cpp/application_impl.h" 5 #include "mojo/application/public/cpp/application_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "mojo/application/public/cpp/application_delegate.h" 11 #include "mojo/application/public/cpp/application_delegate.h"
12 #include "mojo/application/public/cpp/lib/service_registry.h" 12 #include "mojo/application/public/cpp/lib/service_registry.h"
13 #include "mojo/converters/network/network_type_converters.h" 13 #include "mojo/converters/network/network_type_converters.h"
14 #include "mojo/public/cpp/bindings/interface_ptr.h" 14 #include "mojo/public/cpp/bindings/interface_ptr.h"
15 #include "mojo/public/cpp/environment/logging.h" 15 #include "mojo/public/cpp/environment/logging.h"
16 16
17 namespace mojo { 17 namespace mojo {
18 18
19 namespace { 19 namespace {
20 20
21 void DefaultTerminationClosure() { 21 void DefaultTerminationClosure() {
22 if (base::MessageLoop::current() && 22 if (base::MessageLoop::current() &&
23 base::MessageLoop::current()->is_running()) 23 base::MessageLoop::current()->is_running())
24 base::MessageLoop::current()->QuitWhenIdle(); 24 base::MessageLoop::current()->QuitWhenIdle();
25 } 25 }
26 26
27 } // namespace 27 } // namespace
28 28
29 ApplicationImpl::ConnectParams::ConnectParams(const std::string& url) 29 ApplicationImpl::ConnectParams::ConnectParams(const std::string& url)
30 : request_(URLRequest::From(url)) {} 30 : ConnectParams(URLRequest::From(url)) {}
31 ApplicationImpl::ConnectParams::ConnectParams(URLRequestPtr request) 31 ApplicationImpl::ConnectParams::ConnectParams(URLRequestPtr request)
32 : request_(request.Pass()) {} 32 : request_(request.Pass()), filter_(CapabilityFilter::New()) {
33 filter_->filter.mark_non_null();
34 }
33 ApplicationImpl::ConnectParams::~ConnectParams() {} 35 ApplicationImpl::ConnectParams::~ConnectParams() {}
34 36
35 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, 37 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
36 InterfaceRequest<Application> request) 38 InterfaceRequest<Application> request)
37 : ApplicationImpl(delegate, request.Pass(), 39 : ApplicationImpl(delegate, request.Pass(),
38 base::Bind(&DefaultTerminationClosure)) { 40 base::Bind(&DefaultTerminationClosure)) {
39 } 41 }
40 42
41 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, 43 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
42 InterfaceRequest<Application> request, 44 InterfaceRequest<Application> request,
43 const Closure& termination_closure) 45 const Closure& termination_closure)
44 : delegate_(delegate), 46 : delegate_(delegate),
45 binding_(this, request.Pass()), 47 binding_(this, request.Pass()),
46 termination_closure_(termination_closure), 48 termination_closure_(termination_closure),
47 app_lifetime_helper_(this), 49 app_lifetime_helper_(this),
48 quit_requested_(false), 50 quit_requested_(false),
49 weak_factory_(this) {} 51 weak_factory_(this) {}
50 52
51 ApplicationImpl::~ApplicationImpl() { 53 ApplicationImpl::~ApplicationImpl() {
52 app_lifetime_helper_.OnQuit(); 54 app_lifetime_helper_.OnQuit();
53 } 55 }
54 56
55 scoped_ptr<ApplicationConnection> ApplicationImpl::ConnectToApplication( 57 scoped_ptr<ApplicationConnection> ApplicationImpl::ConnectToApplication(
56 const std::string& url) { 58 const std::string& url) {
57 ConnectParams params(url); 59 ConnectParams params(url);
60 params.set_filter(CreatePermissiveCapabilityFilter());
58 return ConnectToApplication(&params); 61 return ConnectToApplication(&params);
59 } 62 }
60 63
61 scoped_ptr<ApplicationConnection> 64 scoped_ptr<ApplicationConnection>
62 ApplicationImpl::ConnectToApplication(ConnectParams* params) { 65 ApplicationImpl::ConnectToApplication(ConnectParams* params) {
63 if (!shell_) 66 if (!shell_)
64 return nullptr; 67 return nullptr;
65 DCHECK(params); 68 DCHECK(params);
66 URLRequestPtr request = params->TakeRequest(); 69 URLRequestPtr request = params->TakeRequest();
67 ServiceProviderPtr local_services; 70 ServiceProviderPtr local_services;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 termination_closure_.Run(); 163 termination_closure_.Run();
161 } 164 }
162 165
163 void ApplicationImpl::UnbindConnections( 166 void ApplicationImpl::UnbindConnections(
164 InterfaceRequest<Application>* application_request, 167 InterfaceRequest<Application>* application_request,
165 ShellPtr* shell) { 168 ShellPtr* shell) {
166 *application_request = binding_.Unbind(); 169 *application_request = binding_.Unbind();
167 shell->Bind(shell_.PassInterface()); 170 shell->Bind(shell_.PassInterface());
168 } 171 }
169 172
173 CapabilityFilterPtr CreatePermissiveCapabilityFilter() {
174 CapabilityFilterPtr filter(CapabilityFilter::New());
175 Array<String> all_interfaces;
176 all_interfaces.push_back("*");
177 filter->filter.insert("*", all_interfaces.Pass());
178 return filter.Pass();
179 }
180
170 } // namespace mojo 181 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/application/public/cpp/application_impl.h ('k') | mojo/application/public/interfaces/shell.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698