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

Side by Side Diff: mojo/ui/content_viewer_app.cc

Issue 1556803002: Add helpers for creating UI components. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-13
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
(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/content_viewer_app.h"
6
7 #include "base/command_line.h"
8 #include "base/logging.h"
9
10 namespace mojo {
11 namespace ui {
12
13 class ContentViewerApp::DelegatingContentHandler : public mojo::ContentHandler {
14 public:
15 DelegatingContentHandler(ContentViewerApp* app,
16 const std::string& content_handler_url)
17 : app_(app), content_handler_url_(content_handler_url) {}
18
19 ~DelegatingContentHandler() override {}
20
21 private:
22 // |ContentHandler|:
23 void StartApplication(
24 mojo::InterfaceRequest<mojo::Application> application_request,
25 mojo::URLResponsePtr response) override {
26 app_->StartViewer(content_handler_url_, application_request.Pass(),
27 response.Pass());
28 }
29
30 ContentViewerApp* app_;
31 std::string content_handler_url_;
32
33 MOJO_DISALLOW_COPY_AND_ASSIGN(DelegatingContentHandler);
34 };
35
36 ContentViewerApp::ContentViewerApp() {}
37
38 ContentViewerApp::~ContentViewerApp() {}
39
40 void ContentViewerApp::Initialize(mojo::ApplicationImpl* app_impl) {
41 app_impl_ = app_impl;
42
43 auto command_line = base::CommandLine::ForCurrentProcess();
abarth 2016/01/10 23:23:39 I'd remove this interaction with the CommandLine s
jeffbrown 2016/01/26 07:25:15 I'm going to leave this in for now since it's supe
44 command_line->InitFromArgv(app_impl_->args());
45 logging::LoggingSettings settings;
46 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
47 logging::InitLogging(settings);
48 }
49
50 bool ContentViewerApp::ConfigureIncomingConnection(
51 mojo::ApplicationConnection* connection) {
52 connection->AddService<mojo::ContentHandler>(this);
53 return true;
54 }
55
56 void ContentViewerApp::Create(
57 mojo::ApplicationConnection* connection,
58 mojo::InterfaceRequest<mojo::ContentHandler> request) {
59 bindings_.AddBinding(
60 new DelegatingContentHandler(this, connection->GetConnectionURL()),
61 request.Pass());
62 }
63
64 void ContentViewerApp::StartViewer(
65 const std::string& content_handler_url,
66 mojo::InterfaceRequest<mojo::Application> application_request,
67 mojo::URLResponsePtr response) {
68 ViewProviderApp* app = LoadContent(content_handler_url, response.Pass());
69 if (app)
70 new mojo::ApplicationImpl(app, application_request.Pass());
71 }
72
73 } // namespace ui
74 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698