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

Unified Diff: mojo/ui/view_provider_app.cc

Issue 1556803002: Add helpers for creating UI components. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-13
Patch Set: address feedback Created 4 years, 11 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
« no previous file with comments | « mojo/ui/view_provider_app.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/ui/view_provider_app.cc
diff --git a/mojo/ui/view_provider_app.cc b/mojo/ui/view_provider_app.cc
new file mode 100644
index 0000000000000000000000000000000000000000..40d5a5bc8e526484fa9c4577821fb575eb0a1730
--- /dev/null
+++ b/mojo/ui/view_provider_app.cc
@@ -0,0 +1,79 @@
+// 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/view_provider_app.h"
+
+#include "base/command_line.h"
+#include "base/logging.h"
+
+namespace mojo {
+namespace ui {
+
+class ViewProviderApp::DelegatingViewProvider : public mojo::ui::ViewProvider {
+ public:
+ DelegatingViewProvider(ViewProviderApp* app,
+ const std::string& view_provider_url)
+ : app_(app), view_provider_url_(view_provider_url) {}
+
+ ~DelegatingViewProvider() override {}
+
+ private:
+ // |ViewProvider|:
+ void CreateView(
+ mojo::InterfaceRequest<mojo::ServiceProvider> services,
+ mojo::ServiceProviderPtr exposed_services,
+ const mojo::ui::ViewProvider::CreateViewCallback& callback) override {
+ app_->CreateView(this, view_provider_url_, services.Pass(),
+ exposed_services.Pass(), callback);
+ }
+
+ ViewProviderApp* app_;
+ std::string view_provider_url_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(DelegatingViewProvider);
+};
+
+ViewProviderApp::ViewProviderApp() {}
+
+ViewProviderApp::~ViewProviderApp() {}
+
+void ViewProviderApp::Initialize(mojo::ApplicationImpl* app_impl) {
+ app_impl_ = app_impl;
+
+ auto command_line = base::CommandLine::ForCurrentProcess();
+ command_line->InitFromArgv(app_impl_->args());
+ logging::LoggingSettings settings;
+ settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
+ logging::InitLogging(settings);
+}
+
+bool ViewProviderApp::ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) {
+ connection->AddService<mojo::ui::ViewProvider>(this);
+ return true;
+}
+
+void ViewProviderApp::Create(
+ mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<mojo::ui::ViewProvider> request) {
+ bindings_.AddBinding(
+ new DelegatingViewProvider(this, connection->GetConnectionURL()),
+ request.Pass());
+}
+
+void ViewProviderApp::CreateView(
+ DelegatingViewProvider* provider,
+ const std::string& view_provider_url,
+ mojo::InterfaceRequest<mojo::ServiceProvider> services,
+ mojo::ServiceProviderPtr exposed_services,
+ const mojo::ui::ViewProvider::CreateViewCallback& callback) {
+ if (!CreateView(view_provider_url, services.Pass(), exposed_services.Pass(),
+ callback)) {
+ bindings_.RemoveBindings(provider);
+ delete provider;
+ }
+}
+
+} // namespace ui
+} // namespace mojo
« no previous file with comments | « mojo/ui/view_provider_app.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698