Commit 2bb23a65 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] Adding IOSTrustedVaultClient

Adding IOSTrustedVaultClient using ChromeTrustedVaultService class.
Replacing FileBasedTrustedVaultClient for IOSTrustedVaultClient in
IOSChromeSyncClient.

Related:
 - crrev.com/c/2116079 ChromeTrustedVaultService
 - crrev.com/i/2774364 ChromeTrustedVaultServiceImpl
=> crrev.com/c/2118054 IOSTrustedVaultClient

Bug: 1019685
Change-Id: I3c9640a52da4132fbad7d5cb19d94a8e05c81c5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2118054
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759634}
parent c2362009
...@@ -17,6 +17,8 @@ source_set("sync") { ...@@ -17,6 +17,8 @@ source_set("sync") {
"ios_chrome_sync_client.mm", "ios_chrome_sync_client.mm",
"ios_chrome_synced_tab_delegate.h", "ios_chrome_synced_tab_delegate.h",
"ios_chrome_synced_tab_delegate.mm", "ios_chrome_synced_tab_delegate.mm",
"ios_trusted_vault_client.h",
"ios_trusted_vault_client.mm",
"ios_user_event_service_factory.cc", "ios_user_event_service_factory.cc",
"ios_user_event_service_factory.h", "ios_user_event_service_factory.h",
"model_type_store_service_factory.cc", "model_type_store_service_factory.cc",
...@@ -53,6 +55,7 @@ source_set("sync") { ...@@ -53,6 +55,7 @@ source_set("sync") {
"//components/send_tab_to_self", "//components/send_tab_to_self",
"//components/sessions", "//components/sessions",
"//components/signin/public/base", "//components/signin/public/base",
"//components/signin/public/identity_manager",
"//components/sync", "//components/sync",
"//components/sync_device_info", "//components/sync_device_info",
"//components/sync_preferences", "//components/sync_preferences",
...@@ -82,6 +85,8 @@ source_set("sync") { ...@@ -82,6 +85,8 @@ source_set("sync") {
"//ios/chrome/browser/webdata_services", "//ios/chrome/browser/webdata_services",
"//ios/chrome/common", "//ios/chrome/common",
"//ios/components/webui:url_constants", "//ios/components/webui:url_constants",
"//ios/public/provider/chrome/browser",
"//ios/public/provider/chrome/browser/signin",
"//ios/web", "//ios/web",
"//ios/web/public/session", "//ios/web/public/session",
"//net", "//net",
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "components/reading_list/core/reading_list_model.h" #include "components/reading_list/core/reading_list_model.h"
#include "components/sync/base/report_unrecoverable_error.h" #include "components/sync/base/report_unrecoverable_error.h"
#include "components/sync/base/sync_base_switches.h" #include "components/sync/base/sync_base_switches.h"
#include "components/sync/driver/file_based_trusted_vault_client.h"
#include "components/sync/driver/sync_api_component_factory.h" #include "components/sync/driver/sync_api_component_factory.h"
#include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_util.h" #include "components/sync/driver/sync_util.h"
...@@ -53,6 +52,7 @@ ...@@ -53,6 +52,7 @@
#include "ios/chrome/browser/signin/identity_manager_factory.h" #include "ios/chrome/browser/signin/identity_manager_factory.h"
#include "ios/chrome/browser/sync/consent_auditor_factory.h" #include "ios/chrome/browser/sync/consent_auditor_factory.h"
#include "ios/chrome/browser/sync/device_info_sync_service_factory.h" #include "ios/chrome/browser/sync/device_info_sync_service_factory.h"
#include "ios/chrome/browser/sync/ios_trusted_vault_client.h"
#include "ios/chrome/browser/sync/ios_user_event_service_factory.h" #include "ios/chrome/browser/sync/ios_user_event_service_factory.h"
#include "ios/chrome/browser/sync/model_type_store_service_factory.h" #include "ios/chrome/browser/sync/model_type_store_service_factory.h"
#include "ios/chrome/browser/sync/send_tab_to_self_sync_service_factory.h" #include "ios/chrome/browser/sync/send_tab_to_self_sync_service_factory.h"
...@@ -69,9 +69,6 @@ ...@@ -69,9 +69,6 @@
namespace { namespace {
const base::FilePath::CharType kTrustedVaultFilename[] =
FILE_PATH_LITERAL("Trusted Vault");
syncer::ModelTypeSet GetDisabledTypesFromCommandLine() { syncer::ModelTypeSet GetDisabledTypesFromCommandLine() {
std::string disabled_types_str = std::string disabled_types_str =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
...@@ -113,9 +110,7 @@ IOSChromeSyncClient::IOSChromeSyncClient(ChromeBrowserState* browser_state) ...@@ -113,9 +110,7 @@ IOSChromeSyncClient::IOSChromeSyncClient(ChromeBrowserState* browser_state)
/*account_password_store=*/nullptr, /*account_password_store=*/nullptr,
ios::BookmarkSyncServiceFactory::GetForBrowserState(browser_state_)); ios::BookmarkSyncServiceFactory::GetForBrowserState(browser_state_));
// TODO(crbug.com/1019685): Instantiate a specific client for ios. trusted_vault_client_ = std::make_unique<IOSTrustedVaultClient>();
trusted_vault_client_ = std::make_unique<syncer::FileBasedTrustedVaultClient>(
browser_state_->GetStatePath().Append(kTrustedVaultFilename));
} }
IOSChromeSyncClient::~IOSChromeSyncClient() {} IOSChromeSyncClient::~IOSChromeSyncClient() {}
......
// Copyright 2020 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_CHROME_BROWSER_SYNC_IOS_TRUSTED_VAULT_CLIENT_H_
#define IOS_CHROME_BROWSER_SYNC_IOS_TRUSTED_VAULT_CLIENT_H_
#include "components/sync/driver/trusted_vault_client.h"
// iOS version of TrustedVaultClient. This class uses the Chrome trusted vault
// service to store the shared keys.
class IOSTrustedVaultClient : public syncer::TrustedVaultClient {
public:
IOSTrustedVaultClient();
~IOSTrustedVaultClient() override;
// TrustedVaultClient implementation.
std::unique_ptr<Subscription> AddKeysChangedObserver(
const base::RepeatingClosure& closure) 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 RemoveAllStoredKeys() override;
void MarkKeysAsStale(const CoreAccountInfo& account_info,
base::OnceCallback<void(bool)> callback) override;
// Not copyable or movable
IOSTrustedVaultClient(const IOSTrustedVaultClient&) = delete;
IOSTrustedVaultClient& operator=(const IOSTrustedVaultClient&) = delete;
};
#endif // IOS_CHROME_BROWSER_SYNC_IOS_TRUSTED_VAULT_CLIENT_H_
// Copyright 2020 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/chrome/browser/sync/ios_trusted_vault_client.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#include "ios/public/provider/chrome/browser/signin/chrome_identity_service.h"
#include "ios/public/provider/chrome/browser/signin/chrome_trusted_vault_service.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
IOSTrustedVaultClient::IOSTrustedVaultClient() {}
IOSTrustedVaultClient::~IOSTrustedVaultClient() = default;
std::unique_ptr<IOSTrustedVaultClient::Subscription>
IOSTrustedVaultClient::AddKeysChangedObserver(
const base::RepeatingClosure& closure) {
// TODO(crbug.com/1019685): observers need to be implemented.
return nullptr;
}
void IOSTrustedVaultClient::FetchKeys(
const CoreAccountInfo& account_info,
base::OnceCallback<void(const std::vector<std::vector<uint8_t>>&)>
callback) {
ios::ChromeBrowserProvider* browser_provider =
ios::GetChromeBrowserProvider();
ios::ChromeIdentityService* identity_service =
browser_provider->GetChromeIdentityService();
ChromeIdentity* identity =
identity_service->GetIdentityWithGaiaID(account_info.gaia);
ios::ChromeTrustedVaultService* trusted_vault_service =
browser_provider->GetChromeTrustedVaultService();
trusted_vault_service->FetchKeys(identity, std::move(callback));
}
void IOSTrustedVaultClient::StoreKeys(
const std::string& gaia_id,
const std::vector<std::vector<uint8_t>>& keys,
int last_key_version) {
// Not used on iOS.
NOTREACHED();
}
void IOSTrustedVaultClient::RemoveAllStoredKeys() {
// Not used on iOS.
NOTREACHED();
}
void IOSTrustedVaultClient::MarkKeysAsStale(
const CoreAccountInfo& account_info,
base::OnceCallback<void(bool)> callback) {
// TODO(crbug.com/1019685): needs implementation.
std::move(callback).Run(false);
}
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