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

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

Issue 230463002: Password bubble: Remove IconView from BubbleView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 8 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 | Annotate | Revision Log
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/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 77
78 // ManagePasswordsBubbleView -------------------------------------------------- 78 // ManagePasswordsBubbleView --------------------------------------------------
79 79
80 // static 80 // static
81 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ = 81 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ =
82 NULL; 82 NULL;
83 83
84 // static 84 // static
85 void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents, 85 void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents,
86 ManagePasswordsIconView* icon_view,
87 DisplayReason reason) { 86 DisplayReason reason) {
88 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); 87 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
89 DCHECK(browser); 88 DCHECK(browser);
90 DCHECK(browser->window()); 89 DCHECK(browser->window());
91 DCHECK(browser->fullscreen_controller()); 90 DCHECK(browser->fullscreen_controller());
92 DCHECK(!IsShowing()); 91 DCHECK(!IsShowing());
93 92
94 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); 93 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
95 bool is_fullscreen = browser_view->IsFullscreen(); 94 bool is_fullscreen = browser_view->IsFullscreen();
96 views::View* anchor_view = is_fullscreen ? 95 views::View* anchor_view = is_fullscreen ?
97 NULL : browser_view->GetLocationBarView()->manage_passwords_icon_view(); 96 NULL : browser_view->GetLocationBarView()->manage_passwords_icon_view();
98 manage_passwords_bubble_ = new ManagePasswordsBubbleView( 97 manage_passwords_bubble_ = new ManagePasswordsBubbleView(
99 web_contents, anchor_view, icon_view, reason); 98 web_contents, anchor_view, reason);
100 99
101 if (is_fullscreen) { 100 if (is_fullscreen) {
102 manage_passwords_bubble_->set_parent_window( 101 manage_passwords_bubble_->set_parent_window(
103 web_contents->GetView()->GetTopLevelNativeWindow()); 102 web_contents->GetView()->GetTopLevelNativeWindow());
104 } 103 }
105 104
106 views::BubbleDelegateView::CreateBubble(manage_passwords_bubble_); 105 views::BubbleDelegateView::CreateBubble(manage_passwords_bubble_);
107 106
108 // Adjust for fullscreen after creation as it relies on the content size. 107 // Adjust for fullscreen after creation as it relies on the content size.
109 if (is_fullscreen) { 108 if (is_fullscreen) {
(...skipping 13 matching lines...) Expand all
123 // static 122 // static
124 bool ManagePasswordsBubbleView::IsShowing() { 123 bool ManagePasswordsBubbleView::IsShowing() {
125 // The bubble may be in the process of closing. 124 // The bubble may be in the process of closing.
126 return (manage_passwords_bubble_ != NULL) && 125 return (manage_passwords_bubble_ != NULL) &&
127 manage_passwords_bubble_->GetWidget()->IsVisible(); 126 manage_passwords_bubble_->GetWidget()->IsVisible();
128 } 127 }
129 128
130 ManagePasswordsBubbleView::ManagePasswordsBubbleView( 129 ManagePasswordsBubbleView::ManagePasswordsBubbleView(
131 content::WebContents* web_contents, 130 content::WebContents* web_contents,
132 views::View* anchor_view, 131 views::View* anchor_view,
133 ManagePasswordsIconView* icon_view,
134 DisplayReason reason) 132 DisplayReason reason)
135 : ManagePasswordsBubble(web_contents, reason), 133 : ManagePasswordsBubble(web_contents, reason),
136 BubbleDelegateView(anchor_view, 134 BubbleDelegateView(anchor_view,
137 anchor_view ? views::BubbleBorder::TOP_RIGHT 135 anchor_view ? views::BubbleBorder::TOP_RIGHT
138 : views::BubbleBorder::NONE), 136 : views::BubbleBorder::NONE) {
139 icon_view_(icon_view) {
140 // Compensate for built-in vertical padding in the anchor view's image. 137 // Compensate for built-in vertical padding in the anchor view's image.
141 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); 138 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0));
142 set_notify_enter_exit_on_child(true); 139 set_notify_enter_exit_on_child(true);
143 } 140 }
144 141
145 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() {} 142 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() {}
146 143
147 void ManagePasswordsBubbleView::BuildColumnSet(views::GridLayout* layout, 144 void ManagePasswordsBubbleView::BuildColumnSet(views::GridLayout* layout,
148 ColumnSetType type) { 145 ColumnSetType type) {
149 views::ColumnSet* column_set = layout->AddColumnSet(type); 146 views::ColumnSet* column_set = layout->AddColumnSet(type);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // The bubble's padding from the screen edge, used in fullscreen. 197 // The bubble's padding from the screen edge, used in fullscreen.
201 const int kFullscreenPaddingEnd = 20; 198 const int kFullscreenPaddingEnd = 20;
202 const size_t bubble_half_width = width() / 2; 199 const size_t bubble_half_width = width() / 2;
203 const int x_pos = base::i18n::IsRTL() ? 200 const int x_pos = base::i18n::IsRTL() ?
204 screen_bounds.x() + bubble_half_width + kFullscreenPaddingEnd : 201 screen_bounds.x() + bubble_half_width + kFullscreenPaddingEnd :
205 screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd; 202 screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd;
206 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); 203 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0));
207 } 204 }
208 205
209 void ManagePasswordsBubbleView::Close() { 206 void ManagePasswordsBubbleView::Close() {
210 icon_view_->SetTooltip(model()->manage_passwords_bubble_state() ==
211 ManagePasswordsBubbleModel::PASSWORD_TO_BE_SAVED);
212 GetWidget()->Close(); 207 GetWidget()->Close();
213 } 208 }
214 209
215 void ManagePasswordsBubbleView::CloseWithoutLogging() { 210 void ManagePasswordsBubbleView::CloseWithoutLogging() {
216 model()->OnCloseWithoutLogging(); 211 model()->OnCloseWithoutLogging();
217 icon_view_->SetTooltip(model()->manage_passwords_bubble_state() ==
218 ManagePasswordsBubbleModel::PASSWORD_TO_BE_SAVED);
219 GetWidget()->Close(); 212 GetWidget()->Close();
220 } 213 }
221 214
222 void ManagePasswordsBubbleView::Init() { 215 void ManagePasswordsBubbleView::Init() {
223 using views::GridLayout; 216 using views::GridLayout;
224 217
225 GridLayout* layout = new GridLayout(this); 218 GridLayout* layout = new GridLayout(this);
226 SetFocusable(true); 219 SetFocusable(true);
227 SetLayoutManager(layout); 220 SetLayoutManager(layout);
228 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); 221 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 break; 360 break;
368 case SavePasswordRefusalComboboxModel::INDEX_NEVER_FOR_THIS_SITE: 361 case SavePasswordRefusalComboboxModel::INDEX_NEVER_FOR_THIS_SITE:
369 model()->OnNeverForThisSiteClicked(); 362 model()->OnNeverForThisSiteClicked();
370 break; 363 break;
371 default: 364 default:
372 NOTREACHED(); 365 NOTREACHED();
373 break; 366 break;
374 } 367 }
375 Close(); 368 Close();
376 } 369 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698