OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chromeos/dbus/ibus/ibus_panel_service.h" | 5 #include "chromeos/dbus/ibus/ibus_panel_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "chromeos/dbus/ibus/ibus_constants.h" | 10 #include "chromeos/dbus/ibus/ibus_constants.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 base::Bind(&IBusPanelServiceImpl::OnMethodExported, | 87 base::Bind(&IBusPanelServiceImpl::OnMethodExported, |
88 weak_ptr_factory_.GetWeakPtr())); | 88 weak_ptr_factory_.GetWeakPtr())); |
89 | 89 |
90 exported_object_->ExportMethod( | 90 exported_object_->ExportMethod( |
91 ibus::panel::kServiceInterface, | 91 ibus::panel::kServiceInterface, |
92 ibus::panel::kUpdatePropertyMethod, | 92 ibus::panel::kUpdatePropertyMethod, |
93 base::Bind(&IBusPanelServiceImpl::UpdateProperty, | 93 base::Bind(&IBusPanelServiceImpl::UpdateProperty, |
94 weak_ptr_factory_.GetWeakPtr()), | 94 weak_ptr_factory_.GetWeakPtr()), |
95 base::Bind(&IBusPanelServiceImpl::OnMethodExported, | 95 base::Bind(&IBusPanelServiceImpl::OnMethodExported, |
96 weak_ptr_factory_.GetWeakPtr())); | 96 weak_ptr_factory_.GetWeakPtr())); |
| 97 |
| 98 // Request well known name to ibus-daemon. |
| 99 bus->RequestOwnership( |
| 100 ibus::panel::kServiceName, |
| 101 base::Bind(&IBusPanelServiceImpl::OnRequestOwnership, |
| 102 weak_ptr_factory_.GetWeakPtr())); |
97 } | 103 } |
98 | 104 |
99 virtual ~IBusPanelServiceImpl() { | 105 virtual ~IBusPanelServiceImpl() { |
100 bus_->UnregisterExportedObject( | 106 bus_->UnregisterExportedObject( |
101 dbus::ObjectPath(ibus::panel::kServicePath)); | 107 dbus::ObjectPath(ibus::panel::kServicePath)); |
102 } | 108 } |
103 | 109 |
104 // IBusPanelService override. | 110 // IBusPanelService override. |
105 virtual void SetUpCandidateWindowHandler( | 111 virtual void SetUpCandidateWindowHandler( |
106 IBusPanelCandidateWindowHandlerInterface* handler) { | 112 IBusPanelCandidateWindowHandlerInterface* handler) { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 } | 315 } |
310 | 316 |
311 // Called when the method call is exported. | 317 // Called when the method call is exported. |
312 void OnMethodExported(const std::string& interface_name, | 318 void OnMethodExported(const std::string& interface_name, |
313 const std::string& method_name, | 319 const std::string& method_name, |
314 bool success) { | 320 bool success) { |
315 LOG_IF(WARNING, !success) << "Failed to export " | 321 LOG_IF(WARNING, !success) << "Failed to export " |
316 << interface_name << "." << method_name; | 322 << interface_name << "." << method_name; |
317 } | 323 } |
318 | 324 |
| 325 // Called when the well knwon name is acquired. |
| 326 void OnRequestOwnership(const std::string& name, bool obtained) { |
| 327 LOG_IF(ERROR, !obtained) << "Failed to acquire well known name:" |
| 328 << name; |
| 329 } |
| 330 |
319 // D-Bus bus object used for unregistering exported methods in dtor. | 331 // D-Bus bus object used for unregistering exported methods in dtor. |
320 dbus::Bus* bus_; | 332 dbus::Bus* bus_; |
321 | 333 |
322 // All incoming method calls are passed on to the |candidate_window_handler_| | 334 // All incoming method calls are passed on to the |candidate_window_handler_| |
323 // or |property_handler|. This class does not take ownership of following | 335 // or |property_handler|. This class does not take ownership of following |
324 // handlers. | 336 // handlers. |
325 IBusPanelCandidateWindowHandlerInterface* candidate_window_handler_; | 337 IBusPanelCandidateWindowHandlerInterface* candidate_window_handler_; |
326 IBusPanelPropertyHandlerInterface* property_handler_; | 338 IBusPanelPropertyHandlerInterface* property_handler_; |
327 | 339 |
328 scoped_refptr<dbus::ExportedObject> exported_object_; | 340 scoped_refptr<dbus::ExportedObject> exported_object_; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 dbus::Bus* bus) { | 375 dbus::Bus* bus) { |
364 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) { | 376 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) { |
365 return new IBusPanelServiceImpl(bus); | 377 return new IBusPanelServiceImpl(bus); |
366 } else { | 378 } else { |
367 return new IBusPanelServiceStubImpl(); | 379 return new IBusPanelServiceStubImpl(); |
368 } | 380 } |
369 } | 381 } |
370 | 382 |
371 } // namespace ibus | 383 } // namespace ibus |
372 } // namespace chromeos | 384 } // namespace chromeos |
OLD | NEW |