blob: 1373d637e28bf3ead93b25a862415984de7041a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/resource_provider/resource_provider_app.h"
#include "components/resource_provider/file_utils.h"
#include "components/resource_provider/resource_provider_impl.h"
#include "third_party/mojo/src/mojo/public/cpp/application/application_connection.h"
#include "url/gurl.h"
namespace resource_provider {
ResourceProviderApp::ResourceProviderApp() {
}
ResourceProviderApp::~ResourceProviderApp() {
}
void ResourceProviderApp::Initialize(mojo::ApplicationImpl* app) {
}
bool ResourceProviderApp::ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) {
const base::FilePath app_path(
GetPathForApplicationUrl(GURL(connection->GetRemoteApplicationURL())));
if (app_path.empty())
return false; // The specified app has no resources.
connection->AddService<ResourceProvider>(this);
return true;
}
void ResourceProviderApp::Create(
mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<ResourceProvider> request) {
const base::FilePath app_path(
GetPathForApplicationUrl(GURL(connection->GetRemoteApplicationURL())));
// We validated path at ConfigureIncomingConnection() time, so it should still
// be valid.
CHECK(!app_path.empty());
bindings_.AddBinding(new ResourceProviderImpl(app_path), request.Pass());
}
} // namespace resource_provider
|