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

Unified Diff: components/proximity_auth/webui/proximity_auth_webui_handler.h

Issue 1264703003: Implement debugging local unlock keys in chrome://proximity-auth. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + fixes Created 5 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 side-by-side diff with in-line comments
Download patch
Index: components/proximity_auth/webui/proximity_auth_webui_handler.h
diff --git a/components/proximity_auth/webui/proximity_auth_webui_handler.h b/components/proximity_auth/webui/proximity_auth_webui_handler.h
index 70e9894c50a4c2f3c22cbccfa065a2dcc93190c6..ce6f3b695852172fab787432fa43c06e266eab47 100644
--- a/components/proximity_auth/webui/proximity_auth_webui_handler.h
+++ b/components/proximity_auth/webui/proximity_auth_webui_handler.h
@@ -7,6 +7,9 @@
#include "base/memory/weak_ptr.h"
#include "base/values.h"
+#include "components/proximity_auth/authenticator.h"
+#include "components/proximity_auth/client_observer.h"
+#include "components/proximity_auth/connection_observer.h"
#include "components/proximity_auth/cryptauth/cryptauth_client.h"
#include "components/proximity_auth/cryptauth/cryptauth_device_manager.h"
#include "components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h"
@@ -21,11 +24,20 @@ class ListValue;
namespace proximity_auth {
+class Authenticator;
+class BluetoothConnection;
+class Connection;
+class ClientImpl;
+struct RemoteStatusUpdate;
+class SecureContext;
+
// Handles messages from the chrome://proximity-auth page.
class ProximityAuthWebUIHandler : public content::WebUIMessageHandler,
public LogBuffer::Observer,
public CryptAuthEnrollmentManager::Observer,
- public CryptAuthDeviceManager::Observer {
+ public CryptAuthDeviceManager::Observer,
+ public ConnectionObserver,
+ public ClientObserver {
public:
// |delegate| is not owned and must outlive this instance.
explicit ProximityAuthWebUIHandler(ProximityAuthUIDelegate* delegate);
@@ -53,9 +65,10 @@ class ProximityAuthWebUIHandler : public content::WebUIMessageHandler,
void GetLogMessages(const base::ListValue* args);
void ClearLogBuffer(const base::ListValue* args);
void FindEligibleUnlockDevices(const base::ListValue* args);
- void GetSyncStates(const base::ListValue* args);
+ void GetLocalState(const base::ListValue* args);
void ForceEnrollment(const base::ListValue* args);
void ForceDeviceSync(const base::ListValue* args);
+ void ToggleConnection(const base::ListValue* args);
// Initializes CryptAuth managers, used for development purposes.
void InitGCMManager();
@@ -69,12 +82,53 @@ class ProximityAuthWebUIHandler : public content::WebUIMessageHandler,
void OnFoundEligibleUnlockDevices(
const cryptauth::FindEligibleUnlockDevicesResponse& response);
+ // Called when the key agreement of PSK of the remote device completes.
+ void OnPSKDerived(const cryptauth::ExternalDeviceInfo& unlock_key,
+ const std::string& persistent_symmetric_key);
+
+ // Callbacks for bluetooth_util::SeekDeviceByAddress().
+ void OnSeekedDeviceByAddress();
+ void OnSeekedDeviceByAddressError(const std::string& error_message);
+
+ // Callback when |authenticator_| completes authentication.
+ void OnAuthenticationResult(Authenticator::Result result,
+ scoped_ptr<SecureContext> secure_context);
+
+ // Creates the client which parses status updates.
+ void CreateStatusUpdateClient();
+
+ // Returns the active connection, whether it's owned the |this| instance or
+ // |client_|.
+ Connection* GetConnection();
+
+ // Converts an ExternalDeviceInfo proto to a JSON dictionary used in
+ // JavaScript.
+ scoped_ptr<base::DictionaryValue> ExternalDeviceInfoToDictionary(
+ const cryptauth::ExternalDeviceInfo& device_info);
+
+ // Converts an IneligibleDevice proto to a JSON dictionary used in JavaScript.
+ scoped_ptr<base::DictionaryValue> IneligibleDeviceToDictionary(
+ const cryptauth::IneligibleDevice& ineligible_device);
+
+ // ConnectionObserver:
+ void OnConnectionStatusChanged(Connection* connection,
+ Connection::Status old_status,
+ Connection::Status new_status) override;
+ void OnMessageReceived(const Connection& connection,
+ const WireMessage& message) override;
+
+ // ClientObserver:
+ void OnRemoteStatusUpdate(const RemoteStatusUpdate& status_update) override;
+
// Returns the current enrollment state that can be used as a JSON object.
scoped_ptr<base::DictionaryValue> GetEnrollmentStateDictionary();
// Returns the current device sync state that can be used as a JSON object.
scoped_ptr<base::DictionaryValue> GetDeviceSyncStateDictionary();
+ // Returns the current unlock keys that can be used as a JSON object.
+ scoped_ptr<base::ListValue> GetUnlockKeysList();
+
// The delegate used to fetch dependencies. Must outlive this instance.
ProximityAuthUIDelegate* delegate_;
@@ -84,11 +138,26 @@ class ProximityAuthWebUIHandler : public content::WebUIMessageHandler,
// We only support one concurrent API call.
scoped_ptr<CryptAuthClient> cryptauth_client_;
+ // True if the WebContents backing the WebUI has been initialized.
+ bool web_contents_initialized_;
+
+ // Member variables related to CryptAuth debugging.
// TODO(tengs): These members are temporarily used for development.
scoped_ptr<PrefService> pref_service;
scoped_ptr<CryptAuthGCMManager> gcm_manager_;
scoped_ptr<CryptAuthEnrollmentManager> enrollment_manager_;
scoped_ptr<CryptAuthDeviceManager> device_manager_;
+ std::string user_public_key_;
+ std::string user_private_key_;
+
+ // Member variables for connecting to and authenticating the remote device.
+ // TODO(tengs): Support multiple simultaenous connections.
+ scoped_ptr<SecureMessageDelegate> secure_message_delegate_;
+ scoped_ptr<BluetoothConnection> bluetooth_connection_;
+ scoped_ptr<Authenticator> authenticator_;
+ scoped_ptr<SecureContext> secure_context_;
+ scoped_ptr<ClientImpl> client_;
+ scoped_ptr<RemoteStatusUpdate> last_remote_status_update_;
base::WeakPtrFactory<ProximityAuthWebUIHandler> weak_ptr_factory_;

Powered by Google App Engine
This is Rietveld 408576698