Roll src/third_party/WebKit ef7cfd7:80927b2 (svn 194570:194575)
[chromium-blink-merge.git] / mojo / shell / shell_impl.cc
blobc51668628ae3065be083fac039732545936c95bc
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
3 // found in the LICENSE file.
5 #include "mojo/shell/shell_impl.h"
7 #include "mojo/common/common_type_converters.h"
8 #include "mojo/common/url_type_converters.h"
9 #include "mojo/shell/application_manager.h"
10 #include "third_party/mojo_services/src/content_handler/public/interfaces/content_handler.mojom.h"
12 namespace mojo {
13 namespace shell {
15 ShellImpl::ShellImpl(ApplicationPtr application,
16 ApplicationManager* manager,
17 const Identity& identity,
18 const base::Closure& on_application_end)
19 : manager_(manager),
20 identity_(identity),
21 on_application_end_(on_application_end),
22 application_(application.Pass()),
23 binding_(this) {
24 binding_.set_error_handler(this);
27 ShellImpl::~ShellImpl() {
30 void ShellImpl::InitializeApplication(Array<String> args) {
31 ShellPtr shell;
32 binding_.Bind(GetProxy(&shell));
33 application_->Initialize(shell.Pass(), args.Pass(), identity_.url.spec());
36 void ShellImpl::ConnectToClient(const GURL& requested_url,
37 const GURL& requestor_url,
38 InterfaceRequest<ServiceProvider> services,
39 ServiceProviderPtr exposed_services) {
40 application_->AcceptConnection(String::From(requestor_url), services.Pass(),
41 exposed_services.Pass(), requested_url.spec());
44 // Shell implementation:
45 void ShellImpl::ConnectToApplication(const String& app_url,
46 InterfaceRequest<ServiceProvider> services,
47 ServiceProviderPtr exposed_services) {
48 GURL app_gurl(app_url);
49 if (!app_gurl.is_valid()) {
50 LOG(ERROR) << "Error: invalid URL: " << app_url;
51 return;
53 manager_->ConnectToApplication(app_gurl, identity_.url, services.Pass(),
54 exposed_services.Pass(), base::Closure());
57 void ShellImpl::OnConnectionError() {
58 manager_->OnShellImplError(this);
61 } // namespace shell
62 } // namespace mojo