| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/passwords/password_controller.h" | 5 #import "ios/chrome/browser/passwords/password_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 32 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 33 #include "ios/chrome/browser/experimental_flags.h" | 33 #include "ios/chrome/browser/experimental_flags.h" |
| 34 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" | 34 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" |
| 35 #import "ios/chrome/browser/passwords/ios_chrome_save_password_infobar_delegate.
h" | 35 #import "ios/chrome/browser/passwords/ios_chrome_save_password_infobar_delegate.
h" |
| 36 #import "ios/chrome/browser/passwords/js_password_manager.h" | 36 #import "ios/chrome/browser/passwords/js_password_manager.h" |
| 37 #import "ios/chrome/browser/passwords/password_generation_agent.h" | 37 #import "ios/chrome/browser/passwords/password_generation_agent.h" |
| 38 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" | 38 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" |
| 39 #include "ios/web/public/url_scheme_util.h" | 39 #include "ios/web/public/url_scheme_util.h" |
| 40 #import "ios/web/public/web_state/js/crw_js_injection_receiver.h" | 40 #import "ios/web/public/web_state/js/crw_js_injection_receiver.h" |
| 41 #import "ios/web/public/web_state/web_state.h" | 41 #import "ios/web/public/web_state/web_state.h" |
| 42 #import "ios/web/public/web_state/web_state_observer_bridge.h" | |
| 43 #include "url/gurl.h" | 42 #include "url/gurl.h" |
| 44 | 43 |
| 45 using password_manager::PasswordFormManager; | 44 using password_manager::PasswordFormManager; |
| 46 using password_manager::PasswordGenerationManager; | 45 using password_manager::PasswordGenerationManager; |
| 47 using password_manager::PasswordManager; | 46 using password_manager::PasswordManager; |
| 48 using password_manager::PasswordManagerClient; | 47 using password_manager::PasswordManagerClient; |
| 49 using password_manager::PasswordManagerDriver; | 48 using password_manager::PasswordManagerDriver; |
| 50 | 49 |
| 51 @interface PasswordController ()<CRWWebStateObserver, FormSuggestionProvider> | 50 @interface PasswordController ()<FormSuggestionProvider> |
| 52 | 51 |
| 53 // Parses the |jsonString| which contatins the password forms found on a web | 52 // Parses the |jsonString| which contatins the password forms found on a web |
| 54 // page to populate the |forms| vector. | 53 // page to populate the |forms| vector. |
| 55 - (void)getPasswordForms:(std::vector<autofill::PasswordForm>*)forms | 54 - (void)getPasswordForms:(std::vector<autofill::PasswordForm>*)forms |
| 56 fromFormsJSON:(NSString*)jsonString | 55 fromFormsJSON:(NSString*)jsonString |
| 57 pageURL:(const GURL&)pageURL; | 56 pageURL:(const GURL&)pageURL; |
| 58 | 57 |
| 59 // Processes the JSON string returned as a result of extracting the submitted | 58 // Processes the JSON string returned as a result of extracting the submitted |
| 60 // form data and populates |form|. Returns YES on success. NO otherwise. | 59 // form data and populates |form|. Returns YES on success. NO otherwise. |
| 61 // |form| cannot be nil. | 60 // |form| cannot be nil. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 236 |
| 238 // The pending form data. | 237 // The pending form data. |
| 239 scoped_ptr<autofill::PasswordFormFillData> formData_; | 238 scoped_ptr<autofill::PasswordFormFillData> formData_; |
| 240 | 239 |
| 241 // Bridge to observe WebState from Objective-C. | 240 // Bridge to observe WebState from Objective-C. |
| 242 scoped_ptr<web::WebStateObserverBridge> webStateObserverBridge_; | 241 scoped_ptr<web::WebStateObserverBridge> webStateObserverBridge_; |
| 243 } | 242 } |
| 244 | 243 |
| 245 - (instancetype)initWithWebState:(web::WebState*)webState | 244 - (instancetype)initWithWebState:(web::WebState*)webState |
| 246 passwordsUiDelegate:(id<PasswordsUiDelegate>)UIDelegate { | 245 passwordsUiDelegate:(id<PasswordsUiDelegate>)UIDelegate { |
| 246 self = [self initWithWebState:webState |
| 247 passwordsUiDelegate:UIDelegate |
| 248 client:nullptr]; |
| 249 return self; |
| 250 } |
| 251 |
| 252 - (instancetype)initWithWebState:(web::WebState*)webState |
| 253 passwordsUiDelegate:(id<PasswordsUiDelegate>)UIDelegate |
| 254 client:(scoped_ptr<PasswordManagerClient>) |
| 255 passwordManagerClient { |
| 247 DCHECK(webState); | 256 DCHECK(webState); |
| 248 self = [super init]; | 257 self = [super init]; |
| 249 if (self) { | 258 if (self) { |
| 250 webStateObserverBridge_.reset( | 259 webStateObserverBridge_.reset( |
| 251 new web::WebStateObserverBridge(webState, self)); | 260 new web::WebStateObserverBridge(webState, self)); |
| 252 passwordManagerClient_.reset(new IOSChromePasswordManagerClient(self)); | 261 if (passwordManagerClient) |
| 262 passwordManagerClient_ = std::move(passwordManagerClient); |
| 263 else |
| 264 passwordManagerClient_.reset(new IOSChromePasswordManagerClient(self)); |
| 253 passwordManager_.reset(new PasswordManager(passwordManagerClient_.get())); | 265 passwordManager_.reset(new PasswordManager(passwordManagerClient_.get())); |
| 254 passwordManagerDriver_.reset(new IOSChromePasswordManagerDriver(self)); | 266 passwordManagerDriver_.reset(new IOSChromePasswordManagerDriver(self)); |
| 255 if (experimental_flags::IsPasswordGenerationEnabled() && | 267 if (experimental_flags::IsPasswordGenerationEnabled() && |
| 256 !passwordManagerClient_->IsOffTheRecord()) { | 268 !passwordManagerClient_->IsOffTheRecord()) { |
| 257 passwordGenerationManager_.reset(new PasswordGenerationManager( | 269 passwordGenerationManager_.reset(new PasswordGenerationManager( |
| 258 passwordManagerClient_.get(), passwordManagerDriver_.get())); | 270 passwordManagerClient_.get(), passwordManagerDriver_.get())); |
| 259 passwordGenerationAgent_.reset([[PasswordGenerationAgent alloc] | 271 passwordGenerationAgent_.reset([[PasswordGenerationAgent alloc] |
| 260 initWithWebState:webState | 272 initWithWebState:webState |
| 261 passwordManager:passwordManager_.get() | 273 passwordManager:passwordManager_.get() |
| 262 passwordManagerDriver:passwordManagerDriver_.get() | 274 passwordManagerDriver:passwordManagerDriver_.get() |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 | 808 |
| 797 - (PasswordManager*)passwordManager { | 809 - (PasswordManager*)passwordManager { |
| 798 return passwordManager_.get(); | 810 return passwordManager_.get(); |
| 799 } | 811 } |
| 800 | 812 |
| 801 - (JsPasswordManager*)passwordJsManager { | 813 - (JsPasswordManager*)passwordJsManager { |
| 802 return passwordJsManager_; | 814 return passwordJsManager_; |
| 803 } | 815 } |
| 804 | 816 |
| 805 @end | 817 @end |
| OLD | NEW |