Skip to content

Commit

Permalink
Add WebViewTrustedVaultClient to //ios/web_view
Browse files Browse the repository at this point in the history
This is a no op implementation for now.

Bug: 1266130
Change-Id: If3f953ad724a674274afa5d90906a3401f487ca7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3257940
Commit-Queue: John Wu <jzw@chromium.org>
Reviewed-by: Hiroshi Ichikawa <ichikawa@chromium.org>
Cr-Commit-Position: refs/heads/main@{#938381}
  • Loading branch information
John Wu authored and Chromium LUCI CQ committed Nov 4, 2021
1 parent 7f38849 commit 1c54d1a
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ios/web_view/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ source_set("web_view_sources") {
"internal/sync/web_view_sync_invalidations_service_factory.mm",
"internal/sync/web_view_sync_service_factory.h",
"internal/sync/web_view_sync_service_factory.mm",
"internal/sync/web_view_trusted_vault_client.h",
"internal/sync/web_view_trusted_vault_client.mm",
"internal/translate/cwv_translation_controller.mm",
"internal/translate/cwv_translation_controller_internal.h",
"internal/translate/cwv_translation_language.mm",
Expand Down
1 change: 1 addition & 0 deletions ios/web_view/internal/sync/web_view_sync_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class WebViewSyncClient : public browser_sync::BrowserSyncClient {

std::unique_ptr<browser_sync::ProfileSyncComponentsFactoryImpl>
component_factory_;
std::unique_ptr<syncer::TrustedVaultClient> trusted_vault_client_;
};

} // namespace ios_web_view
Expand Down
4 changes: 3 additions & 1 deletion ios/web_view/internal/sync/web_view_sync_client.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#import "ios/web_view/internal/sync/web_view_model_type_store_service_factory.h"
#import "ios/web_view/internal/sync/web_view_profile_invalidation_provider_factory.h"
#import "ios/web_view/internal/sync/web_view_sync_invalidations_service_factory.h"
#include "ios/web_view/internal/sync/web_view_trusted_vault_client.h"
#include "ios/web_view/internal/webdata_services/web_view_web_data_service_wrapper_factory.h"

#if !defined(__has_feature) || !__has_feature(objc_arc)
Expand Down Expand Up @@ -107,6 +108,7 @@
profile_web_data_service_, account_web_data_service_,
profile_password_store_, account_password_store_,
/*bookmark_sync_service=*/nullptr);
trusted_vault_client_ = std::make_unique<WebViewTrustedVaultClient>();
}

WebViewSyncClient::~WebViewSyncClient() {}
Expand Down Expand Up @@ -180,7 +182,7 @@
}

syncer::TrustedVaultClient* WebViewSyncClient::GetTrustedVaultClient() {
return nullptr;
return trusted_vault_client_.get();
}

scoped_refptr<syncer::ExtensionsActivity>
Expand Down
47 changes: 47 additions & 0 deletions ios/web_view/internal/sync/web_view_trusted_vault_client.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_WEB_VIEW_INTERNAL_SYNC_WEB_VIEW_TRUSTED_VAULT_CLIENT_H_
#define IOS_WEB_VIEW_INTERNAL_SYNC_WEB_VIEW_TRUSTED_VAULT_CLIENT_H_

#include "components/sync/driver/trusted_vault_client.h"

namespace ios_web_view {

// ChromeWebView implementation of TrustedVaultClient.
// This class uses the Chrome trusted vault service to store the shared keys.
class WebViewTrustedVaultClient : public syncer::TrustedVaultClient {
public:
explicit WebViewTrustedVaultClient();
~WebViewTrustedVaultClient() override;

// TrustedVaultClient implementation.
void AddObserver(Observer* observer) override;
void RemoveObserver(Observer* observer) override;
void FetchKeys(
const CoreAccountInfo& account_info,
base::OnceCallback<void(const std::vector<std::vector<uint8_t>>&)>
callback) override;
void StoreKeys(const std::string& gaia_id,
const std::vector<std::vector<uint8_t>>& keys,
int last_key_version) override;
void MarkLocalKeysAsStale(const CoreAccountInfo& account_info,
base::OnceCallback<void(bool)> callback) override;
void GetIsRecoverabilityDegraded(
const CoreAccountInfo& account_info,
base::OnceCallback<void(bool)> callback) override;
void AddTrustedRecoveryMethod(const std::string& gaia_id,
const std::vector<uint8_t>& public_key,
int method_type_hint,
base::OnceClosure callback) override;

// Not copyable or movable
WebViewTrustedVaultClient(const WebViewTrustedVaultClient&) = delete;
WebViewTrustedVaultClient& operator=(const WebViewTrustedVaultClient&) =
delete;
};

} // namespace ios_web_view

#endif // IOS_WEB_VIEW_INTERNAL_SYNC_WEB_VIEW_TRUSTED_VAULT_CLIENT_H_
65 changes: 65 additions & 0 deletions ios/web_view/internal/sync/web_view_trusted_vault_client.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ios/web_view/internal/sync/web_view_trusted_vault_client.h"

#include "base/callback.h"
#include "base/notreached.h"
#include "components/signin/public/identity_manager/account_info.h"

#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif

namespace ios_web_view {

WebViewTrustedVaultClient::WebViewTrustedVaultClient() {}

WebViewTrustedVaultClient::~WebViewTrustedVaultClient() = default;

void WebViewTrustedVaultClient::AddObserver(Observer* observer) {
// TODO(crbug.com/1266130): Implement this.
}

void WebViewTrustedVaultClient::RemoveObserver(Observer* observer) {
// TODO(crbug.com/1266130): Implement this.
}

void WebViewTrustedVaultClient::FetchKeys(
const CoreAccountInfo& account_info,
base::OnceCallback<void(const std::vector<std::vector<uint8_t>>&)>
callback) {
// TODO(crbug.com/1266130): Implement this.
}

void WebViewTrustedVaultClient::StoreKeys(
const std::string& gaia_id,
const std::vector<std::vector<uint8_t>>& keys,
int last_key_version) {
// Not used on iOS.
NOTREACHED();
}

void WebViewTrustedVaultClient::MarkLocalKeysAsStale(
const CoreAccountInfo& account_info,
base::OnceCallback<void(bool)> callback) {
// TODO(crbug.com/1266130): Implement this.
}

void WebViewTrustedVaultClient::GetIsRecoverabilityDegraded(
const CoreAccountInfo& account_info,
base::OnceCallback<void(bool)> callback) {
// TODO(crbug.com/1266130): Implement this.
}

void WebViewTrustedVaultClient::AddTrustedRecoveryMethod(
const std::string& gaia_id,
const std::vector<uint8_t>& public_key,
int method_type_hint,
base::OnceClosure callback) {
// Not used on iOS.
NOTREACHED();
}

} // namespace ios_web_view

0 comments on commit 1c54d1a

Please sign in to comment.