Commit 5b3a81d6 authored by Tomasz Garbus's avatar Tomasz Garbus Committed by Commit Bot

Add CredentialManager instance to PasswordController

This CL adds an instance of CredentialManager to PasswordController:
 * In PasswordController's Init function, it is checked whether the
   feature is enabled, and then (and only then), CredentialManager is
   instantiated and owned by PasswordController. CredentialManager then
   registers a script command callback for "credentials" command prefix.
 * CredentialManager instance owned by PasswordController is destroyed
   in PasswordController::detach(), which is invoked when WebState is
   being destroyed. CredentialManager then removes script command
   callback.

Bug: 435048
Change-Id: Ibad9c09f8c8f0868d940bd0912a861b6120dd1c8
Reviewed-on: https://chromium-review.googlesource.com/652227
Commit-Queue: Tomasz Garbus <tgarbus@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501258}
parent cacc3a58
......@@ -33,6 +33,8 @@
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/experimental_flags.h"
#include "ios/chrome/browser/infobars/infobar_manager_impl.h"
#include "ios/chrome/browser/passwords/credential_manager.h"
#include "ios/chrome/browser/passwords/credential_manager_features.h"
#import "ios/chrome/browser/passwords/ios_chrome_save_password_infobar_delegate.h"
#import "ios/chrome/browser/passwords/ios_chrome_update_password_infobar_delegate.h"
#import "ios/chrome/browser/passwords/js_password_manager.h"
......@@ -261,6 +263,7 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) {
std::unique_ptr<PasswordGenerationManager> passwordGenerationManager_;
std::unique_ptr<PasswordManagerClient> passwordManagerClient_;
std::unique_ptr<PasswordManagerDriver> passwordManagerDriver_;
std::unique_ptr<credential_manager::CredentialManager> credentialManager_;
PasswordGenerationAgent* passwordGenerationAgent_;
__weak JsPasswordManager* passwordJsManager_;
......@@ -318,6 +321,13 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) {
webStateObserverBridge_.reset(
new web::WebStateObserverBridge(webState, self));
sent_request_to_store_ = NO;
if (base::FeatureList::IsEnabled(
credential_manager::features::kCredentialManager)) {
credentialManager_ =
std::make_unique<credential_manager::CredentialManager>(
passwordManagerClient_.get(), webState_);
}
}
return self;
}
......@@ -351,6 +361,7 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) {
passwordManagerDriver_.reset();
passwordManager_.reset();
passwordManagerClient_.reset();
credentialManager_.reset();
}
#pragma mark -
......
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