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 "chrome/browser/password_manager/native_backend_kwallet_x.h" | 5 #include "chrome/browser/password_manager/native_backend_kwallet_x.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/pickle.h" | 11 #include "base/pickle.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "dbus/bus.h" | 16 #include "dbus/bus.h" |
17 #include "dbus/message.h" | 17 #include "dbus/message.h" |
| 18 #include "dbus/object_path.h" |
18 #include "dbus/object_proxy.h" | 19 #include "dbus/object_proxy.h" |
19 #include "grit/chromium_strings.h" | 20 #include "grit/chromium_strings.h" |
20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
21 | 22 |
22 using content::BrowserThread; | 23 using content::BrowserThread; |
23 using webkit::forms::PasswordForm; | 24 using webkit::forms::PasswordForm; |
24 | 25 |
25 // We could localize this string, but then changing your locale would cause | 26 // We could localize this string, but then changing your locale would cause |
26 // you to lose access to all your stored passwords. Maybe best not to do that. | 27 // you to lose access to all your stored passwords. Maybe best not to do that. |
27 const char NativeBackendKWallet::kKWalletFolder[] = "Chrome Form Data"; | 28 const char NativeBackendKWallet::kKWalletFolder[] = "Chrome Form Data"; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // The optional_bus parameter is given when this method is called in tests. | 97 // The optional_bus parameter is given when this method is called in tests. |
97 session_bus_ = optional_bus; | 98 session_bus_ = optional_bus; |
98 } else { | 99 } else { |
99 // Get a (real) connection to the session bus. | 100 // Get a (real) connection to the session bus. |
100 dbus::Bus::Options options; | 101 dbus::Bus::Options options; |
101 options.bus_type = dbus::Bus::SESSION; | 102 options.bus_type = dbus::Bus::SESSION; |
102 options.connection_type = dbus::Bus::PRIVATE; | 103 options.connection_type = dbus::Bus::PRIVATE; |
103 session_bus_ = new dbus::Bus(options); | 104 session_bus_ = new dbus::Bus(options); |
104 } | 105 } |
105 kwallet_proxy_ = | 106 kwallet_proxy_ = |
106 session_bus_->GetObjectProxy(kKWalletServiceName, kKWalletPath); | 107 session_bus_->GetObjectProxy(kKWalletServiceName, |
| 108 dbus::ObjectPath(kKWalletPath)); |
107 // kwalletd may not be running. If we get a temporary failure initializing it, | 109 // kwalletd may not be running. If we get a temporary failure initializing it, |
108 // try to start it and then try again. (Note the short-circuit evaluation.) | 110 // try to start it and then try again. (Note the short-circuit evaluation.) |
109 const InitResult result = InitWallet(); | 111 const InitResult result = InitWallet(); |
110 *success = (result == INIT_SUCCESS || | 112 *success = (result == INIT_SUCCESS || |
111 (result == TEMPORARY_FAIL && | 113 (result == TEMPORARY_FAIL && |
112 StartKWalletd() && InitWallet() == INIT_SUCCESS)); | 114 StartKWalletd() && InitWallet() == INIT_SUCCESS)); |
113 event->Signal(); | 115 event->Signal(); |
114 } | 116 } |
115 | 117 |
116 bool NativeBackendKWallet::StartKWalletd() { | 118 bool NativeBackendKWallet::StartKWalletd() { |
117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
118 // Sadly kwalletd doesn't use DBus activation, so we have to make a call to | 120 // Sadly kwalletd doesn't use DBus activation, so we have to make a call to |
119 // klauncher to start it. | 121 // klauncher to start it. |
120 dbus::ObjectProxy* klauncher = | 122 dbus::ObjectProxy* klauncher = |
121 session_bus_->GetObjectProxy(kKLauncherServiceName, kKLauncherPath); | 123 session_bus_->GetObjectProxy(kKLauncherServiceName, |
| 124 dbus::ObjectPath(kKLauncherPath)); |
122 | 125 |
123 dbus::MethodCall method_call(kKLauncherInterface, | 126 dbus::MethodCall method_call(kKLauncherInterface, |
124 "start_service_by_desktop_name"); | 127 "start_service_by_desktop_name"); |
125 dbus::MessageWriter builder(&method_call); | 128 dbus::MessageWriter builder(&method_call); |
126 std::vector<std::string> empty; | 129 std::vector<std::string> empty; |
127 builder.AppendString("kwalletd"); // serviceName | 130 builder.AppendString("kwalletd"); // serviceName |
128 builder.AppendArrayOfStrings(empty); // urls | 131 builder.AppendArrayOfStrings(empty); // urls |
129 builder.AppendArrayOfStrings(empty); // envs | 132 builder.AppendArrayOfStrings(empty); // envs |
130 builder.AppendString(""); // startup_id | 133 builder.AppendString(""); // startup_id |
131 builder.AppendBool(false); // blind | 134 builder.AppendBool(false); // blind |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 // Each other profile must be able to migrate the shared data as well, | 893 // Each other profile must be able to migrate the shared data as well, |
891 // so we must leave it alone. After a few releases, we'll add code to | 894 // so we must leave it alone. After a few releases, we'll add code to |
892 // delete them, and eventually remove this migration code. | 895 // delete them, and eventually remove this migration code. |
893 // TODO(mdm): follow through with the plan above. | 896 // TODO(mdm): follow through with the plan above. |
894 PasswordStoreX::SetPasswordsUseLocalProfileId(prefs_); | 897 PasswordStoreX::SetPasswordsUseLocalProfileId(prefs_); |
895 } else { | 898 } else { |
896 // We failed to migrate for some reason. Use the old folder name. | 899 // We failed to migrate for some reason. Use the old folder name. |
897 folder_name_ = kKWalletFolder; | 900 folder_name_ = kKWalletFolder; |
898 } | 901 } |
899 } | 902 } |
OLD | NEW |