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

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

Issue 1402363013: Update location bar bubble/icon behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/timer/timer.h" 7 #include "base/timer/timer.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 if (is_fullscreen) 933 if (is_fullscreen)
934 manage_passwords_bubble_->set_parent_window(web_contents->GetNativeView()); 934 manage_passwords_bubble_->set_parent_window(web_contents->GetNativeView());
935 935
936 views::BubbleDelegateView::CreateBubble(manage_passwords_bubble_); 936 views::BubbleDelegateView::CreateBubble(manage_passwords_bubble_);
937 937
938 // Adjust for fullscreen after creation as it relies on the content size. 938 // Adjust for fullscreen after creation as it relies on the content size.
939 if (is_fullscreen) { 939 if (is_fullscreen) {
940 manage_passwords_bubble_->AdjustForFullscreen( 940 manage_passwords_bubble_->AdjustForFullscreen(
941 browser_view->GetBoundsInScreen()); 941 browser_view->GetBoundsInScreen());
942 } 942 }
943 if (reason == ManagePasswordsBubbleModel::AUTOMATIC) 943
944 manage_passwords_bubble_->GetWidget()->ShowInactive(); 944 manage_passwords_bubble_->ShowForReason(
945 else 945 reason == ManagePasswordsBubbleModel::AUTOMATIC ? AUTOMATIC
946 manage_passwords_bubble_->GetWidget()->Show(); 946 : USER_ACTION);
947 } 947 }
948 948
949 // static 949 // static
950 void ManagePasswordsBubbleView::CloseBubble() { 950 void ManagePasswordsBubbleView::CloseBubble() {
951 if (manage_passwords_bubble_) 951 if (manage_passwords_bubble_)
952 manage_passwords_bubble_->Close(); 952 manage_passwords_bubble_->Close();
953 } 953 }
954 954
955 // static 955 // static
956 void ManagePasswordsBubbleView::ActivateBubble() { 956 void ManagePasswordsBubbleView::ActivateBubble() {
(...skipping 14 matching lines...) Expand all
971 model_(web_contents, reason), 971 model_(web_contents, reason),
972 anchor_view_(anchor_view), 972 anchor_view_(anchor_view),
973 initially_focused_view_(NULL) { 973 initially_focused_view_(NULL) {
974 // Compensate for built-in vertical padding in the anchor view's image. 974 // Compensate for built-in vertical padding in the anchor view's image.
975 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); 975 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0));
976 976
977 const int top_margin = ShouldShowCloseButton() ? margins().top() 977 const int top_margin = ShouldShowCloseButton() ? margins().top()
978 : views::kPanelVertMargin; 978 : views::kPanelVertMargin;
979 set_margins(gfx::Insets(top_margin, views::kPanelHorizMargin, 979 set_margins(gfx::Insets(top_margin, views::kPanelHorizMargin,
980 views::kPanelVertMargin, views::kPanelHorizMargin)); 980 views::kPanelVertMargin, views::kPanelHorizMargin));
981 if (anchor_view)
982 anchor_view->SetActive(true);
983 mouse_handler_.reset(new WebContentMouseHandler(this)); 981 mouse_handler_.reset(new WebContentMouseHandler(this));
984 } 982 }
985 983
986 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() { 984 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() {
987 if (manage_passwords_bubble_ == this) 985 if (manage_passwords_bubble_ == this)
988 manage_passwords_bubble_ = NULL; 986 manage_passwords_bubble_ = NULL;
989 } 987 }
990 988
991 views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { 989 views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() {
992 return initially_focused_view_; 990 return initially_focused_view_;
993 } 991 }
994 992
995 void ManagePasswordsBubbleView::Init() { 993 void ManagePasswordsBubbleView::Init() {
996 views::FillLayout* layout = new views::FillLayout(); 994 views::FillLayout* layout = new views::FillLayout();
997 SetLayoutManager(layout); 995 SetLayoutManager(layout);
998 996
999 Refresh(); 997 Refresh();
1000 } 998 }
1001 999
1002 void ManagePasswordsBubbleView::Close() { 1000 void ManagePasswordsBubbleView::Close() {
1003 mouse_handler_.reset(); 1001 mouse_handler_.reset();
1004 LocationBarBubbleDelegateView::Close(); 1002 LocationBarBubbleDelegateView::Close();
1005 } 1003 }
1006 1004
1007 void ManagePasswordsBubbleView::OnWidgetClosing(views::Widget* /*widget*/) {
1008 if (anchor_view_)
1009 anchor_view_->SetActive(false);
1010 }
1011
1012 bool ManagePasswordsBubbleView::ShouldShowCloseButton() const { 1005 bool ManagePasswordsBubbleView::ShouldShowCloseButton() const {
1013 return model_.state() == password_manager::ui::PENDING_PASSWORD_STATE; 1006 return model_.state() == password_manager::ui::PENDING_PASSWORD_STATE;
1014 } 1007 }
1015 1008
1016 void ManagePasswordsBubbleView::Refresh() { 1009 void ManagePasswordsBubbleView::Refresh() {
1017 RemoveAllChildViews(true); 1010 RemoveAllChildViews(true);
1018 initially_focused_view_ = NULL; 1011 initially_focused_view_ = NULL;
1019 if (model_.state() == password_manager::ui::PENDING_PASSWORD_STATE) { 1012 if (model_.state() == password_manager::ui::PENDING_PASSWORD_STATE) {
1020 AddChildView(new PendingView(this)); 1013 AddChildView(new PendingView(this));
1021 } else if (model_.state() == 1014 } else if (model_.state() ==
1022 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) { 1015 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) {
1023 AddChildView(new UpdatePendingView(this)); 1016 AddChildView(new UpdatePendingView(this));
1024 } else if (model_.state() == password_manager::ui::CONFIRMATION_STATE) { 1017 } else if (model_.state() == password_manager::ui::CONFIRMATION_STATE) {
1025 AddChildView(new SaveConfirmationView(this)); 1018 AddChildView(new SaveConfirmationView(this));
1026 } else if (model_.state() == password_manager::ui::CREDENTIAL_REQUEST_STATE) { 1019 } else if (model_.state() == password_manager::ui::CREDENTIAL_REQUEST_STATE) {
1027 AddChildView(new AccountChooserView(this)); 1020 AddChildView(new AccountChooserView(this));
1028 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) { 1021 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) {
1029 AddChildView(new AutoSigninView(this)); 1022 AddChildView(new AutoSigninView(this));
1030 } else { 1023 } else {
1031 AddChildView(new ManageView(this)); 1024 AddChildView(new ManageView(this));
1032 } 1025 }
1033 GetLayoutManager()->Layout(this); 1026 GetLayoutManager()->Layout(this);
1034 } 1027 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698