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

Side by Side Diff: mash/browser_driver/browser_driver_application_delegate.cc

Issue 1614553002: Reduce boilerplate needed to configure mojo::Binding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment 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 | « no previous file | mash/shelf/shelf_view.cc » ('j') | mojo/public/cpp/bindings/binding.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "mash/browser_driver/browser_driver_application_delegate.h" 5 #include "mash/browser_driver/browser_driver_application_delegate.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "components/mus/public/cpp/event_matcher.h" 10 #include "components/mus/public/cpp/event_matcher.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 void BrowserDriverApplicationDelegate::AddAccelerators() { 81 void BrowserDriverApplicationDelegate::AddAccelerators() {
82 // TODO(beng): find some other way to get the window manager. I don't like 82 // TODO(beng): find some other way to get the window manager. I don't like
83 // having to specify it by URL because it may differ per display. 83 // having to specify it by URL because it may differ per display.
84 mus::mojom::AcceleratorRegistrarPtr registrar; 84 mus::mojom::AcceleratorRegistrarPtr registrar;
85 app_->ConnectToService("mojo:desktop_wm", &registrar); 85 app_->ConnectToService("mojo:desktop_wm", &registrar);
86 86
87 if (binding_.is_bound()) 87 if (binding_.is_bound())
88 binding_.Unbind(); 88 binding_.Unbind();
89 mus::mojom::AcceleratorHandlerPtr handler;
90 binding_.Bind(GetProxy(&handler));
91 // If the window manager restarts, the handler pipe will close and we'll need 89 // If the window manager restarts, the handler pipe will close and we'll need
92 // to re-add our accelerators when the window manager comes back up. 90 // to re-add our accelerators when the window manager comes back up.
93 binding_.set_connection_error_handler( 91 binding_.set_connection_error_handler(
94 base::Bind(&BrowserDriverApplicationDelegate::AddAccelerators, 92 base::Bind(&BrowserDriverApplicationDelegate::AddAccelerators,
95 base::Unretained(this))); 93 base::Unretained(this)));
96 registrar->SetHandler(std::move(handler)); 94 registrar->SetHandler(binding_.CreateInterfacePtrAndBind());
97 95
98 for (const AcceleratorSpec& spec : g_spec) { 96 for (const AcceleratorSpec& spec : g_spec) {
99 registrar->AddAccelerator( 97 registrar->AddAccelerator(
100 static_cast<uint32_t>(spec.id), 98 static_cast<uint32_t>(spec.id),
101 mus::CreateKeyMatcher(spec.keyboard_code, spec.event_flags), 99 mus::CreateKeyMatcher(spec.keyboard_code, spec.event_flags),
102 base::Bind(&AssertTrue)); 100 base::Bind(&AssertTrue));
103 } 101 }
104 } 102 }
105 103
106 } // namespace browser_driver 104 } // namespace browser_driver
107 } // namespace main 105 } // namespace main
OLDNEW
« no previous file with comments | « no previous file | mash/shelf/shelf_view.cc » ('j') | mojo/public/cpp/bindings/binding.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698