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

Side by Side Diff: components/os_crypt/kwallet_dbus.cc

Issue 2150543002: OSCrypt supports encryption with KWallet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed build Created 4 years, 5 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <components/os_crypt/kwallet_dbus.h> 5 #include <components/os_crypt/kwallet_dbus.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 return CANNOT_CONTACT; 335 return CANNOT_CONTACT;
336 } 336 }
337 dbus::MessageReader reader(response.get()); 337 dbus::MessageReader reader(response.get());
338 if (!reader.PopBool(success_ptr)) { 338 if (!reader.PopBool(success_ptr)) {
339 LOG(ERROR) << "Error reading response from " << kwalletd_name_ 339 LOG(ERROR) << "Error reading response from " << kwalletd_name_
340 << " (createFolder): " << response->ToString(); 340 << " (createFolder): " << response->ToString();
341 return CANNOT_READ; 341 return CANNOT_READ;
342 } 342 }
343 return SUCCESS; 343 return SUCCESS;
344 } 344 }
345
346 KWalletDBus::Error KWalletDBus::WritePassword(const int handle,
347 const std::string& folder_name,
348 const std::string& key,
349 const std::string& password,
350 const std::string& app_name,
351 bool* const write_success_ptr) {
352 dbus::MethodCall method_call(kKWalletInterface, "writePassword");
353 dbus::MessageWriter builder(&method_call);
354 builder.AppendInt32(handle);
355 builder.AppendString(folder_name);
356 builder.AppendString(key);
357 builder.AppendString(password);
358 builder.AppendString(app_name);
359 std::unique_ptr<dbus::Response> response(kwallet_proxy_->CallMethodAndBlock(
360 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
361 if (!response.get()) {
Lei Zhang 2016/07/20 01:08:26 No need for .get() here, ditto on line 390, and 41
cfroussios 2016/07/20 15:22:47 Done.
362 LOG(ERROR) << "Error contacting << " << kwalletd_name_
Lei Zhang 2016/07/20 01:08:26 did you want the extra "<< " in the string? Ditto
cfroussios 2016/07/20 15:22:47 Done.
363 << " (writePassword)";
364 return CANNOT_CONTACT;
365 }
366 dbus::MessageReader reader(response.get());
367 int return_code;
368 if (!reader.PopInt32(&return_code)) {
369 LOG(ERROR) << "Error reading response from " << kwalletd_name_
370 << " (writePassword): " << response->ToString();
371 return CANNOT_READ;
372 }
373 *write_success_ptr = return_code == 0;
374 return SUCCESS;
375 }
376
377 KWalletDBus::Error KWalletDBus::ReadPassword(const int handle,
378 const std::string& folder_name,
379 const std::string& key,
380 const std::string& app_name,
381 std::string* const password_ptr) {
382 dbus::MethodCall method_call(kKWalletInterface, "readPassword");
383 dbus::MessageWriter builder(&method_call);
384 builder.AppendInt32(handle);
385 builder.AppendString(folder_name);
386 builder.AppendString(key);
387 builder.AppendString(app_name);
388 std::unique_ptr<dbus::Response> response(kwallet_proxy_->CallMethodAndBlock(
389 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
390 if (!response.get()) {
391 LOG(ERROR) << "Error contacting << " << kwalletd_name_ << " (readPassword)";
392 return CANNOT_CONTACT;
393 }
394 dbus::MessageReader reader(response.get());
395 if (!reader.PopString(password_ptr)) {
396 LOG(ERROR) << "Error reading response from " << kwalletd_name_
397 << " (readPassword): " << response->ToString();
398 return CANNOT_READ;
399 }
400 return SUCCESS;
401 }
402
403 KWalletDBus::Error KWalletDBus::Close(const int handle,
404 const bool force,
405 const std::string& app_name,
406 bool* success_ptr) {
407 dbus::MethodCall method_call(kKWalletInterface, "close");
408 dbus::MessageWriter builder(&method_call);
409 builder.AppendInt32(handle);
410 builder.AppendBool(force);
411 builder.AppendString(app_name);
412 std::unique_ptr<dbus::Response> response(kwallet_proxy_->CallMethodAndBlock(
413 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
414 if (!response.get()) {
415 LOG(ERROR) << "Error contacting << " << kwalletd_name_ << " (close)";
416 return CANNOT_CONTACT;
417 }
418 dbus::MessageReader reader(response.get());
419 int return_code = 1;
420 if (!reader.PopInt32(&return_code)) {
421 LOG(ERROR) << "Error reading response from " << kwalletd_name_
422 << " (close): " << response->ToString();
423 return CANNOT_READ;
424 }
425 *success_ptr = return_code == 0;
426 return SUCCESS;
427 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698