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

Side by Side Diff: examples/ui/tile/tile_app.cc

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

Powered by Google App Engine
This is Rietveld 408576698