Chromium Code Reviews| 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 |