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

Side by Side Diff: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc

Issue 1759453002: Convert location bar bubble delegates to bubble dialog delegates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix ImmersiveFullscreenController Created 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views/passwords/manage_passwords_bubble_view.h" 5 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/timer/timer.h" 9 #include "base/timer/timer.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 timer_.Start(FROM_HERE, GetTimeout(), this, &AutoSigninView::OnTimer); 257 timer_.Start(FROM_HERE, GetTimeout(), this, &AutoSigninView::OnTimer);
258 } 258 }
259 259
260 void ManagePasswordsBubbleView::AutoSigninView::OnWidgetClosing( 260 void ManagePasswordsBubbleView::AutoSigninView::OnWidgetClosing(
261 views::Widget* widget) { 261 views::Widget* widget) {
262 observed_browser_.RemoveAll(); 262 observed_browser_.RemoveAll();
263 } 263 }
264 264
265 void ManagePasswordsBubbleView::AutoSigninView::OnTimer() { 265 void ManagePasswordsBubbleView::AutoSigninView::OnTimer() {
266 parent_->model()->OnAutoSignInToastTimeout(); 266 parent_->model()->OnAutoSignInToastTimeout();
267 parent_->Close(); 267 parent_->CloseBubble();
268 } 268 }
269 269
270 // ManagePasswordsBubbleView::PendingView ------------------------------------- 270 // ManagePasswordsBubbleView::PendingView -------------------------------------
271 271
272 // A view offering the user the ability to save credentials. Contains a 272 // A view offering the user the ability to save credentials. Contains a
273 // single ManagePasswordItemsView, along with a "Save Passwords" button 273 // single ManagePasswordItemsView, along with a "Save Passwords" button
274 // and a "Never" button. 274 // and a "Never" button.
275 class ManagePasswordsBubbleView::PendingView 275 class ManagePasswordsBubbleView::PendingView
276 : public views::View, 276 : public views::View,
277 public views::ButtonListener, 277 public views::ButtonListener,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 void ManagePasswordsBubbleView::PendingView::ButtonPressed( 359 void ManagePasswordsBubbleView::PendingView::ButtonPressed(
360 views::Button* sender, 360 views::Button* sender,
361 const ui::Event& event) { 361 const ui::Event& event) {
362 if (sender == save_button_) 362 if (sender == save_button_)
363 parent_->model()->OnSaveClicked(); 363 parent_->model()->OnSaveClicked();
364 else if (sender == never_button_) 364 else if (sender == never_button_)
365 parent_->model()->OnNeverForThisSiteClicked(); 365 parent_->model()->OnNeverForThisSiteClicked();
366 else 366 else
367 NOTREACHED(); 367 NOTREACHED();
368 368
369 parent_->Close(); 369 parent_->CloseBubble();
370 } 370 }
371 371
372 void ManagePasswordsBubbleView::PendingView::StyledLabelLinkClicked( 372 void ManagePasswordsBubbleView::PendingView::StyledLabelLinkClicked(
373 views::StyledLabel* label, 373 views::StyledLabel* label,
374 const gfx::Range& range, 374 const gfx::Range& range,
375 int event_flags) { 375 int event_flags) {
376 DCHECK_EQ(range, parent_->model()->title_brand_link_range()); 376 DCHECK_EQ(range, parent_->model()->title_brand_link_range());
377 parent_->model()->OnBrandLinkClicked(); 377 parent_->model()->OnBrandLinkClicked();
378 } 378 }
379 379
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 462 }
463 463
464 ManagePasswordsBubbleView::ManageView::~ManageView() { 464 ManagePasswordsBubbleView::ManageView::~ManageView() {
465 } 465 }
466 466
467 void ManagePasswordsBubbleView::ManageView::ButtonPressed( 467 void ManagePasswordsBubbleView::ManageView::ButtonPressed(
468 views::Button* sender, 468 views::Button* sender,
469 const ui::Event& event) { 469 const ui::Event& event) {
470 DCHECK(sender == done_button_); 470 DCHECK(sender == done_button_);
471 parent_->model()->OnDoneClicked(); 471 parent_->model()->OnDoneClicked();
472 parent_->Close(); 472 parent_->CloseBubble();
473 } 473 }
474 474
475 void ManagePasswordsBubbleView::ManageView::LinkClicked(views::Link* source, 475 void ManagePasswordsBubbleView::ManageView::LinkClicked(views::Link* source,
476 int event_flags) { 476 int event_flags) {
477 DCHECK_EQ(source, manage_link_); 477 DCHECK_EQ(source, manage_link_);
478 parent_->model()->OnManageLinkClicked(); 478 parent_->model()->OnManageLinkClicked();
479 parent_->Close(); 479 parent_->CloseBubble();
480 } 480 }
481 481
482 // ManagePasswordsBubbleView::SaveConfirmationView ---------------------------- 482 // ManagePasswordsBubbleView::SaveConfirmationView ----------------------------
483 483
484 // A view confirming to the user that a password was saved and offering a link 484 // A view confirming to the user that a password was saved and offering a link
485 // to the Google account manager. 485 // to the Google account manager.
486 class ManagePasswordsBubbleView::SaveConfirmationView 486 class ManagePasswordsBubbleView::SaveConfirmationView
487 : public views::View, 487 : public views::View,
488 public views::ButtonListener, 488 public views::ButtonListener,
489 public views::StyledLabelListener { 489 public views::StyledLabelListener {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 538
539 ManagePasswordsBubbleView::SaveConfirmationView::~SaveConfirmationView() { 539 ManagePasswordsBubbleView::SaveConfirmationView::~SaveConfirmationView() {
540 } 540 }
541 541
542 void ManagePasswordsBubbleView::SaveConfirmationView::StyledLabelLinkClicked( 542 void ManagePasswordsBubbleView::SaveConfirmationView::StyledLabelLinkClicked(
543 views::StyledLabel* label, 543 views::StyledLabel* label,
544 const gfx::Range& range, 544 const gfx::Range& range,
545 int event_flags) { 545 int event_flags) {
546 DCHECK_EQ(range, parent_->model()->save_confirmation_link_range()); 546 DCHECK_EQ(range, parent_->model()->save_confirmation_link_range());
547 parent_->model()->OnManageLinkClicked(); 547 parent_->model()->OnManageLinkClicked();
548 parent_->Close(); 548 parent_->CloseBubble();
549 } 549 }
550 550
551 void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed( 551 void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed(
552 views::Button* sender, const ui::Event& event) { 552 views::Button* sender, const ui::Event& event) {
553 DCHECK_EQ(sender, ok_button_); 553 DCHECK_EQ(sender, ok_button_);
554 parent_->model()->OnOKClicked(); 554 parent_->model()->OnOKClicked();
555 parent_->Close(); 555 parent_->CloseBubble();
556 } 556 }
557 557
558 // ManagePasswordsBubbleView::WebContentMouseHandler -------------------------- 558 // ManagePasswordsBubbleView::WebContentMouseHandler --------------------------
559 559
560 // The class listens for WebContentsView events and notifies the bubble if the 560 // The class listens for WebContentsView events and notifies the bubble if the
561 // view was clicked on or received keystrokes. 561 // view was clicked on or received keystrokes.
562 class ManagePasswordsBubbleView::WebContentMouseHandler 562 class ManagePasswordsBubbleView::WebContentMouseHandler
563 : public ui::EventHandler { 563 : public ui::EventHandler {
564 public: 564 public:
565 explicit WebContentMouseHandler(ManagePasswordsBubbleView* bubble); 565 explicit WebContentMouseHandler(ManagePasswordsBubbleView* bubble);
(...skipping 17 matching lines...) Expand all
583 event_monitor_ = views::EventMonitor::CreateWindowMonitor( 583 event_monitor_ = views::EventMonitor::CreateWindowMonitor(
584 this, web_contents->GetTopLevelNativeWindow()); 584 this, web_contents->GetTopLevelNativeWindow());
585 } 585 }
586 586
587 void ManagePasswordsBubbleView::WebContentMouseHandler::OnKeyEvent( 587 void ManagePasswordsBubbleView::WebContentMouseHandler::OnKeyEvent(
588 ui::KeyEvent* event) { 588 ui::KeyEvent* event) {
589 content::WebContents* web_contents = bubble_->web_contents(); 589 content::WebContents* web_contents = bubble_->web_contents();
590 content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); 590 content::RenderViewHost* rvh = web_contents->GetRenderViewHost();
591 if ((event->key_code() == ui::VKEY_ESCAPE || 591 if ((event->key_code() == ui::VKEY_ESCAPE ||
592 rvh->IsFocusedElementEditable()) && event->type() == ui::ET_KEY_PRESSED) 592 rvh->IsFocusedElementEditable()) && event->type() == ui::ET_KEY_PRESSED)
593 bubble_->Close(); 593 bubble_->CloseBubble();
594 } 594 }
595 595
596 void ManagePasswordsBubbleView::WebContentMouseHandler::OnMouseEvent( 596 void ManagePasswordsBubbleView::WebContentMouseHandler::OnMouseEvent(
597 ui::MouseEvent* event) { 597 ui::MouseEvent* event) {
598 if (event->type() == ui::ET_MOUSE_PRESSED) 598 if (event->type() == ui::ET_MOUSE_PRESSED)
599 bubble_->Close(); 599 bubble_->CloseBubble();
600 } 600 }
601 601
602 void ManagePasswordsBubbleView::WebContentMouseHandler::OnTouchEvent( 602 void ManagePasswordsBubbleView::WebContentMouseHandler::OnTouchEvent(
603 ui::TouchEvent* event) { 603 ui::TouchEvent* event) {
604 if (event->type() == ui::ET_TOUCH_PRESSED) 604 if (event->type() == ui::ET_TOUCH_PRESSED)
605 bubble_->Close(); 605 bubble_->CloseBubble();
606 } 606 }
607 607
608 // ManagePasswordsBubbleView::UpdatePendingView ------------------------------- 608 // ManagePasswordsBubbleView::UpdatePendingView -------------------------------
609 609
610 // A view offering the user the ability to update credentials. Contains a 610 // A view offering the user the ability to update credentials. Contains a
611 // single ManagePasswordItemsView (in case of one credentials) or 611 // single ManagePasswordItemsView (in case of one credentials) or
612 // CredentialsSelectionView otherwise, along with a "Update Passwords" button 612 // CredentialsSelectionView otherwise, along with a "Update Passwords" button
613 // and a rejection button. 613 // and a rejection button.
614 class ManagePasswordsBubbleView::UpdatePendingView 614 class ManagePasswordsBubbleView::UpdatePendingView
615 : public views::View, 615 : public views::View,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 if (selection_view_) { 692 if (selection_view_) {
693 // Multi account case. 693 // Multi account case.
694 parent_->model()->OnUpdateClicked( 694 parent_->model()->OnUpdateClicked(
695 *selection_view_->GetSelectedCredentials()); 695 *selection_view_->GetSelectedCredentials());
696 } else { 696 } else {
697 parent_->model()->OnUpdateClicked(parent_->model()->pending_password()); 697 parent_->model()->OnUpdateClicked(parent_->model()->pending_password());
698 } 698 }
699 } else { 699 } else {
700 parent_->model()->OnNopeUpdateClicked(); 700 parent_->model()->OnNopeUpdateClicked();
701 } 701 }
702 parent_->Close(); 702 parent_->CloseBubble();
703 } 703 }
704 704
705 void ManagePasswordsBubbleView::UpdatePendingView::StyledLabelLinkClicked( 705 void ManagePasswordsBubbleView::UpdatePendingView::StyledLabelLinkClicked(
706 views::StyledLabel* label, 706 views::StyledLabel* label,
707 const gfx::Range& range, 707 const gfx::Range& range,
708 int event_flags) { 708 int event_flags) {
709 DCHECK_EQ(range, parent_->model()->title_brand_link_range()); 709 DCHECK_EQ(range, parent_->model()->title_brand_link_range());
710 parent_->model()->OnBrandLinkClicked(); 710 parent_->model()->OnBrandLinkClicked();
711 } 711 }
712 712
(...skipping 19 matching lines...) Expand all
732 is_fullscreen 732 is_fullscreen
733 ? NULL 733 ? NULL
734 : browser_view->GetLocationBarView()->manage_passwords_icon_view(); 734 : browser_view->GetLocationBarView()->manage_passwords_icon_view();
735 manage_passwords_bubble_ = new ManagePasswordsBubbleView( 735 manage_passwords_bubble_ = new ManagePasswordsBubbleView(
736 web_contents, anchor_view, reason); 736 web_contents, anchor_view, reason);
737 737
738 if (is_fullscreen) 738 if (is_fullscreen)
739 manage_passwords_bubble_->set_parent_window(web_contents->GetNativeView()); 739 manage_passwords_bubble_->set_parent_window(web_contents->GetNativeView());
740 740
741 views::Widget* manage_passwords_bubble_widget = 741 views::Widget* manage_passwords_bubble_widget =
742 views::BubbleDelegateView::CreateBubble(manage_passwords_bubble_); 742 views::BubbleDialogDelegateView::CreateBubble(manage_passwords_bubble_);
743 if (anchor_view) 743 if (anchor_view)
744 manage_passwords_bubble_widget->AddObserver(anchor_view); 744 manage_passwords_bubble_widget->AddObserver(anchor_view);
745 745
746 // Adjust for fullscreen after creation as it relies on the content size. 746 // Adjust for fullscreen after creation as it relies on the content size.
747 if (is_fullscreen) { 747 if (is_fullscreen) {
748 manage_passwords_bubble_->AdjustForFullscreen( 748 manage_passwords_bubble_->AdjustForFullscreen(
749 browser_view->GetBoundsInScreen()); 749 browser_view->GetBoundsInScreen());
750 } 750 }
751 751
752 manage_passwords_bubble_->ShowForReason(reason); 752 manage_passwords_bubble_->ShowForReason(reason);
753 } 753 }
754 754
755 // static 755 // static
756 void ManagePasswordsBubbleView::CloseBubble() { 756 void ManagePasswordsBubbleView::CloseCurrentBubble() {
757 if (manage_passwords_bubble_) 757 if (manage_passwords_bubble_)
758 manage_passwords_bubble_->Close(); 758 manage_passwords_bubble_->CloseBubble();
759 } 759 }
760 760
761 // static 761 // static
762 void ManagePasswordsBubbleView::ActivateBubble() { 762 void ManagePasswordsBubbleView::ActivateBubble() {
763 DCHECK(manage_passwords_bubble_); 763 DCHECK(manage_passwords_bubble_);
764 DCHECK(manage_passwords_bubble_->GetWidget()->IsVisible()); 764 DCHECK(manage_passwords_bubble_->GetWidget()->IsVisible());
765 manage_passwords_bubble_->GetWidget()->Activate(); 765 manage_passwords_bubble_->GetWidget()->Activate();
766 } 766 }
767 767
768 content::WebContents* ManagePasswordsBubbleView::web_contents() const { 768 content::WebContents* ManagePasswordsBubbleView::web_contents() const {
(...skipping 24 matching lines...) Expand all
793 return initially_focused_view_; 793 return initially_focused_view_;
794 } 794 }
795 795
796 void ManagePasswordsBubbleView::Init() { 796 void ManagePasswordsBubbleView::Init() {
797 views::FillLayout* layout = new views::FillLayout(); 797 views::FillLayout* layout = new views::FillLayout();
798 SetLayoutManager(layout); 798 SetLayoutManager(layout);
799 799
800 Refresh(); 800 Refresh();
801 } 801 }
802 802
803 void ManagePasswordsBubbleView::Close() { 803 void ManagePasswordsBubbleView::CloseBubble() {
804 mouse_handler_.reset(); 804 mouse_handler_.reset();
805 LocationBarBubbleDelegateView::Close(); 805 LocationBarBubbleDelegateView::CloseBubble();
806 } 806 }
807 807
808 base::string16 ManagePasswordsBubbleView::GetWindowTitle() const { 808 base::string16 ManagePasswordsBubbleView::GetWindowTitle() const {
809 return model_.title(); 809 return model_.title();
810 } 810 }
811 811
812 bool ManagePasswordsBubbleView::ShouldShowWindowTitle() const { 812 bool ManagePasswordsBubbleView::ShouldShowWindowTitle() const {
813 // Since bubble titles don't support links, fall back to a custom title view 813 // Since bubble titles don't support links, fall back to a custom title view
814 // if we need to show a link. Only use the normal title path if there's no 814 // if we need to show a link. Only use the normal title path if there's no
815 // link. 815 // link.
(...skipping 16 matching lines...) Expand all
832 AddChildView(new SaveConfirmationView(this)); 832 AddChildView(new SaveConfirmationView(this));
833 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) { 833 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) {
834 AddChildView(new AutoSigninView(this)); 834 AddChildView(new AutoSigninView(this));
835 } else { 835 } else {
836 AddChildView(new ManageView(this)); 836 AddChildView(new ManageView(this));
837 } 837 }
838 if (GetWidget()) 838 if (GetWidget())
839 GetWidget()->UpdateWindowTitle(); 839 GetWidget()->UpdateWindowTitle();
840 GetLayoutManager()->Layout(this); 840 GetLayoutManager()->Layout(this);
841 } 841 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698