Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: chrome/browser/password_manager/chrome_password_manager_client.cc

Issue 2472133004: Creating class for processing of keypress events. (Closed)
Patch Set: fix Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 UserDataKey(), 137 UserDataKey(),
138 new ChromePasswordManagerClient(contents, autofill_client)); 138 new ChromePasswordManagerClient(contents, autofill_client));
139 } 139 }
140 140
141 ChromePasswordManagerClient::ChromePasswordManagerClient( 141 ChromePasswordManagerClient::ChromePasswordManagerClient(
142 content::WebContents* web_contents, 142 content::WebContents* web_contents,
143 autofill::AutofillClient* autofill_client) 143 autofill::AutofillClient* autofill_client)
144 : content::WebContentsObserver(web_contents), 144 : content::WebContentsObserver(web_contents),
145 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), 145 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())),
146 password_manager_(this), 146 password_manager_(this),
147 password_reuse_detection_manager_(this),
147 driver_factory_(nullptr), 148 driver_factory_(nullptr),
148 credential_manager_impl_(web_contents, this), 149 credential_manager_impl_(web_contents, this),
149 password_manager_client_bindings_(web_contents, this), 150 password_manager_client_bindings_(web_contents, this),
150 observer_(nullptr), 151 observer_(nullptr),
151 credentials_filter_(this, 152 credentials_filter_(this,
152 base::Bind(&GetSyncService, profile_), 153 base::Bind(&GetSyncService, profile_),
153 base::Bind(&GetSigninManager, profile_)) { 154 base::Bind(&GetSigninManager, profile_)) {
154 ContentPasswordManagerDriverFactory::CreateForWebContents(web_contents, this, 155 ContentPasswordManagerDriverFactory::CreateForWebContents(web_contents, this,
155 autofill_client); 156 autofill_client);
156 driver_factory_ = 157 driver_factory_ =
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 249 }
249 #else 250 #else
250 if (form_to_save->IsBlacklisted()) 251 if (form_to_save->IsBlacklisted())
251 return false; 252 return false;
252 253
253 if (update_password) { 254 if (update_password) {
254 UpdatePasswordInfoBarDelegate::Create(web_contents(), 255 UpdatePasswordInfoBarDelegate::Create(web_contents(),
255 std::move(form_to_save)); 256 std::move(form_to_save));
256 return true; 257 return true;
257 } 258 }
258 SavePasswordInfoBarDelegate::Create(web_contents(), 259 SavePasswordInfoBarDelegate::Create(web_contents(), std::move(form_to_save));
259 std::move(form_to_save));
260 #endif // !BUILDFLAG(ANDROID_JAVA_UI) 260 #endif // !BUILDFLAG(ANDROID_JAVA_UI)
261 return true; 261 return true;
262 } 262 }
263 263
264 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( 264 bool ChromePasswordManagerClient::PromptUserToChooseCredentials(
265 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms, 265 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms,
266 const GURL& origin, 266 const GURL& origin,
267 const CredentialsCallback& callback) { 267 const CredentialsCallback& callback) {
268 // Set up an intercept callback if the prompt is zero-clickable (e.g. just one 268 // Set up an intercept callback if the prompt is zero-clickable (e.g. just one
269 // form provided). 269 // form provided).
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin, 370 manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin,
371 federated_matches); 371 federated_matches);
372 #endif 372 #endif
373 } 373 }
374 374
375 void ChromePasswordManagerClient::HidePasswordGenerationPopup() { 375 void ChromePasswordManagerClient::HidePasswordGenerationPopup() {
376 if (popup_controller_) 376 if (popup_controller_)
377 popup_controller_->HideAndDestroy(); 377 popup_controller_->HideAndDestroy();
378 } 378 }
379 379
380 void ChromePasswordManagerClient::DidNavigateMainFrame(
381 const content::LoadCommittedDetails& details,
382 const content::FrameNavigateParams& params) {
383 password_reuse_detection_manager_.DidNavigateMainFrame();
384 web_contents()->GetRenderViewHost()->GetWidget()->RemoveInputEventObserver(
vabr (Chromium) 2016/12/23 17:14:10 Why is it needed to remove and immediately add its
dvadym 2016/12/23 17:45:20 I've added a comment with explanation.
vabr (Chromium) 2016/12/23 21:24:24 Acknowledged.
385 this);
386 web_contents()->GetRenderViewHost()->GetWidget()->AddInputEventObserver(this);
387 }
388
389 void ChromePasswordManagerClient::OnInputEvent(
390 const blink::WebInputEvent& event) {
391 if (event.type != blink::WebInputEvent::Char)
392 return;
393 const blink::WebKeyboardEvent& key_event =
394 static_cast<const blink::WebKeyboardEvent&>(event);
395 password_reuse_detection_manager_.OnKeyPressed(key_event.text);
396 }
397
380 PrefService* ChromePasswordManagerClient::GetPrefs() { 398 PrefService* ChromePasswordManagerClient::GetPrefs() {
381 return profile_->GetPrefs(); 399 return profile_->GetPrefs();
382 } 400 }
383 401
384 password_manager::PasswordStore* 402 password_manager::PasswordStore* ChromePasswordManagerClient::GetPasswordStore()
vabr (Chromium) 2016/12/23 17:14:10 nit: Also here and on lines 408-409, please revert
dvadym 2016/12/23 17:45:20 Done.
385 ChromePasswordManagerClient::GetPasswordStore() const { 403 const {
386 // Always use EXPLICIT_ACCESS as the password manager checks IsOffTheRecord 404 // Always use EXPLICIT_ACCESS as the password manager checks IsOffTheRecord
387 // itself when it shouldn't access the PasswordStore. 405 // itself when it shouldn't access the PasswordStore.
388 // TODO(gcasto): Is is safe to change this to 406 // TODO(gcasto): Is is safe to change this to
389 // ServiceAccessType::IMPLICIT_ACCESS? 407 // ServiceAccessType::IMPLICIT_ACCESS?
390 return PasswordStoreFactory::GetForProfile( 408 return PasswordStoreFactory::GetForProfile(profile_,
391 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); 409 ServiceAccessType::EXPLICIT_ACCESS).get();
392 } 410 }
393 411
394 password_manager::PasswordSyncState 412 password_manager::PasswordSyncState
395 ChromePasswordManagerClient::GetPasswordSyncState() const { 413 ChromePasswordManagerClient::GetPasswordSyncState() const {
396 const browser_sync::ProfileSyncService* sync_service = 414 const browser_sync::ProfileSyncService* sync_service =
397 ProfileSyncServiceFactory::GetForProfile(profile_); 415 ProfileSyncServiceFactory::GetForProfile(profile_);
398 return password_manager_util::GetPasswordSyncState(sync_service); 416 return password_manager_util::GetPasswordSyncState(sync_service);
399 } 417 }
400 418
401 bool ChromePasswordManagerClient::WasLastNavigationHTTPError() const { 419 bool ChromePasswordManagerClient::WasLastNavigationHTTPError() const {
402 DCHECK(web_contents()); 420 DCHECK(web_contents());
403 421
404 std::unique_ptr<password_manager::BrowserSavePasswordProgressLogger> logger; 422 std::unique_ptr<password_manager::BrowserSavePasswordProgressLogger> logger;
405 if (log_manager_->IsLoggingActive()) { 423 if (log_manager_->IsLoggingActive()) {
406 logger.reset(new password_manager::BrowserSavePasswordProgressLogger( 424 logger.reset(new password_manager::BrowserSavePasswordProgressLogger(
407 log_manager_.get())); 425 log_manager_.get()));
408 logger->LogMessage( 426 logger->LogMessage(Logger::STRING_WAS_LAST_NAVIGATION_HTTP_ERROR_METHOD);
409 Logger::STRING_WAS_LAST_NAVIGATION_HTTP_ERROR_METHOD);
410 } 427 }
411 428
412 content::NavigationEntry* entry = 429 content::NavigationEntry* entry =
413 web_contents()->GetController().GetVisibleEntry(); 430 web_contents()->GetController().GetVisibleEntry();
414 if (!entry) 431 if (!entry)
415 return false; 432 return false;
416 int http_status_code = entry->GetHttpStatusCode(); 433 int http_status_code = entry->GetHttpStatusCode();
417 434
418 if (logger) 435 if (logger)
419 logger->LogNumber(Logger::STRING_HTTP_STATUS_CODE, http_status_code); 436 logger->LogNumber(Logger::STRING_HTTP_STATUS_CODE, http_status_code);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 ChromePasswordManagerClient::FromWebContents(web_contents); 630 ChromePasswordManagerClient::FromWebContents(web_contents);
614 631
615 // Try to bind to the driver, but if driver is not available for this render 632 // Try to bind to the driver, but if driver is not available for this render
616 // frame host, the request will be just dropped. This will cause the message 633 // frame host, the request will be just dropped. This will cause the message
617 // pipe to be closed, which will raise a connection error on the peer side. 634 // pipe to be closed, which will raise a connection error on the peer side.
618 if (!instance) 635 if (!instance)
619 return; 636 return;
620 637
621 instance->credential_manager_impl_.BindRequest(std::move(request)); 638 instance->credential_manager_impl_.BindRequest(std::move(request));
622 } 639 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698