Commit d7bfd5bb authored by James Hawkins's avatar James Hawkins Committed by Commit Bot

Proximity Auth: Remove kMultiDeviceApi flagging from ProxAuthWebuiHandler.

R=hansberry@chromium.org

Bug: 899324
Test: none
Change-Id: Iac6aacb1b40608d261d6c13b12fd37bfd6b0df8f
Reviewed-on: https://chromium-review.googlesource.com/c/1325393Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Commit-Queue: James Hawkins <jhawkins@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606865}
parent f513b7c0
......@@ -263,23 +263,12 @@ WebUIController* NewWebUI<proximity_auth::ProximityAuthUI>(WebUI* web_ui,
const GURL& url) {
content::BrowserContext* browser_context =
web_ui->GetWebContents()->GetBrowserContext();
// TODO(crbug.com/848956): Only pass DeviceSyncClient once Smart Lock has
// fully migrated to the DeviceSync API.
return new proximity_auth::ProximityAuthUI(
web_ui,
base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi)
? nullptr
: chromeos::EasyUnlockServiceFactory::GetForBrowserContext(
browser_context)
->proximity_auth_client(),
base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi)
? chromeos::device_sync::DeviceSyncClientFactory::GetForProfile(
Profile::FromBrowserContext(browser_context))
: nullptr,
base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi)
? chromeos::secure_channel::SecureChannelClientProvider::GetInstance()
->GetClient()
: nullptr);
chromeos::device_sync::DeviceSyncClientFactory::GetForProfile(
Profile::FromBrowserContext(browser_context)),
chromeos::secure_channel::SecureChannelClientProvider::GetInstance()
->GetClient());
}
#endif
......
......@@ -23,7 +23,6 @@ namespace proximity_auth {
ProximityAuthUI::ProximityAuthUI(
content::WebUI* web_ui,
ProximityAuthClient* proximity_auth_client,
chromeos::device_sync::DeviceSyncClient* device_sync_client,
chromeos::secure_channel::SecureChannelClient* secure_channel_client)
: ui::MojoWebUIController(web_ui, true /* enable_chrome_send */) {
......@@ -47,7 +46,7 @@ ProximityAuthUI::ProximityAuthUI(
web_ui->GetWebContents()->GetBrowserContext();
content::WebUIDataSource::Add(browser_context, source);
web_ui->AddMessageHandler(std::make_unique<ProximityAuthWebUIHandler>(
proximity_auth_client, device_sync_client, secure_channel_client));
device_sync_client, secure_channel_client));
AddHandlerToRegistry(base::BindRepeating(
&ProximityAuthUI::BindMultiDeviceSetup, base::Unretained(this)));
}
......
......@@ -23,16 +23,13 @@ class SecureChannelClient;
namespace proximity_auth {
class ProximityAuthClient;
// The WebUI controller for chrome://proximity-auth.
class ProximityAuthUI : public ui::MojoWebUIController {
public:
// Note: |web_ui| and |proximity_auth_client| are not owned by this instance
// and must outlive this instance.
// Note: |web_ui| is not owned by this instance and must outlive this
// instance.
ProximityAuthUI(
content::WebUI* web_ui,
ProximityAuthClient* proximity_auth_client,
chromeos::device_sync::DeviceSyncClient* device_sync_client,
chromeos::secure_channel::SecureChannelClient* secure_channel_client);
~ProximityAuthUI() override;
......
......@@ -15,11 +15,6 @@
#include "chromeos/components/proximity_auth/remote_device_life_cycle.h"
#include "chromeos/services/device_sync/public/cpp/device_sync_client.h"
#include "chromeos/services/secure_channel/public/cpp/client/secure_channel_client.h"
#include "components/cryptauth/connection_observer.h"
#include "components/cryptauth/cryptauth_client.h"
#include "components/cryptauth/cryptauth_device_manager.h"
#include "components/cryptauth/cryptauth_enrollment_manager.h"
#include "components/cryptauth/cryptauth_gcm_manager.h"
#include "components/cryptauth/network_request_error.h"
#include "components/cryptauth/remote_device_ref.h"
#include "content/public/browser/web_ui_message_handler.h"
......@@ -28,11 +23,6 @@ namespace base {
class ListValue;
}
namespace cryptauth {
class ExternalDeviceInfo;
class RemoteDeviceLoader;
} // namespace cryptauth
namespace proximity_auth {
class RemoteDeviceLifeCycle;
......@@ -42,14 +32,11 @@ struct RemoteStatusUpdate;
class ProximityAuthWebUIHandler
: public content::WebUIMessageHandler,
public LogBuffer::Observer,
public cryptauth::CryptAuthEnrollmentManager::Observer,
public cryptauth::CryptAuthDeviceManager::Observer,
public chromeos::device_sync::DeviceSyncClient::Observer,
public RemoteDeviceLifeCycle::Observer,
public MessengerObserver {
public:
ProximityAuthWebUIHandler(
ProximityAuthClient* proximity_auth_client,
chromeos::device_sync::DeviceSyncClient* device_sync_client,
chromeos::secure_channel::SecureChannelClient* secure_channel_client);
~ProximityAuthWebUIHandler() override;
......@@ -62,16 +49,6 @@ class ProximityAuthWebUIHandler
void OnLogMessageAdded(const LogBuffer::LogMessage& log_message) override;
void OnLogBufferCleared() override;
// CryptAuthEnrollmentManager::Observer:
void OnEnrollmentStarted() override;
void OnEnrollmentFinished(bool success) override;
// CryptAuthDeviceManager::Observer:
void OnSyncStarted() override;
void OnSyncFinished(cryptauth::CryptAuthDeviceManager::SyncResult sync_result,
cryptauth::CryptAuthDeviceManager::DeviceChangeResult
device_change_result) override;
// chromeos::device_sync::DeviceSyncClient::Observer:
void OnEnrollmentFinished() override;
void OnNewDevicesSynced() override;
......@@ -87,29 +64,11 @@ class ProximityAuthWebUIHandler
void ForceDeviceSync(const base::ListValue* args);
void ToggleConnection(const base::ListValue* args);
// Initializes CryptAuth managers, used for development purposes.
void InitGCMManager();
void InitEnrollmentManager();
void InitDeviceManager();
void OnCryptAuthClientError(cryptauth::NetworkRequestError error);
void OnEasyUnlockToggled(const cryptauth::ToggleEasyUnlockResponse& response);
void OnFoundEligibleUnlockDevices(
const cryptauth::FindEligibleUnlockDevicesResponse& response);
// Called when the RemoteDevice is loaded so we can create a connection.
void OnRemoteDevicesLoaded(const cryptauth::RemoteDeviceList& remote_devices);
void StartRemoteDeviceLifeCycle(cryptauth::RemoteDeviceRef remote_device);
void CleanUpRemoteDeviceLifeCycle();
std::unique_ptr<base::DictionaryValue> ExternalDeviceInfoToDictionary(
const cryptauth::ExternalDeviceInfo& device_info);
std::unique_ptr<base::DictionaryValue> RemoteDeviceToDictionary(
const cryptauth::RemoteDeviceRef& remote_device);
std::unique_ptr<base::DictionaryValue> IneligibleDeviceToDictionary(
const cryptauth::IneligibleDevice& ineligible_device);
// RemoteDeviceLifeCycle::Observer:
void OnLifeCycleStateChanged(RemoteDeviceLifeCycle::State old_state,
......@@ -144,22 +103,11 @@ class ProximityAuthWebUIHandler
std::unique_ptr<base::ListValue> synced_devices);
std::unique_ptr<base::Value> GetTruncatedLocalDeviceId();
// These two methods cannot be used if the chromeos::features::kMultiDeviceApi
// flag is enabled.
std::unique_ptr<base::DictionaryValue> GetEnrollmentStateDictionary();
std::unique_ptr<base::DictionaryValue> GetDeviceSyncStateDictionary();
std::unique_ptr<base::ListValue> GetRemoteDevicesList();
// The delegate used to fetch dependencies. Must outlive this instance.
ProximityAuthClient* proximity_auth_client_;
chromeos::device_sync::DeviceSyncClient* device_sync_client_;
chromeos::secure_channel::SecureChannelClient* secure_channel_client_;
std::unique_ptr<cryptauth::CryptAuthClientFactory> cryptauth_client_factory_;
// We only support one concurrent API call.
std::unique_ptr<cryptauth::CryptAuthClient> cryptauth_client_;
// True if we get a message from the loaded WebContents to know that it is
// initialized, and we can inject JavaScript.
......@@ -167,7 +115,6 @@ class ProximityAuthWebUIHandler
// Member variables for connecting to and authenticating the remote device.
// TODO(tengs): Support multiple simultaenous connections.
std::unique_ptr<cryptauth::RemoteDeviceLoader> remote_device_loader_;
base::Optional<cryptauth::RemoteDeviceRef> selected_remote_device_;
std::unique_ptr<RemoteDeviceLifeCycle> life_cycle_;
std::unique_ptr<RemoteStatusUpdate> last_remote_status_update_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment