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

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

Issue 795053003: [Password Manager] Close the bubble when fullscreen state gets change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated Vasilii's review comments. Created 6 years 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 "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_finder.h" 8 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 9 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
11 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" 10 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
12 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 11 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
13 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" 12 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h"
14 #include "chrome/browser/ui/views/frame/browser_view.h" 13 #include "chrome/browser/ui/views/frame/browser_view.h"
15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
16 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" 14 #include "chrome/browser/ui/views/passwords/credentials_item_view.h"
17 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" 15 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h"
18 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" 16 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h"
19 #include "chrome/grit/generated_resources.h" 17 #include "chrome/grit/generated_resources.h"
20 #include "content/public/browser/notification_source.h"
21 #include "content/public/browser/render_view_host.h" 18 #include "content/public/browser/render_view_host.h"
22 #include "content/public/browser/web_contents.h"
23 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
25 #include "ui/views/controls/button/blue_button.h" 21 #include "ui/views/controls/button/blue_button.h"
26 #include "ui/views/controls/button/label_button.h" 22 #include "ui/views/controls/button/label_button.h"
27 #include "ui/views/controls/combobox/combobox.h" 23 #include "ui/views/controls/combobox/combobox.h"
28 #include "ui/views/controls/combobox/combobox_listener.h" 24 #include "ui/views/controls/combobox/combobox_listener.h"
29 #include "ui/views/controls/link.h" 25 #include "ui/views/controls/link.h"
30 #include "ui/views/controls/link_listener.h" 26 #include "ui/views/controls/link_listener.h"
31 #include "ui/views/controls/separator.h" 27 #include "ui/views/controls/separator.h"
32 #include "ui/views/controls/styled_label.h" 28 #include "ui/views/controls/styled_label.h"
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 1010
1015 content::WebContents* ManagePasswordsBubbleView::web_contents() const { 1011 content::WebContents* ManagePasswordsBubbleView::web_contents() const {
1016 return model()->web_contents(); 1012 return model()->web_contents();
1017 } 1013 }
1018 1014
1019 ManagePasswordsBubbleView::ManagePasswordsBubbleView( 1015 ManagePasswordsBubbleView::ManagePasswordsBubbleView(
1020 content::WebContents* web_contents, 1016 content::WebContents* web_contents,
1021 ManagePasswordsIconView* anchor_view, 1017 ManagePasswordsIconView* anchor_view,
1022 DisplayReason reason) 1018 DisplayReason reason)
1023 : ManagePasswordsBubble(web_contents, reason), 1019 : ManagePasswordsBubble(web_contents, reason),
1024 BubbleDelegateView(anchor_view, 1020 ManagedFullScreenBubbleDelegateView(anchor_view, web_contents),
1025 anchor_view ? views::BubbleBorder::TOP_RIGHT
1026 : views::BubbleBorder::NONE),
1027 anchor_view_(anchor_view), 1021 anchor_view_(anchor_view),
1028 initially_focused_view_(NULL) { 1022 initially_focused_view_(NULL) {
1029 // Compensate for built-in vertical padding in the anchor view's image. 1023 // Compensate for built-in vertical padding in the anchor view's image.
1030 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); 1024 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0));
1031 if (anchor_view) 1025 if (anchor_view)
1032 anchor_view->SetActive(true); 1026 anchor_view->SetActive(true);
1033 mouse_handler_.reset(new WebContentMouseHandler(this)); 1027 mouse_handler_.reset(new WebContentMouseHandler(this));
1034
1035 // Add observers to close the bubble if the fullscreen state changes.
1036 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
1037 registrar_.Add(
1038 this,
1039 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
1040 content::Source<FullscreenController>(browser->fullscreen_controller()));
1041 } 1028 }
1042 1029
1043 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() { 1030 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() {
1044 if (anchor_view_) 1031 if (anchor_view_)
1045 anchor_view_->SetActive(false); 1032 anchor_view_->SetActive(false);
1046 } 1033 }
1047 1034
1048 void ManagePasswordsBubbleView::AdjustForFullscreen(
1049 const gfx::Rect& screen_bounds) {
1050 if (GetAnchorView())
1051 return;
1052
1053 // The bubble's padding from the screen edge, used in fullscreen.
1054 const int kFullscreenPaddingEnd = 20;
1055 const size_t bubble_half_width = width() / 2;
1056 const int x_pos = base::i18n::IsRTL() ?
1057 screen_bounds.x() + bubble_half_width + kFullscreenPaddingEnd :
1058 screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd;
1059 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0));
1060 }
1061
1062 void ManagePasswordsBubbleView::Close() { 1035 void ManagePasswordsBubbleView::Close() {
1063 mouse_handler_.reset(); 1036 mouse_handler_.reset();
1064 GetWidget()->Close(); 1037 GetWidget()->Close();
1065 } 1038 }
1066 1039
1067 void ManagePasswordsBubbleView::Refresh() { 1040 void ManagePasswordsBubbleView::Refresh() {
1068 RemoveAllChildViews(true); 1041 RemoveAllChildViews(true);
1069 initially_focused_view_ = NULL; 1042 initially_focused_view_ = NULL;
1070 bool need_resize = false; 1043 bool need_resize = false;
1071 if (password_manager::ui::IsPendingState(model()->state())) { 1044 if (password_manager::ui::IsPendingState(model()->state())) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 void ManagePasswordsBubbleView::WindowClosing() { 1096 void ManagePasswordsBubbleView::WindowClosing() {
1124 // Close() closes the window asynchronously, so by the time we reach here, 1097 // Close() closes the window asynchronously, so by the time we reach here,
1125 // |manage_passwords_bubble_| may have already been reset. 1098 // |manage_passwords_bubble_| may have already been reset.
1126 if (manage_passwords_bubble_ == this) 1099 if (manage_passwords_bubble_ == this)
1127 manage_passwords_bubble_ = NULL; 1100 manage_passwords_bubble_ = NULL;
1128 } 1101 }
1129 1102
1130 views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { 1103 views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() {
1131 return initially_focused_view_; 1104 return initially_focused_view_;
1132 } 1105 }
1133
1134 void ManagePasswordsBubbleView::Observe(
1135 int type,
1136 const content::NotificationSource& source,
1137 const content::NotificationDetails& details) {
1138 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED);
1139 GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE);
1140 CloseBubble();
1141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698