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

Unified Diff: examples/ui/tile/tile_app.cc

Issue 1425543002: mozart: Add a simple tiling view manager. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 2 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: examples/ui/tile/tile_app.cc
diff --git a/examples/ui/tile/tile_app.cc b/examples/ui/tile/tile_app.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6d5f7d3741d1ceb8f1620cb91dd2e391078a4a9a
--- /dev/null
+++ b/examples/ui/tile/tile_app.cc
@@ -0,0 +1,63 @@
+// Copyright 2013 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 <vector>
+
+#include "base/strings/string_split.h"
+#include "examples/ui/tile/tile_app.h"
+#include "examples/ui/tile/tile_view.h"
+#include "url/gurl.h"
+
+namespace examples {
+
+class TileViewProvider : public mojo::ui::ViewProvider {
+ public:
+ TileViewProvider(mojo::ApplicationImpl* app_impl,
+ const std::vector<std::string>& view_urls)
+ : app_impl_(app_impl), view_urls_(view_urls) {}
+ ~TileViewProvider() override {}
+
+ // |ViewProvider|:
+ void CreateView(mojo::InterfaceRequest<mojo::ServiceProvider> services,
+ mojo::ServiceProviderPtr exposed_services,
+ const CreateViewCallback& callback) override {
+ new TileView(app_impl_, view_urls_, callback);
+ }
+
+ private:
+ mojo::ApplicationImpl* app_impl_;
+ std::vector<std::string> view_urls_;
+};
+
+TileApp::TileApp() {}
+
+TileApp::~TileApp() {}
+
+void TileApp::Initialize(mojo::ApplicationImpl* app_impl) {
+ app_impl_ = app_impl;
+}
+
+bool TileApp::ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) {
+ connection->AddService<mojo::ui::ViewProvider>(this);
+ return true;
+}
+
+void TileApp::Create(mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<mojo::ui::ViewProvider> request) {
+ GURL url(connection->GetConnectionURL());
+ std::vector<std::string> view_urls;
+ base::SplitString(url.query(), ',', &view_urls);
abarth 2015/10/24 06:51:12 This is kind of lame. You should probably use the
jeffbrown 2015/10/27 03:13:08 Args won't work here. Suppose I wanted to embed t
+
+ if (view_urls.empty()) {
+ LOG(ERROR) << "Must supply comma-delimited URLs of mojo views to tile as a "
+ "query parameter.";
+ return;
+ }
+
+ bindings_.AddBinding(new TileViewProvider(app_impl_, view_urls),
+ request.Pass());
+}
+
+} // namespace examples

Powered by Google App Engine
This is Rietveld 408576698