summaryrefslogtreecommitdiffstats
path: root/mojo/shell/application_manager/shell_impl.cc
diff options
context:
space:
mode:
authorJohn Abd-El-Malek <jam@chromium.org>2015-04-02 10:29:35 -0700
committerJohn Abd-El-Malek <jam@chromium.org>2015-04-02 17:31:11 +0000
commit537a670451020f4764d511cbdf8e30ec91ef897c (patch)
treed2868da2b0d33dc7ed8c8e709ae4a7f5bd5aefd8 /mojo/shell/application_manager/shell_impl.cc
parent83653dd1da59dfa7ddd9e48d4cd507a11cefd968 (diff)
downloadchromium_src-537a670451020f4764d511cbdf8e30ec91ef897c.zip
chromium_src-537a670451020f4764d511cbdf8e30ec91ef897c.tar.gz
chromium_src-537a670451020f4764d511cbdf8e30ec91ef897c.tar.bz2
Get mojo_shell building inside chromium checkout.
This brings in mojo_shell and the necessary services to make html_viewer work. This is copied from the Mojo repo at 272fbba5887d66fc0111e2ab44c1edf67b7f23e0. R=scottmg@chromium.org Review URL: https://codereview.chromium.org/1049993002 Cr-Commit-Position: refs/heads/master@{#323528}
Diffstat (limited to 'mojo/shell/application_manager/shell_impl.cc')
-rw-r--r--mojo/shell/application_manager/shell_impl.cc62
1 files changed, 62 insertions, 0 deletions
diff --git a/mojo/shell/application_manager/shell_impl.cc b/mojo/shell/application_manager/shell_impl.cc
new file mode 100644
index 0000000..ed8c5ea
--- /dev/null
+++ b/mojo/shell/application_manager/shell_impl.cc
@@ -0,0 +1,62 @@
+// 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 "mojo/shell/application_manager/shell_impl.h"
+
+#include "mojo/common/common_type_converters.h"
+#include "mojo/common/url_type_converters.h"
+#include "mojo/shell/application_manager/application_manager.h"
+#include "third_party/mojo_services/src/content_handler/public/interfaces/content_handler.mojom.h"
+
+namespace mojo {
+namespace shell {
+
+ShellImpl::ShellImpl(ApplicationPtr application,
+ ApplicationManager* manager,
+ const Identity& identity,
+ const base::Closure& on_application_end)
+ : manager_(manager),
+ identity_(identity),
+ on_application_end_(on_application_end),
+ application_(application.Pass()),
+ binding_(this) {
+ binding_.set_error_handler(this);
+}
+
+ShellImpl::~ShellImpl() {
+}
+
+void ShellImpl::InitializeApplication(Array<String> args) {
+ ShellPtr shell;
+ binding_.Bind(GetProxy(&shell));
+ application_->Initialize(shell.Pass(), args.Pass(), identity_.url.spec());
+}
+
+void ShellImpl::ConnectToClient(const GURL& requested_url,
+ const GURL& requestor_url,
+ InterfaceRequest<ServiceProvider> services,
+ ServiceProviderPtr exposed_services) {
+ application_->AcceptConnection(String::From(requestor_url), services.Pass(),
+ exposed_services.Pass(), requested_url.spec());
+}
+
+// Shell implementation:
+void ShellImpl::ConnectToApplication(const String& app_url,
+ InterfaceRequest<ServiceProvider> services,
+ ServiceProviderPtr exposed_services) {
+ GURL app_gurl(app_url);
+ if (!app_gurl.is_valid()) {
+ LOG(ERROR) << "Error: invalid URL: " << app_url;
+ return;
+ }
+ manager_->ConnectToApplication(app_gurl, identity_.url, services.Pass(),
+ exposed_services.Pass(), base::Closure());
+}
+
+void ShellImpl::OnConnectionError() {
+ manager_->OnShellImplError(this);
+}
+
+} // namespace shell
+} // namespace mojo