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 "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 14 matching lines...) Expand all Loading... |
25 #include "ui/views/controls/button/label_button.h" | 25 #include "ui/views/controls/button/label_button.h" |
26 #include "ui/views/controls/combobox/combobox.h" | 26 #include "ui/views/controls/combobox/combobox.h" |
27 #include "ui/views/layout/grid_layout.h" | 27 #include "ui/views/layout/grid_layout.h" |
28 #include "ui/views/layout/layout_constants.h" | 28 #include "ui/views/layout/layout_constants.h" |
29 | 29 |
30 | 30 |
31 // Helpers -------------------------------------------------------------------- | 31 // Helpers -------------------------------------------------------------------- |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 // Metrics: "PasswordBubble.DisplayDisposition" | 35 enum FieldType { USERNAME_FIELD, PASSWORD_FIELD }; |
36 enum BubbleDisplayDisposition { | |
37 AUTOMATIC_WITH_PASSWORD_PENDING = 0, | |
38 MANUAL_WITH_PASSWORD_PENDING, | |
39 MANUAL_MANAGE_PASSWORDS, | |
40 NUM_DISPLAY_DISPOSITIONS | |
41 }; | |
42 | 36 |
43 // Upper limit on the size of the username and password fields. | 37 // Upper limit on the size of the username and password fields. |
44 const int kUsernameFieldSize = 30; | 38 const int kUsernameFieldSize = 30; |
45 const int kPasswordFieldSize = 22; | 39 const int kPasswordFieldSize = 22; |
46 | 40 |
47 // Returns the width of |type| field. | 41 // Returns the width of |type| field. |
48 int GetFieldWidth(ManagePasswordsBubbleView::FieldType type) { | 42 int GetFieldWidth(FieldType type) { |
49 return ui::ResourceBundle::GetSharedInstance() | 43 return ui::ResourceBundle::GetSharedInstance() |
50 .GetFontList(ui::ResourceBundle::SmallFont) | 44 .GetFontList(ui::ResourceBundle::SmallFont) |
51 .GetExpectedTextWidth(type == ManagePasswordsBubbleView::USERNAME_FIELD | 45 .GetExpectedTextWidth(type == USERNAME_FIELD ? kUsernameFieldSize |
52 ? kUsernameFieldSize | 46 : kPasswordFieldSize); |
53 : kPasswordFieldSize); | |
54 } | 47 } |
55 | 48 |
56 class SavePasswordRefusalComboboxModel : public ui::ComboboxModel { | 49 class SavePasswordRefusalComboboxModel : public ui::ComboboxModel { |
57 public: | 50 public: |
58 enum { INDEX_NOPE = 0, INDEX_NEVER_FOR_THIS_SITE = 1, }; | 51 enum { INDEX_NOPE = 0, INDEX_NEVER_FOR_THIS_SITE = 1, }; |
59 | 52 |
60 SavePasswordRefusalComboboxModel() { | 53 SavePasswordRefusalComboboxModel() { |
61 items_.push_back( | 54 items_.push_back( |
62 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON)); | 55 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON)); |
63 items_.push_back( | 56 items_.push_back( |
(...skipping 20 matching lines...) Expand all Loading... |
84 | 77 |
85 // ManagePasswordsBubbleView -------------------------------------------------- | 78 // ManagePasswordsBubbleView -------------------------------------------------- |
86 | 79 |
87 // static | 80 // static |
88 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ = | 81 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ = |
89 NULL; | 82 NULL; |
90 | 83 |
91 // static | 84 // static |
92 void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents, | 85 void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents, |
93 ManagePasswordsIconView* icon_view, | 86 ManagePasswordsIconView* icon_view, |
94 BubbleDisplayReason reason) { | 87 DisplayReason reason) { |
95 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 88 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
96 DCHECK(browser); | 89 DCHECK(browser); |
97 DCHECK(browser->window()); | 90 DCHECK(browser->window()); |
98 DCHECK(browser->fullscreen_controller()); | 91 DCHECK(browser->fullscreen_controller()); |
99 DCHECK(!IsShowing()); | 92 DCHECK(!IsShowing()); |
100 | 93 |
101 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | 94 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
102 bool is_fullscreen = browser_view->IsFullscreen(); | 95 bool is_fullscreen = browser_view->IsFullscreen(); |
103 views::View* anchor_view = is_fullscreen ? | 96 views::View* anchor_view = is_fullscreen ? |
104 NULL : browser_view->GetLocationBarView()->manage_passwords_icon_view(); | 97 NULL : browser_view->GetLocationBarView()->manage_passwords_icon_view(); |
(...skipping 10 matching lines...) Expand all Loading... |
115 // Adjust for fullscreen after creation as it relies on the content size. | 108 // Adjust for fullscreen after creation as it relies on the content size. |
116 if (is_fullscreen) { | 109 if (is_fullscreen) { |
117 manage_passwords_bubble_->AdjustForFullscreen( | 110 manage_passwords_bubble_->AdjustForFullscreen( |
118 browser_view->GetBoundsInScreen()); | 111 browser_view->GetBoundsInScreen()); |
119 } | 112 } |
120 | 113 |
121 manage_passwords_bubble_->GetWidget()->Show(); | 114 manage_passwords_bubble_->GetWidget()->Show(); |
122 } | 115 } |
123 | 116 |
124 // static | 117 // static |
125 void ManagePasswordsBubbleView::CloseBubble( | 118 void ManagePasswordsBubbleView::CloseBubble() { |
126 password_manager::metrics_util::UIDismissalReason reason) { | |
127 if (manage_passwords_bubble_) | 119 if (manage_passwords_bubble_) |
128 manage_passwords_bubble_->Close(reason); | 120 manage_passwords_bubble_->CloseWithoutLogging(); |
129 } | 121 } |
130 | 122 |
131 // static | 123 // static |
132 bool ManagePasswordsBubbleView::IsShowing() { | 124 bool ManagePasswordsBubbleView::IsShowing() { |
133 // The bubble may be in the process of closing. | 125 // The bubble may be in the process of closing. |
134 return (manage_passwords_bubble_ != NULL) && | 126 return (manage_passwords_bubble_ != NULL) && |
135 manage_passwords_bubble_->GetWidget()->IsVisible(); | 127 manage_passwords_bubble_->GetWidget()->IsVisible(); |
136 } | 128 } |
137 | 129 |
138 ManagePasswordsBubbleView::ManagePasswordsBubbleView( | 130 ManagePasswordsBubbleView::ManagePasswordsBubbleView( |
139 content::WebContents* web_contents, | 131 content::WebContents* web_contents, |
140 views::View* anchor_view, | 132 views::View* anchor_view, |
141 ManagePasswordsIconView* icon_view, | 133 ManagePasswordsIconView* icon_view, |
142 BubbleDisplayReason reason) | 134 DisplayReason reason) |
143 : BubbleDelegateView(anchor_view, | 135 : ManagePasswordsBubble(web_contents, reason), |
| 136 BubbleDelegateView(anchor_view, |
144 anchor_view ? views::BubbleBorder::TOP_RIGHT | 137 anchor_view ? views::BubbleBorder::TOP_RIGHT |
145 : views::BubbleBorder::NONE), | 138 : views::BubbleBorder::NONE), |
146 manage_passwords_bubble_model_( | |
147 new ManagePasswordsBubbleModel(web_contents)), | |
148 icon_view_(icon_view) { | 139 icon_view_(icon_view) { |
149 // Compensate for built-in vertical padding in the anchor view's image. | 140 // Compensate for built-in vertical padding in the anchor view's image. |
150 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); | 141 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); |
151 set_notify_enter_exit_on_child(true); | 142 set_notify_enter_exit_on_child(true); |
152 | |
153 BubbleDisplayDisposition disposition = AUTOMATIC_WITH_PASSWORD_PENDING; | |
154 if (reason == USER_ACTION) { | |
155 // TODO(mkwst): Deal with "Never save passwords" once we've decided how that | |
156 // flow should work. | |
157 disposition = manage_passwords_bubble_model_->WaitingToSavePassword() | |
158 ? MANUAL_WITH_PASSWORD_PENDING | |
159 : MANUAL_MANAGE_PASSWORDS; | |
160 } else { | |
161 DCHECK(manage_passwords_bubble_model_->WaitingToSavePassword()); | |
162 } | |
163 | |
164 UMA_HISTOGRAM_ENUMERATION("PasswordBubble.DisplayDisposition", | |
165 disposition, | |
166 NUM_DISPLAY_DISPOSITIONS); | |
167 } | 143 } |
168 | 144 |
169 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() { | 145 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() {} |
170 if (dismissal_reason_ == password_manager::metrics_util::NOT_DISPLAYED) | |
171 return; | |
172 | |
173 password_manager::metrics_util::LogUIDismissalReason(dismissal_reason_); | |
174 } | |
175 | 146 |
176 void ManagePasswordsBubbleView::BuildColumnSet(views::GridLayout* layout, | 147 void ManagePasswordsBubbleView::BuildColumnSet(views::GridLayout* layout, |
177 ColumnSetType type) { | 148 ColumnSetType type) { |
178 views::ColumnSet* column_set = layout->AddColumnSet(type); | 149 views::ColumnSet* column_set = layout->AddColumnSet(type); |
179 column_set->AddPaddingColumn(0, views::kPanelHorizMargin); | 150 column_set->AddPaddingColumn(0, views::kPanelHorizMargin); |
180 switch (type) { | 151 switch (type) { |
181 case SINGLE_VIEW_COLUMN_SET: | 152 case SINGLE_VIEW_COLUMN_SET: |
182 column_set->AddColumn(views::GridLayout::FILL, | 153 column_set->AddColumn(views::GridLayout::FILL, |
183 views::GridLayout::FILL, | 154 views::GridLayout::FILL, |
184 0, | 155 0, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 199 |
229 // The bubble's padding from the screen edge, used in fullscreen. | 200 // The bubble's padding from the screen edge, used in fullscreen. |
230 const int kFullscreenPaddingEnd = 20; | 201 const int kFullscreenPaddingEnd = 20; |
231 const size_t bubble_half_width = width() / 2; | 202 const size_t bubble_half_width = width() / 2; |
232 const int x_pos = base::i18n::IsRTL() ? | 203 const int x_pos = base::i18n::IsRTL() ? |
233 screen_bounds.x() + bubble_half_width + kFullscreenPaddingEnd : | 204 screen_bounds.x() + bubble_half_width + kFullscreenPaddingEnd : |
234 screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd; | 205 screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd; |
235 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); | 206 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); |
236 } | 207 } |
237 | 208 |
238 void ManagePasswordsBubbleView::Close( | 209 void ManagePasswordsBubbleView::Close() { |
239 password_manager::metrics_util::UIDismissalReason reason) { | 210 icon_view_->SetTooltip(model()->manage_passwords_bubble_state() == |
240 dismissal_reason_ = reason; | 211 ManagePasswordsBubbleModel::PASSWORD_TO_BE_SAVED); |
241 icon_view_->SetTooltip( | 212 GetWidget()->Close(); |
242 manage_passwords_bubble_model_->manage_passwords_bubble_state() == | 213 } |
243 ManagePasswordsBubbleModel::PASSWORD_TO_BE_SAVED); | 214 |
| 215 void ManagePasswordsBubbleView::CloseWithoutLogging() { |
| 216 model()->OnCloseWithoutLogging(); |
| 217 icon_view_->SetTooltip(model()->manage_passwords_bubble_state() == |
| 218 ManagePasswordsBubbleModel::PASSWORD_TO_BE_SAVED); |
244 GetWidget()->Close(); | 219 GetWidget()->Close(); |
245 } | 220 } |
246 | 221 |
247 void ManagePasswordsBubbleView::Init() { | 222 void ManagePasswordsBubbleView::Init() { |
248 using views::GridLayout; | 223 using views::GridLayout; |
249 | 224 |
250 // Default to a dismissal reason of "no interaction". If the user interacts | |
251 // with the button in such a way that it closes, we'll reset this value | |
252 // accordingly. | |
253 dismissal_reason_ = password_manager::metrics_util::NO_DIRECT_INTERACTION; | |
254 | |
255 GridLayout* layout = new GridLayout(this); | 225 GridLayout* layout = new GridLayout(this); |
256 SetFocusable(true); | 226 SetFocusable(true); |
257 SetLayoutManager(layout); | 227 SetLayoutManager(layout); |
258 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 228 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
259 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); | 229 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); |
260 BuildColumnSet(layout, LINK_BUTTON_COLUMN_SET); | 230 BuildColumnSet(layout, LINK_BUTTON_COLUMN_SET); |
261 | 231 |
262 // This calculates the necessary widths for credential columns in the bubble. | 232 // This calculates the necessary widths for credential columns in the bubble. |
263 const int first_field_width = std::max( | 233 const int first_field_width = std::max( |
264 GetFieldWidth(USERNAME_FIELD), | 234 GetFieldWidth(USERNAME_FIELD), |
265 views::Label(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_DELETED)) | 235 views::Label(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_DELETED)) |
266 .GetPreferredSize() | 236 .GetPreferredSize() |
267 .width()); | 237 .width()); |
268 | 238 |
269 const int second_field_width = std::max( | 239 const int second_field_width = std::max( |
270 GetFieldWidth(PASSWORD_FIELD), | 240 GetFieldWidth(PASSWORD_FIELD), |
271 views::Label(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_UNDO)) | 241 views::Label(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_UNDO)) |
272 .GetPreferredSize() | 242 .GetPreferredSize() |
273 .width()); | 243 .width()); |
274 | 244 |
275 // Build and populate the header. | 245 // Build and populate the header. |
276 views::Label* title_label = | 246 views::Label* title_label = new views::Label(model()->title()); |
277 new views::Label(manage_passwords_bubble_model_->title()); | |
278 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 247 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
279 title_label->SetMultiLine(true); | 248 title_label->SetMultiLine(true); |
280 title_label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 249 title_label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
281 ui::ResourceBundle::MediumFont)); | 250 ui::ResourceBundle::MediumFont)); |
282 | 251 |
283 layout->StartRowWithPadding( | 252 layout->StartRowWithPadding( |
284 0, SINGLE_VIEW_COLUMN_SET, 0, views::kRelatedControlSmallVerticalSpacing); | 253 0, SINGLE_VIEW_COLUMN_SET, 0, views::kRelatedControlSmallVerticalSpacing); |
285 layout->AddView(title_label); | 254 layout->AddView(title_label); |
286 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | 255 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); |
287 | 256 |
288 if (manage_passwords_bubble_model_->WaitingToSavePassword()) { | 257 if (model()->WaitingToSavePassword()) { |
289 // If we've got a password that we're deciding whether or not to save, | 258 // If we've got a password that we're deciding whether or not to save, |
290 // then we need to display a single-view columnset containing the | 259 // then we need to display a single-view columnset containing the |
291 // ManagePasswordItemView, followed by double-view columnset containing | 260 // ManagePasswordItemView, followed by double-view columnset containing |
292 // a "Save" and "Reject" button. | 261 // a "Save" and "Reject" button. |
293 ManagePasswordItemView* item = new ManagePasswordItemView( | 262 ManagePasswordItemView* item = |
294 manage_passwords_bubble_model_, | 263 new ManagePasswordItemView(model(), |
295 manage_passwords_bubble_model_->pending_credentials(), | 264 model()->pending_credentials(), |
296 first_field_width, | 265 first_field_width, |
297 second_field_width, | 266 second_field_width, |
298 ManagePasswordItemView::FIRST_ITEM); | 267 ManagePasswordItemView::FIRST_ITEM); |
299 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 268 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
300 layout->AddView(item); | 269 layout->AddView(item); |
301 | 270 |
302 refuse_combobox_ = | 271 refuse_combobox_ = |
303 new views::Combobox(new SavePasswordRefusalComboboxModel()); | 272 new views::Combobox(new SavePasswordRefusalComboboxModel()); |
304 refuse_combobox_->set_listener(this); | 273 refuse_combobox_->set_listener(this); |
305 refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION); | 274 refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION); |
306 | 275 |
307 save_button_ = new views::BlueButton( | 276 save_button_ = new views::BlueButton( |
308 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); | 277 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); |
309 | 278 |
310 layout->StartRowWithPadding( | 279 layout->StartRowWithPadding( |
311 0, DOUBLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); | 280 0, DOUBLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
312 layout->AddView(save_button_); | 281 layout->AddView(save_button_); |
313 layout->AddView(refuse_combobox_); | 282 layout->AddView(refuse_combobox_); |
314 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 283 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
315 } else { | 284 } else { |
316 // If we have a list of passwords to store for the current site, display | 285 // If we have a list of passwords to store for the current site, display |
317 // them to the user for management. Otherwise, render a "No passwords for | 286 // them to the user for management. Otherwise, render a "No passwords for |
318 // this site" message. | 287 // this site" message. |
319 // | 288 // |
320 // TODO(mkwst): Do we really want the "No passwords" case? It would probably | 289 // TODO(mkwst): Do we really want the "No passwords" case? It would probably |
321 // be better to only clear the pending password upon navigation, rather than | 290 // be better to only clear the pending password upon navigation, rather than |
322 // as soon as the bubble closes. | 291 // as soon as the bubble closes. |
323 if (!manage_passwords_bubble_model_->best_matches().empty()) { | 292 if (!model()->best_matches().empty()) { |
324 for (autofill::PasswordFormMap::const_iterator i( | 293 for (autofill::PasswordFormMap::const_iterator i( |
325 manage_passwords_bubble_model_->best_matches().begin()); | 294 model()->best_matches().begin()); |
326 i != manage_passwords_bubble_model_->best_matches().end(); ++i) { | 295 i != model()->best_matches().end(); |
| 296 ++i) { |
327 ManagePasswordItemView* item = new ManagePasswordItemView( | 297 ManagePasswordItemView* item = new ManagePasswordItemView( |
328 manage_passwords_bubble_model_, | 298 model(), |
329 *i->second, | 299 *i->second, |
330 first_field_width, | 300 first_field_width, |
331 second_field_width, | 301 second_field_width, |
332 i == manage_passwords_bubble_model_->best_matches().begin() | 302 i == model()->best_matches().begin() |
333 ? ManagePasswordItemView::FIRST_ITEM | 303 ? ManagePasswordItemView::FIRST_ITEM |
334 : ManagePasswordItemView::SUBSEQUENT_ITEM); | 304 : ManagePasswordItemView::SUBSEQUENT_ITEM); |
335 | 305 |
336 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 306 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
337 layout->AddView(item); | 307 layout->AddView(item); |
338 } | 308 } |
339 } else { | 309 } else { |
340 views::Label* empty_label = new views::Label( | 310 views::Label* empty_label = new views::Label( |
341 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_NO_PASSWORDS)); | 311 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_NO_PASSWORDS)); |
342 empty_label->SetMultiLine(true); | 312 empty_label->SetMultiLine(true); |
343 | 313 |
344 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 314 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
345 layout->AddView(empty_label); | 315 layout->AddView(empty_label); |
346 } | 316 } |
347 | 317 |
348 // Build a "manage" link and "done" button, and throw them both into a new | 318 // Build a "manage" link and "done" button, and throw them both into a new |
349 // row | 319 // row |
350 // containing a double-view columnset. | 320 // containing a double-view columnset. |
351 manage_link_ = | 321 manage_link_ = new views::Link(model()->manage_link()); |
352 new views::Link(manage_passwords_bubble_model_->manage_link()); | |
353 manage_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 322 manage_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
354 manage_link_->SetUnderline(false); | 323 manage_link_->SetUnderline(false); |
355 manage_link_->set_listener(this); | 324 manage_link_->set_listener(this); |
356 | 325 |
357 done_button_ = | 326 done_button_ = |
358 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_DONE)); | 327 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_DONE)); |
359 done_button_->SetStyle(views::Button::STYLE_BUTTON); | 328 done_button_->SetStyle(views::Button::STYLE_BUTTON); |
360 | 329 |
361 layout->StartRowWithPadding( | 330 layout->StartRowWithPadding( |
362 0, LINK_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); | 331 0, LINK_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
363 layout->AddView(manage_link_); | 332 layout->AddView(manage_link_); |
364 layout->AddView(done_button_); | 333 layout->AddView(done_button_); |
365 } | 334 } |
366 } | 335 } |
367 | 336 |
368 void ManagePasswordsBubbleView::WindowClosing() { | 337 void ManagePasswordsBubbleView::WindowClosing() { |
369 // Close() closes the window asynchronously, so by the time we reach here, | 338 // Close() closes the window asynchronously, so by the time we reach here, |
370 // |manage_passwords_bubble_| may have already been reset. | 339 // |manage_passwords_bubble_| may have already been reset. |
371 if (manage_passwords_bubble_ == this) | 340 if (manage_passwords_bubble_ == this) |
372 manage_passwords_bubble_ = NULL; | 341 manage_passwords_bubble_ = NULL; |
373 } | 342 } |
374 | 343 |
375 void ManagePasswordsBubbleView::ButtonPressed(views::Button* sender, | 344 void ManagePasswordsBubbleView::ButtonPressed(views::Button* sender, |
376 const ui::Event& event) { | 345 const ui::Event& event) { |
377 DCHECK(sender == save_button_ || sender == done_button_); | 346 DCHECK(sender == save_button_ || sender == done_button_); |
378 | 347 |
379 password_manager::metrics_util::UIDismissalReason reason; | 348 if (sender == save_button_) |
380 if (sender == save_button_) { | 349 model()->OnSaveClicked(); |
381 manage_passwords_bubble_model_->OnSaveClicked(); | 350 else |
382 reason = password_manager::metrics_util::CLICKED_SAVE; | 351 model()->OnDoneClicked(); |
383 } else { | 352 Close(); |
384 reason = password_manager::metrics_util::CLICKED_DONE; | |
385 } | |
386 Close(reason); | |
387 } | 353 } |
388 | 354 |
389 void ManagePasswordsBubbleView::LinkClicked(views::Link* source, | 355 void ManagePasswordsBubbleView::LinkClicked(views::Link* source, |
390 int event_flags) { | 356 int event_flags) { |
391 DCHECK_EQ(source, manage_link_); | 357 DCHECK_EQ(source, manage_link_); |
392 manage_passwords_bubble_model_->OnManageLinkClicked(); | 358 model()->OnManageLinkClicked(); |
393 Close(password_manager::metrics_util::CLICKED_MANAGE); | 359 Close(); |
394 } | 360 } |
395 | 361 |
396 void ManagePasswordsBubbleView::OnPerformAction(views::Combobox* source) { | 362 void ManagePasswordsBubbleView::OnPerformAction(views::Combobox* source) { |
397 DCHECK_EQ(source, refuse_combobox_); | 363 DCHECK_EQ(source, refuse_combobox_); |
398 password_manager::metrics_util::UIDismissalReason reason = | |
399 password_manager::metrics_util::NOT_DISPLAYED; | |
400 switch (refuse_combobox_->selected_index()) { | 364 switch (refuse_combobox_->selected_index()) { |
401 case SavePasswordRefusalComboboxModel::INDEX_NOPE: | 365 case SavePasswordRefusalComboboxModel::INDEX_NOPE: |
402 manage_passwords_bubble_model_->OnNopeClicked(); | 366 model()->OnNopeClicked(); |
403 reason = password_manager::metrics_util::CLICKED_NOPE; | |
404 break; | 367 break; |
405 case SavePasswordRefusalComboboxModel::INDEX_NEVER_FOR_THIS_SITE: | 368 case SavePasswordRefusalComboboxModel::INDEX_NEVER_FOR_THIS_SITE: |
406 manage_passwords_bubble_model_->OnNeverForThisSiteClicked(); | 369 model()->OnNeverForThisSiteClicked(); |
407 reason = password_manager::metrics_util::CLICKED_NEVER; | |
408 break; | 370 break; |
409 default: | 371 default: |
410 NOTREACHED(); | 372 NOTREACHED(); |
411 break; | 373 break; |
412 } | 374 } |
413 Close(reason); | 375 Close(); |
414 } | 376 } |
OLD | NEW |