Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <vector> | |
| 6 | |
| 7 #include "base/strings/string_split.h" | |
| 8 #include "examples/ui/tile/tile_app.h" | |
| 9 #include "examples/ui/tile/tile_view.h" | |
| 10 #include "url/gurl.h" | |
| 11 | |
| 12 namespace examples { | |
| 13 | |
| 14 class TileViewProvider : public mojo::ui::ViewProvider { | |
| 15 public: | |
| 16 TileViewProvider(mojo::ApplicationImpl* app_impl, | |
| 17 const std::vector<std::string>& view_urls) | |
| 18 : app_impl_(app_impl), view_urls_(view_urls) {} | |
| 19 ~TileViewProvider() override {} | |
| 20 | |
| 21 // |ViewProvider|: | |
| 22 void CreateView(mojo::InterfaceRequest<mojo::ServiceProvider> services, | |
| 23 mojo::ServiceProviderPtr exposed_services, | |
| 24 const CreateViewCallback& callback) override { | |
| 25 new TileView(app_impl_, view_urls_, callback); | |
| 26 } | |
| 27 | |
| 28 private: | |
| 29 mojo::ApplicationImpl* app_impl_; | |
| 30 std::vector<std::string> view_urls_; | |
| 31 }; | |
|
jamesr
2015/10/27 22:58:27
probably want to DISALLOW_COPY_AND_ASSIGN this too
jeffbrown
2015/10/27 23:24:19
Done.
| |
| 32 | |
| 33 TileApp::TileApp() {} | |
| 34 | |
| 35 TileApp::~TileApp() {} | |
| 36 | |
| 37 void TileApp::Initialize(mojo::ApplicationImpl* app_impl) { | |
| 38 app_impl_ = app_impl; | |
| 39 } | |
| 40 | |
| 41 bool TileApp::ConfigureIncomingConnection( | |
| 42 mojo::ApplicationConnection* connection) { | |
| 43 connection->AddService<mojo::ui::ViewProvider>(this); | |
| 44 return true; | |
| 45 } | |
| 46 | |
| 47 void TileApp::Create(mojo::ApplicationConnection* connection, | |
| 48 mojo::InterfaceRequest<mojo::ui::ViewProvider> request) { | |
| 49 GURL url(connection->GetConnectionURL()); | |
| 50 std::vector<std::string> view_urls; | |
| 51 base::SplitString(url.query(), ',', &view_urls); | |
| 52 | |
| 53 if (view_urls.empty()) { | |
| 54 LOG(ERROR) << "Must supply comma-delimited URLs of mojo views to tile as a " | |
| 55 "query parameter."; | |
| 56 return; | |
| 57 } | |
| 58 | |
| 59 bindings_.AddBinding(new TileViewProvider(app_impl_, view_urls), | |
| 60 request.Pass()); | |
| 61 } | |
| 62 | |
| 63 } // namespace examples | |
| OLD | NEW |