OLD | NEW |
---|---|
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/exclusive_access/fullscreen_controller.h" | 9 #include "chrome/browser/ui/exclusive_access/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" |
11 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | |
12 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" | 12 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" |
13 #include "chrome/browser/ui/views/frame/browser_view.h" | 13 #include "chrome/browser/ui/views/frame/browser_view.h" |
14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | |
15 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" | 14 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" |
16 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" | 15 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" |
17 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" | 16 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" |
18 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
19 #include "content/public/browser/notification_source.h" | |
20 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
21 #include "content/public/browser/web_contents.h" | |
22 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
24 #include "ui/views/controls/button/blue_button.h" | 21 #include "ui/views/controls/button/blue_button.h" |
25 #include "ui/views/controls/button/label_button.h" | 22 #include "ui/views/controls/button/label_button.h" |
26 #include "ui/views/controls/combobox/combobox.h" | 23 #include "ui/views/controls/combobox/combobox.h" |
27 #include "ui/views/controls/combobox/combobox_listener.h" | 24 #include "ui/views/controls/combobox/combobox_listener.h" |
28 #include "ui/views/controls/link.h" | 25 #include "ui/views/controls/link.h" |
29 #include "ui/views/controls/link_listener.h" | 26 #include "ui/views/controls/link_listener.h" |
30 #include "ui/views/controls/separator.h" | 27 #include "ui/views/controls/separator.h" |
31 #include "ui/views/controls/styled_label.h" | 28 #include "ui/views/controls/styled_label.h" |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
982 | 979 |
983 content::WebContents* ManagePasswordsBubbleView::web_contents() const { | 980 content::WebContents* ManagePasswordsBubbleView::web_contents() const { |
984 return model()->web_contents(); | 981 return model()->web_contents(); |
985 } | 982 } |
986 | 983 |
987 ManagePasswordsBubbleView::ManagePasswordsBubbleView( | 984 ManagePasswordsBubbleView::ManagePasswordsBubbleView( |
988 content::WebContents* web_contents, | 985 content::WebContents* web_contents, |
989 ManagePasswordsIconView* anchor_view, | 986 ManagePasswordsIconView* anchor_view, |
990 DisplayReason reason) | 987 DisplayReason reason) |
991 : ManagePasswordsBubble(web_contents, reason), | 988 : ManagePasswordsBubble(web_contents, reason), |
992 BubbleDelegateView(anchor_view, | 989 ManagedFullScreenBubbleDelegateView(anchor_view, web_contents), |
993 anchor_view ? views::BubbleBorder::TOP_RIGHT | |
994 : views::BubbleBorder::NONE), | |
995 anchor_view_(anchor_view), | 990 anchor_view_(anchor_view), |
996 initially_focused_view_(NULL) { | 991 initially_focused_view_(NULL) { |
997 // Compensate for built-in vertical padding in the anchor view's image. | 992 // Compensate for built-in vertical padding in the anchor view's image. |
998 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); | 993 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); |
999 if (anchor_view) | 994 if (anchor_view) |
1000 anchor_view->SetActive(true); | 995 anchor_view->SetActive(true); |
1001 mouse_handler_.reset(new WebContentMouseHandler(this)); | 996 mouse_handler_.reset(new WebContentMouseHandler(this)); |
1002 | |
1003 // Add observers to close the bubble if the fullscreen state changes. | |
1004 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | |
1005 registrar_.Add( | |
1006 this, | |
1007 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
1008 content::Source<FullscreenController>(browser->fullscreen_controller())); | |
1009 } | 997 } |
1010 | 998 |
1011 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() { | 999 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() { |
1012 if (anchor_view_) | 1000 if (anchor_view_) |
1013 anchor_view_->SetActive(false); | 1001 anchor_view_->SetActive(false); |
1014 } | 1002 } |
1015 | 1003 |
1016 void ManagePasswordsBubbleView::AdjustForFullscreen( | |
1017 const gfx::Rect& screen_bounds) { | |
1018 if (GetAnchorView()) | |
1019 return; | |
1020 | |
1021 // The bubble's padding from the screen edge, used in fullscreen. | |
1022 const int kFullscreenPaddingEnd = 20; | |
1023 const size_t bubble_half_width = width() / 2; | |
1024 const int x_pos = base::i18n::IsRTL() ? | |
1025 screen_bounds.x() + bubble_half_width + kFullscreenPaddingEnd : | |
1026 screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd; | |
1027 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); | |
1028 } | |
1029 | |
1030 void ManagePasswordsBubbleView::Close() { | 1004 void ManagePasswordsBubbleView::Close() { |
1031 mouse_handler_.reset(); | 1005 mouse_handler_.reset(); |
1032 GetWidget()->Close(); | 1006 GetWidget()->Close(); |
Peter Kasting
2014/12/19 22:11:36
Nit: Same comment as in other class
Pritam Nikam
2014/12/22 08:19:10
Done.
| |
1033 } | 1007 } |
1034 | 1008 |
1035 void ManagePasswordsBubbleView::Refresh() { | 1009 void ManagePasswordsBubbleView::Refresh() { |
1036 RemoveAllChildViews(true); | 1010 RemoveAllChildViews(true); |
1037 initially_focused_view_ = NULL; | 1011 initially_focused_view_ = NULL; |
1038 bool need_resize = false; | 1012 bool need_resize = false; |
1039 if (password_manager::ui::IsPendingState(model()->state())) { | 1013 if (password_manager::ui::IsPendingState(model()->state())) { |
1040 if (model()->never_save_passwords()) | 1014 if (model()->never_save_passwords()) |
1041 AddChildView(new ConfirmNeverView(this)); | 1015 AddChildView(new ConfirmNeverView(this)); |
1042 else | 1016 else |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1091 void ManagePasswordsBubbleView::WindowClosing() { | 1065 void ManagePasswordsBubbleView::WindowClosing() { |
1092 // Close() closes the window asynchronously, so by the time we reach here, | 1066 // Close() closes the window asynchronously, so by the time we reach here, |
1093 // |manage_passwords_bubble_| may have already been reset. | 1067 // |manage_passwords_bubble_| may have already been reset. |
1094 if (manage_passwords_bubble_ == this) | 1068 if (manage_passwords_bubble_ == this) |
1095 manage_passwords_bubble_ = NULL; | 1069 manage_passwords_bubble_ = NULL; |
1096 } | 1070 } |
1097 | 1071 |
1098 views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { | 1072 views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { |
1099 return initially_focused_view_; | 1073 return initially_focused_view_; |
1100 } | 1074 } |
1101 | |
1102 void ManagePasswordsBubbleView::Observe( | |
1103 int type, | |
1104 const content::NotificationSource& source, | |
1105 const content::NotificationDetails& details) { | |
1106 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); | |
1107 GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); | |
1108 CloseBubble(); | |
1109 } | |
OLD | NEW |