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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « mojo/ui/view_provider_app.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mojo/ui/view_provider_app.h"
6
7 #include "base/command_line.h"
8 #include "base/logging.h"
9
10 namespace mojo {
11 namespace ui {
12
13 class ViewProviderApp::DelegatingViewProvider : public mojo::ui::ViewProvider {
14 public:
15 DelegatingViewProvider(ViewProviderApp* app,
16 const std::string& view_provider_url)
17 : app_(app), view_provider_url_(view_provider_url) {}
18
19 ~DelegatingViewProvider() override {}
20
21 private:
22 // |ViewProvider|:
23 void CreateView(
24 mojo::InterfaceRequest<mojo::ServiceProvider> services,
25 mojo::ServiceProviderPtr exposed_services,
26 const mojo::ui::ViewProvider::CreateViewCallback& callback) override {
27 app_->CreateView(this, view_provider_url_, services.Pass(),
28 exposed_services.Pass(), callback);
29 }
30
31 ViewProviderApp* app_;
32 std::string view_provider_url_;
33
34 MOJO_DISALLOW_COPY_AND_ASSIGN(DelegatingViewProvider);
35 };
36
37 ViewProviderApp::ViewProviderApp() {}
38
39 ViewProviderApp::~ViewProviderApp() {}
40
41 void ViewProviderApp::Initialize(mojo::ApplicationImpl* app_impl) {
42 app_impl_ = app_impl;
43
44 auto command_line = base::CommandLine::ForCurrentProcess();
45 command_line->InitFromArgv(app_impl_->args());
46 logging::LoggingSettings settings;
47 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
48 logging::InitLogging(settings);
49 }
50
51 bool ViewProviderApp::ConfigureIncomingConnection(
52 mojo::ApplicationConnection* connection) {
53 connection->AddService<mojo::ui::ViewProvider>(this);
54 return true;
55 }
56
57 void ViewProviderApp::Create(
58 mojo::ApplicationConnection* connection,
59 mojo::InterfaceRequest<mojo::ui::ViewProvider> request) {
60 bindings_.AddBinding(
61 new DelegatingViewProvider(this, connection->GetConnectionURL()),
62 request.Pass());
63 }
64
65 void ViewProviderApp::CreateView(
66 DelegatingViewProvider* provider,
67 const std::string& view_provider_url,
68 mojo::InterfaceRequest<mojo::ServiceProvider> services,
69 mojo::ServiceProviderPtr exposed_services,
70 const mojo::ui::ViewProvider::CreateViewCallback& callback) {
71 if (!CreateView(view_provider_url, services.Pass(), exposed_services.Pass(),
72 callback)) {
73 bindings_.RemoveBindings(provider);
74 delete provider;
75 }
76 }
77
78 } // namespace ui
79 } // namespace mojo
OLDNEW
« 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