Chromium Code Reviews| 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" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
|
vasilii
2014/12/17 13:40:12
Clean up the unused headers.
Pritam Nikam
2014/12/17 16:06:26
Done.
| |
| 10 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 10 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| 11 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 11 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
| 12 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 12 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
| 13 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" | 13 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" |
| 14 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 15 #include "chrome/browser/ui/views/location_bar/location_bar_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" | 16 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" |
| 17 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" | 17 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" |
| 18 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" | 18 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" |
| 19 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
| (...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1014 | 1014 |
| 1015 content::WebContents* ManagePasswordsBubbleView::web_contents() const { | 1015 content::WebContents* ManagePasswordsBubbleView::web_contents() const { |
| 1016 return model()->web_contents(); | 1016 return model()->web_contents(); |
| 1017 } | 1017 } |
| 1018 | 1018 |
| 1019 ManagePasswordsBubbleView::ManagePasswordsBubbleView( | 1019 ManagePasswordsBubbleView::ManagePasswordsBubbleView( |
| 1020 content::WebContents* web_contents, | 1020 content::WebContents* web_contents, |
| 1021 ManagePasswordsIconView* anchor_view, | 1021 ManagePasswordsIconView* anchor_view, |
| 1022 DisplayReason reason) | 1022 DisplayReason reason) |
| 1023 : ManagePasswordsBubble(web_contents, reason), | 1023 : ManagePasswordsBubble(web_contents, reason), |
| 1024 BubbleDelegateView(anchor_view, | 1024 ManagedFullScreenBubbleDelegateView(anchor_view, web_contents), |
| 1025 anchor_view ? views::BubbleBorder::TOP_RIGHT | |
| 1026 : views::BubbleBorder::NONE), | |
| 1027 anchor_view_(anchor_view), | 1025 anchor_view_(anchor_view), |
| 1028 initially_focused_view_(NULL) { | 1026 initially_focused_view_(NULL) { |
| 1029 // Compensate for built-in vertical padding in the anchor view's image. | 1027 // Compensate for built-in vertical padding in the anchor view's image. |
| 1030 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); | 1028 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); |
| 1031 if (anchor_view) | 1029 if (anchor_view) |
| 1032 anchor_view->SetActive(true); | 1030 anchor_view->SetActive(true); |
| 1033 mouse_handler_.reset(new WebContentMouseHandler(this)); | 1031 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 } | 1032 } |
| 1042 | 1033 |
| 1043 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() { | 1034 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() { |
| 1044 if (anchor_view_) | 1035 if (anchor_view_) |
| 1045 anchor_view_->SetActive(false); | 1036 anchor_view_->SetActive(false); |
| 1046 } | 1037 } |
| 1047 | 1038 |
| 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() { | 1039 void ManagePasswordsBubbleView::Close() { |
| 1063 mouse_handler_.reset(); | 1040 mouse_handler_.reset(); |
| 1064 GetWidget()->Close(); | 1041 GetWidget()->Close(); |
| 1065 } | 1042 } |
| 1066 | 1043 |
| 1067 void ManagePasswordsBubbleView::Refresh() { | 1044 void ManagePasswordsBubbleView::Refresh() { |
| 1068 RemoveAllChildViews(true); | 1045 RemoveAllChildViews(true); |
| 1069 initially_focused_view_ = NULL; | 1046 initially_focused_view_ = NULL; |
| 1070 bool need_resize = false; | 1047 bool need_resize = false; |
| 1071 if (password_manager::ui::IsPendingState(model()->state())) { | 1048 if (password_manager::ui::IsPendingState(model()->state())) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1123 void ManagePasswordsBubbleView::WindowClosing() { | 1100 void ManagePasswordsBubbleView::WindowClosing() { |
| 1124 // Close() closes the window asynchronously, so by the time we reach here, | 1101 // Close() closes the window asynchronously, so by the time we reach here, |
| 1125 // |manage_passwords_bubble_| may have already been reset. | 1102 // |manage_passwords_bubble_| may have already been reset. |
| 1126 if (manage_passwords_bubble_ == this) | 1103 if (manage_passwords_bubble_ == this) |
| 1127 manage_passwords_bubble_ = NULL; | 1104 manage_passwords_bubble_ = NULL; |
| 1128 } | 1105 } |
| 1129 | 1106 |
| 1130 views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { | 1107 views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { |
| 1131 return initially_focused_view_; | 1108 return initially_focused_view_; |
| 1132 } | 1109 } |
| 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 } | |
| OLD | NEW |