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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_ui_controller.cc

Issue 952023002: Credential Manager API: pop up the new "Manage accounts" bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix the test Created 5 years, 9 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/ui/passwords/manage_passwords_ui_controller.h" 5 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/browsing_data/browsing_data_helper.h" 9 #include "chrome/browser/browsing_data/browsing_data_helper.h"
10 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 10 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 DCHECK_EQ(password_manager::ui::BLACKLIST_STATE, state()); 248 DCHECK_EQ(password_manager::ui::BLACKLIST_STATE, state());
249 password_manager::PasswordStore* password_store = 249 password_manager::PasswordStore* password_store =
250 GetPasswordStore(web_contents()); 250 GetPasswordStore(web_contents());
251 DCHECK(GetCurrentForms().front()->blacklisted_by_user); 251 DCHECK(GetCurrentForms().front()->blacklisted_by_user);
252 if (password_store) 252 if (password_store)
253 password_store->RemoveLogin(*GetCurrentForms().front()); 253 password_store->RemoveLogin(*GetCurrentForms().front());
254 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); 254 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE);
255 UpdateBubbleAndIconVisibility(); 255 UpdateBubbleAndIconVisibility();
256 } 256 }
257 257
258 void ManagePasswordsUIController::ManageAccounts() {
259 DCHECK_EQ(password_manager::ui::AUTO_SIGNIN_STATE, state());
260 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE);
261 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true);
262 UpdateBubbleAndIconVisibility();
263 }
264
258 void ManagePasswordsUIController::DidNavigateMainFrame( 265 void ManagePasswordsUIController::DidNavigateMainFrame(
259 const content::LoadCommittedDetails& details, 266 const content::LoadCommittedDetails& details,
260 const content::FrameNavigateParams& params) { 267 const content::FrameNavigateParams& params) {
261 // Don't react to in-page (fragment) navigations. 268 // Don't react to in-page (fragment) navigations.
262 if (details.is_in_page) 269 if (details.is_in_page)
263 return; 270 return;
264 271
265 // Don't do anything if a navigation occurs before a user could reasonably 272 // Don't do anything if a navigation occurs before a user could reasonably
266 // interact with the password bubble. 273 // interact with the password bubble.
267 if (Elapsed() < base::TimeDelta::FromSeconds(1)) 274 if (Elapsed() < base::TimeDelta::FromSeconds(1))
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 } else { 308 } else {
302 icon->SetState(state()); 309 icon->SetState(state());
303 } 310 }
304 } 311 }
305 312
306 void ManagePasswordsUIController::OnBubbleShown() { 313 void ManagePasswordsUIController::OnBubbleShown() {
307 should_pop_up_bubble_ = false; 314 should_pop_up_bubble_ = false;
308 } 315 }
309 316
310 void ManagePasswordsUIController::OnBubbleHidden() { 317 void ManagePasswordsUIController::OnBubbleHidden() {
311 password_manager::ui::State next_state = state(); 318 if (state() == password_manager::ui::CREDENTIAL_REQUEST_STATE ||
312 if (state() == password_manager::ui::CREDENTIAL_REQUEST_STATE) 319 state() == password_manager::ui::CONFIRMATION_STATE ||
313 next_state = password_manager::ui::MANAGE_STATE; 320 state() == password_manager::ui::AUTO_SIGNIN_STATE) {
314 else if (state() == password_manager::ui::CONFIRMATION_STATE) 321 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE);
315 next_state = password_manager::ui::MANAGE_STATE;
316 else if (state() == password_manager::ui::AUTO_SIGNIN_STATE)
317 next_state = password_manager::ui::INACTIVE_STATE;
318
319 if (next_state != state()) {
320 if (next_state == password_manager::ui::INACTIVE_STATE)
321 passwords_data_.OnInactive();
322 else
323 passwords_data_.TransitionToState(next_state);
324 UpdateBubbleAndIconVisibility(); 322 UpdateBubbleAndIconVisibility();
325 } 323 }
326 } 324 }
327 325
328 void ManagePasswordsUIController::ShowBubbleWithoutUserInteraction() { 326 void ManagePasswordsUIController::ShowBubbleWithoutUserInteraction() {
329 DCHECK(should_pop_up_bubble_); 327 DCHECK(should_pop_up_bubble_);
330 #if !defined(OS_ANDROID) 328 #if !defined(OS_ANDROID)
331 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); 329 Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
332 if (!browser || browser->toolbar_model()->input_in_progress()) 330 if (!browser || browser->toolbar_model()->input_in_progress())
333 return; 331 return;
334 if (state() == password_manager::ui::PENDING_PASSWORD_STATE && 332 if (state() == password_manager::ui::PENDING_PASSWORD_STATE &&
335 !password_bubble_experiment::ShouldShowBubble( 333 !password_bubble_experiment::ShouldShowBubble(
336 browser->profile()->GetPrefs())) 334 browser->profile()->GetPrefs()))
337 return; 335 return;
338 CommandUpdater* updater = browser->command_controller()->command_updater(); 336 CommandUpdater* updater = browser->command_controller()->command_updater();
339 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); 337 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE);
340 #endif 338 #endif
341 } 339 }
342 340
343 void ManagePasswordsUIController::WebContentsDestroyed() { 341 void ManagePasswordsUIController::WebContentsDestroyed() {
344 password_manager::PasswordStore* password_store = 342 password_manager::PasswordStore* password_store =
345 GetPasswordStore(web_contents()); 343 GetPasswordStore(web_contents());
346 if (password_store) 344 if (password_store)
347 password_store->RemoveObserver(this); 345 password_store->RemoveObserver(this);
348 } 346 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698