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

Unified Diff: mojo/ui/content_viewer_app.cc

Issue 1556803002: Add helpers for creating UI components. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-13
Patch Set: Created 4 years, 12 months 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 side-by-side diff with in-line comments
Download patch
Index: mojo/ui/content_viewer_app.cc
diff --git a/mojo/ui/content_viewer_app.cc b/mojo/ui/content_viewer_app.cc
new file mode 100644
index 0000000000000000000000000000000000000000..69930820956b4180402ab4f0d4485fd809b81f8e
--- /dev/null
+++ b/mojo/ui/content_viewer_app.cc
@@ -0,0 +1,74 @@
+// 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/ui/content_viewer_app.h"
+
+#include "base/command_line.h"
+#include "base/logging.h"
+
+namespace mojo {
+namespace ui {
+
+class ContentViewerApp::DelegatingContentHandler : public mojo::ContentHandler {
+ public:
+ DelegatingContentHandler(ContentViewerApp* app,
+ const std::string& content_handler_url)
+ : app_(app), content_handler_url_(content_handler_url) {}
+
+ ~DelegatingContentHandler() override {}
+
+ private:
+ // |ContentHandler|:
+ void StartApplication(
+ mojo::InterfaceRequest<mojo::Application> application_request,
+ mojo::URLResponsePtr response) override {
+ app_->StartViewer(content_handler_url_, application_request.Pass(),
+ response.Pass());
+ }
+
+ ContentViewerApp* app_;
+ std::string content_handler_url_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(DelegatingContentHandler);
+};
+
+ContentViewerApp::ContentViewerApp() {}
+
+ContentViewerApp::~ContentViewerApp() {}
+
+void ContentViewerApp::Initialize(mojo::ApplicationImpl* app_impl) {
+ app_impl_ = app_impl;
+
+ auto command_line = base::CommandLine::ForCurrentProcess();
abarth 2016/01/10 23:23:39 I'd remove this interaction with the CommandLine s
jeffbrown 2016/01/26 07:25:15 I'm going to leave this in for now since it's supe
+ command_line->InitFromArgv(app_impl_->args());
+ logging::LoggingSettings settings;
+ settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
+ logging::InitLogging(settings);
+}
+
+bool ContentViewerApp::ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) {
+ connection->AddService<mojo::ContentHandler>(this);
+ return true;
+}
+
+void ContentViewerApp::Create(
+ mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<mojo::ContentHandler> request) {
+ bindings_.AddBinding(
+ new DelegatingContentHandler(this, connection->GetConnectionURL()),
+ request.Pass());
+}
+
+void ContentViewerApp::StartViewer(
+ const std::string& content_handler_url,
+ mojo::InterfaceRequest<mojo::Application> application_request,
+ mojo::URLResponsePtr response) {
+ ViewProviderApp* app = LoadContent(content_handler_url, response.Pass());
+ if (app)
+ new mojo::ApplicationImpl(app, application_request.Pass());
+}
+
+} // namespace ui
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698