diff options
author | sky <sky@chromium.org> | 2015-05-02 09:29:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-02 16:29:30 +0000 |
commit | 63795badcd1a2ba1a37605540bbbb12465d908ec (patch) | |
tree | a41fbf761ba68e6e23b79a0f6dedb05bde93f259 /components/resource_provider/resource_provider_app.cc | |
parent | d2d50f900a0d32b8cca20ba496373e8116d70a6e (diff) | |
download | chromium_src-63795badcd1a2ba1a37605540bbbb12465d908ec.zip chromium_src-63795badcd1a2ba1a37605540bbbb12465d908ec.tar.gz chromium_src-63795badcd1a2ba1a37605540bbbb12465d908ec.tar.bz2 |
Adds resource_provider::ResourceProvider
It's used to fetch resources for mojo apps.
R=ben@chromium.org
Committed: https://crrev.com/6de67f80026697580ed4cefa11a72193243bd4a0
Cr-Commit-Position: refs/heads/master@{#328014}
Review URL: https://codereview.chromium.org/1108403008
Cr-Commit-Position: refs/heads/master@{#328064}
Diffstat (limited to 'components/resource_provider/resource_provider_app.cc')
-rw-r--r-- | components/resource_provider/resource_provider_app.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/components/resource_provider/resource_provider_app.cc b/components/resource_provider/resource_provider_app.cc new file mode 100644 index 0000000..1373d63 --- /dev/null +++ b/components/resource_provider/resource_provider_app.cc @@ -0,0 +1,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 |