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/browser_window.h" | |
11 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 9 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
12 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 10 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
11 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" | |
13 #include "chrome/browser/ui/views/frame/browser_view.h" | 12 #include "chrome/browser/ui/views/frame/browser_view.h" |
14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
15 #include "chrome/browser/ui/views/passwords/manage_password_item_view.h" | 14 #include "chrome/browser/ui/views/passwords/manage_password_item_view.h" |
16 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" | 15 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" |
17 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
18 #include "components/password_manager/core/common/password_manager_ui.h" | |
19 #include "content/public/browser/notification_source.h" | |
20 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
21 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
22 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/base/models/combobox_model.h" | |
24 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/compositor/layer_animation_observer.h" | 21 #include "ui/compositor/layer_animation_observer.h" |
26 #include "ui/compositor/scoped_layer_animation_settings.h" | 22 #include "ui/compositor/scoped_layer_animation_settings.h" |
27 #include "ui/gfx/text_utils.h" | |
28 #include "ui/views/controls/button/blue_button.h" | 23 #include "ui/views/controls/button/blue_button.h" |
29 #include "ui/views/controls/button/label_button.h" | 24 #include "ui/views/controls/button/label_button.h" |
30 #include "ui/views/controls/combobox/combobox.h" | 25 #include "ui/views/controls/combobox/combobox.h" |
26 #include "ui/views/controls/combobox/combobox_listener.h" | |
27 #include "ui/views/controls/link.h" | |
28 #include "ui/views/controls/link_listener.h" | |
31 #include "ui/views/controls/styled_label.h" | 29 #include "ui/views/controls/styled_label.h" |
30 #include "ui/views/controls/styled_label_listener.h" | |
32 #include "ui/views/layout/fill_layout.h" | 31 #include "ui/views/layout/fill_layout.h" |
33 #include "ui/views/layout/grid_layout.h" | 32 #include "ui/views/layout/grid_layout.h" |
34 #include "ui/views/layout/layout_constants.h" | 33 #include "ui/views/layout/layout_constants.h" |
35 | 34 |
36 | 35 |
37 // Helpers -------------------------------------------------------------------- | 36 // Helpers -------------------------------------------------------------------- |
38 | 37 |
39 namespace { | 38 namespace { |
40 | 39 |
41 // The number of seconds the bubble needs to fade out. | 40 // The number of seconds the bubble needs to fade out. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 password_manager::ui::IsAutomaticDisplayState(controller->state()) | 157 password_manager::ui::IsAutomaticDisplayState(controller->state()) |
159 ? ManagePasswordsBubbleView::AUTOMATIC | 158 ? ManagePasswordsBubbleView::AUTOMATIC |
160 : ManagePasswordsBubbleView::USER_ACTION); | 159 : ManagePasswordsBubbleView::USER_ACTION); |
161 } | 160 } |
162 | 161 |
163 } // namespace chrome | 162 } // namespace chrome |
164 | 163 |
165 | 164 |
166 // ManagePasswordsBubbleView::PendingView ------------------------------------- | 165 // ManagePasswordsBubbleView::PendingView ------------------------------------- |
167 | 166 |
167 // A view offering the user the ability to save credentials. Contains a | |
168 // single ManagePasswordItemView, along with a "Save Passwords" button | |
169 // and a rejection combobox. | |
170 class ManagePasswordsBubbleView::PendingView : public views::View, | |
171 public views::ButtonListener, | |
172 public views::ComboboxListener { | |
173 public: | |
174 explicit PendingView(ManagePasswordsBubbleView* parent); | |
175 | |
176 private: | |
177 // views::ButtonListener: | |
178 virtual void ButtonPressed(views::Button* sender, | |
179 const ui::Event& event) OVERRIDE; | |
180 | |
181 // Handles the event when the user changes an index of a combobox. | |
182 virtual void OnPerformAction(views::Combobox* source) OVERRIDE; | |
183 | |
184 ManagePasswordsBubbleView* parent_; | |
185 | |
186 views::BlueButton* save_button_; | |
187 | |
188 // The combobox doesn't take ownership of its model. If we created a | |
189 // combobox we need to ensure that we delete the model here, and because the | |
190 // combobox uses the model in it's destructor, we need to make sure we | |
191 // delete the model _after_ the combobox itself is deleted. | |
192 scoped_ptr<SavePasswordRefusalComboboxModel> combobox_model_; | |
193 scoped_ptr<views::Combobox> refuse_combobox_; | |
194 }; | |
195 | |
168 ManagePasswordsBubbleView::PendingView::PendingView( | 196 ManagePasswordsBubbleView::PendingView::PendingView( |
169 ManagePasswordsBubbleView* parent) | 197 ManagePasswordsBubbleView* parent) |
170 : parent_(parent) { | 198 : parent_(parent) { |
171 views::GridLayout* layout = new views::GridLayout(this); | 199 views::GridLayout* layout = new views::GridLayout(this); |
172 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 200 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
173 SetLayoutManager(layout); | 201 SetLayoutManager(layout); |
174 | 202 |
175 // Create the pending credential item, save button and refusal combobox. | 203 // Create the pending credential item, save button and refusal combobox. |
176 ManagePasswordItemView* item = | 204 ManagePasswordItemView* item = |
177 new ManagePasswordItemView(parent->model(), | 205 new ManagePasswordItemView(parent->model(), |
(...skipping 24 matching lines...) Expand all Loading... | |
202 0, DOUBLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); | 230 0, DOUBLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
203 layout->AddView(save_button_); | 231 layout->AddView(save_button_); |
204 layout->AddView(refuse_combobox_.get()); | 232 layout->AddView(refuse_combobox_.get()); |
205 | 233 |
206 // Extra padding for visual awesomeness. | 234 // Extra padding for visual awesomeness. |
207 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 235 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
208 | 236 |
209 parent_->set_initially_focused_view(save_button_); | 237 parent_->set_initially_focused_view(save_button_); |
210 } | 238 } |
211 | 239 |
212 ManagePasswordsBubbleView::PendingView::~PendingView() { | |
vabr (Chromium)
2014/09/02 13:29:28
Any particular reason for dropping the destructors
vasilii
2014/09/02 15:33:33
Not really. Reverted.
| |
213 } | |
214 | |
215 void ManagePasswordsBubbleView::PendingView::ButtonPressed( | 240 void ManagePasswordsBubbleView::PendingView::ButtonPressed( |
216 views::Button* sender, | 241 views::Button* sender, |
217 const ui::Event& event) { | 242 const ui::Event& event) { |
218 DCHECK(sender == save_button_); | 243 DCHECK(sender == save_button_); |
219 parent_->model()->OnSaveClicked(); | 244 parent_->model()->OnSaveClicked(); |
220 parent_->Close(); | 245 parent_->Close(); |
221 } | 246 } |
222 | 247 |
223 void ManagePasswordsBubbleView::PendingView::OnPerformAction( | 248 void ManagePasswordsBubbleView::PendingView::OnPerformAction( |
224 views::Combobox* source) { | 249 views::Combobox* source) { |
225 DCHECK_EQ(source, refuse_combobox_); | 250 DCHECK_EQ(source, refuse_combobox_); |
226 switch (refuse_combobox_->selected_index()) { | 251 switch (refuse_combobox_->selected_index()) { |
227 case SavePasswordRefusalComboboxModel::INDEX_NOPE: | 252 case SavePasswordRefusalComboboxModel::INDEX_NOPE: |
228 parent_->model()->OnNopeClicked(); | 253 parent_->model()->OnNopeClicked(); |
229 parent_->Close(); | 254 parent_->Close(); |
230 break; | 255 break; |
231 case SavePasswordRefusalComboboxModel::INDEX_NEVER_FOR_THIS_SITE: | 256 case SavePasswordRefusalComboboxModel::INDEX_NEVER_FOR_THIS_SITE: |
232 parent_->NotifyNeverForThisSiteClicked(); | 257 parent_->NotifyNeverForThisSiteClicked(); |
233 break; | 258 break; |
234 } | 259 } |
235 } | 260 } |
236 | 261 |
237 // ManagePasswordsBubbleView::ConfirmNeverView --------------------------------- | 262 // ManagePasswordsBubbleView::ConfirmNeverView --------------------------------- |
238 | 263 |
264 // A view offering the user the ability to undo her decision to never save | |
265 // passwords for a particular site. | |
266 class ManagePasswordsBubbleView::ConfirmNeverView | |
267 : public views::View, | |
268 public views::ButtonListener { | |
269 public: | |
270 explicit ConfirmNeverView(ManagePasswordsBubbleView* parent); | |
271 | |
272 private: | |
273 // views::ButtonListener: | |
274 virtual void ButtonPressed(views::Button* sender, | |
275 const ui::Event& event) OVERRIDE; | |
276 | |
277 ManagePasswordsBubbleView* parent_; | |
278 | |
279 views::LabelButton* confirm_button_; | |
280 views::LabelButton* undo_button_; | |
281 }; | |
282 | |
239 ManagePasswordsBubbleView::ConfirmNeverView::ConfirmNeverView( | 283 ManagePasswordsBubbleView::ConfirmNeverView::ConfirmNeverView( |
240 ManagePasswordsBubbleView* parent) | 284 ManagePasswordsBubbleView* parent) |
241 : parent_(parent) { | 285 : parent_(parent) { |
242 views::GridLayout* layout = new views::GridLayout(this); | 286 views::GridLayout* layout = new views::GridLayout(this); |
243 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 287 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
244 SetLayoutManager(layout); | 288 SetLayoutManager(layout); |
245 | 289 |
246 // Title row. | 290 // Title row. |
247 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 291 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
248 views::Label* title_label = new views::Label(l10n_util::GetStringUTF16( | 292 views::Label* title_label = new views::Label(l10n_util::GetStringUTF16( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 undo_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 332 undo_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
289 ui::ResourceBundle::SmallFont)); | 333 ui::ResourceBundle::SmallFont)); |
290 layout->AddView(undo_button_); | 334 layout->AddView(undo_button_); |
291 | 335 |
292 // Extra padding for visual awesomeness. | 336 // Extra padding for visual awesomeness. |
293 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 337 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
294 | 338 |
295 parent_->set_initially_focused_view(confirm_button_); | 339 parent_->set_initially_focused_view(confirm_button_); |
296 } | 340 } |
297 | 341 |
298 ManagePasswordsBubbleView::ConfirmNeverView::~ConfirmNeverView() { | |
299 } | |
300 | |
301 void ManagePasswordsBubbleView::ConfirmNeverView::ButtonPressed( | 342 void ManagePasswordsBubbleView::ConfirmNeverView::ButtonPressed( |
302 views::Button* sender, | 343 views::Button* sender, |
303 const ui::Event& event) { | 344 const ui::Event& event) { |
304 DCHECK(sender == confirm_button_ || sender == undo_button_); | 345 DCHECK(sender == confirm_button_ || sender == undo_button_); |
305 if (sender == confirm_button_) | 346 if (sender == confirm_button_) |
306 parent_->NotifyConfirmedNeverForThisSite(); | 347 parent_->NotifyConfirmedNeverForThisSite(); |
307 else | 348 else |
308 parent_->NotifyUndoNeverForThisSite(); | 349 parent_->NotifyUndoNeverForThisSite(); |
309 } | 350 } |
310 | 351 |
311 // ManagePasswordsBubbleView::ManageView -------------------------------------- | 352 // ManagePasswordsBubbleView::ManageView -------------------------------------- |
312 | 353 |
354 // A view offering the user a list of her currently saved credentials | |
355 // for the current page, along with a "Manage passwords" link and a | |
356 // "Done" button. | |
357 class ManagePasswordsBubbleView::ManageView : public views::View, | |
358 public views::ButtonListener, | |
359 public views::LinkListener { | |
360 public: | |
361 explicit ManageView(ManagePasswordsBubbleView* parent); | |
362 | |
363 private: | |
364 // views::ButtonListener: | |
365 virtual void ButtonPressed(views::Button* sender, | |
366 const ui::Event& event) OVERRIDE; | |
367 | |
368 // views::LinkListener: | |
369 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | |
370 | |
371 ManagePasswordsBubbleView* parent_; | |
372 | |
373 views::Link* manage_link_; | |
374 views::LabelButton* done_button_; | |
375 }; | |
376 | |
313 ManagePasswordsBubbleView::ManageView::ManageView( | 377 ManagePasswordsBubbleView::ManageView::ManageView( |
314 ManagePasswordsBubbleView* parent) | 378 ManagePasswordsBubbleView* parent) |
315 : parent_(parent) { | 379 : parent_(parent) { |
316 views::GridLayout* layout = new views::GridLayout(this); | 380 views::GridLayout* layout = new views::GridLayout(this); |
317 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 381 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
318 SetLayoutManager(layout); | 382 SetLayoutManager(layout); |
319 | 383 |
320 // Add the title. | 384 // Add the title. |
321 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 385 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
322 AddTitleRow(layout, parent_->model()); | 386 AddTitleRow(layout, parent_->model()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 0, LINK_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); | 436 0, LINK_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
373 layout->AddView(manage_link_); | 437 layout->AddView(manage_link_); |
374 layout->AddView(done_button_); | 438 layout->AddView(done_button_); |
375 | 439 |
376 // Extra padding for visual awesomeness. | 440 // Extra padding for visual awesomeness. |
377 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 441 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
378 | 442 |
379 parent_->set_initially_focused_view(done_button_); | 443 parent_->set_initially_focused_view(done_button_); |
380 } | 444 } |
381 | 445 |
382 ManagePasswordsBubbleView::ManageView::~ManageView() { | |
383 } | |
384 | |
385 void ManagePasswordsBubbleView::ManageView::ButtonPressed( | 446 void ManagePasswordsBubbleView::ManageView::ButtonPressed( |
386 views::Button* sender, | 447 views::Button* sender, |
387 const ui::Event& event) { | 448 const ui::Event& event) { |
388 DCHECK(sender == done_button_); | 449 DCHECK(sender == done_button_); |
389 parent_->model()->OnDoneClicked(); | 450 parent_->model()->OnDoneClicked(); |
390 parent_->Close(); | 451 parent_->Close(); |
391 } | 452 } |
392 | 453 |
393 void ManagePasswordsBubbleView::ManageView::LinkClicked(views::Link* source, | 454 void ManagePasswordsBubbleView::ManageView::LinkClicked(views::Link* source, |
394 int event_flags) { | 455 int event_flags) { |
395 DCHECK_EQ(source, manage_link_); | 456 DCHECK_EQ(source, manage_link_); |
396 parent_->model()->OnManageLinkClicked(); | 457 parent_->model()->OnManageLinkClicked(); |
397 parent_->Close(); | 458 parent_->Close(); |
398 } | 459 } |
399 | 460 |
400 // ManagePasswordsBubbleView::BlacklistedView --------------------------------- | 461 // ManagePasswordsBubbleView::BlacklistedView --------------------------------- |
401 | 462 |
463 // A view offering the user the ability to re-enable the password manager for | |
464 // a specific site after she's decided to "never save passwords". | |
465 class ManagePasswordsBubbleView::BlacklistedView | |
466 : public views::View, | |
467 public views::ButtonListener { | |
468 public: | |
469 explicit BlacklistedView(ManagePasswordsBubbleView* parent); | |
470 | |
471 private: | |
472 // views::ButtonListener: | |
473 virtual void ButtonPressed(views::Button* sender, | |
474 const ui::Event& event) OVERRIDE; | |
475 | |
476 ManagePasswordsBubbleView* parent_; | |
477 | |
478 views::BlueButton* unblacklist_button_; | |
479 views::LabelButton* done_button_; | |
480 }; | |
481 | |
402 ManagePasswordsBubbleView::BlacklistedView::BlacklistedView( | 482 ManagePasswordsBubbleView::BlacklistedView::BlacklistedView( |
403 ManagePasswordsBubbleView* parent) | 483 ManagePasswordsBubbleView* parent) |
404 : parent_(parent) { | 484 : parent_(parent) { |
405 views::GridLayout* layout = new views::GridLayout(this); | 485 views::GridLayout* layout = new views::GridLayout(this); |
406 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 486 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
407 SetLayoutManager(layout); | 487 SetLayoutManager(layout); |
408 | 488 |
409 // Add the title. | 489 // Add the title. |
410 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 490 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
411 AddTitleRow(layout, parent_->model()); | 491 AddTitleRow(layout, parent_->model()); |
(...skipping 25 matching lines...) Expand all Loading... | |
437 0, DOUBLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); | 517 0, DOUBLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
438 layout->AddView(unblacklist_button_); | 518 layout->AddView(unblacklist_button_); |
439 layout->AddView(done_button_); | 519 layout->AddView(done_button_); |
440 | 520 |
441 // Extra padding for visual awesomeness. | 521 // Extra padding for visual awesomeness. |
442 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 522 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
443 | 523 |
444 parent_->set_initially_focused_view(unblacklist_button_); | 524 parent_->set_initially_focused_view(unblacklist_button_); |
445 } | 525 } |
446 | 526 |
447 ManagePasswordsBubbleView::BlacklistedView::~BlacklistedView() { | |
448 } | |
449 | |
450 void ManagePasswordsBubbleView::BlacklistedView::ButtonPressed( | 527 void ManagePasswordsBubbleView::BlacklistedView::ButtonPressed( |
451 views::Button* sender, | 528 views::Button* sender, |
452 const ui::Event& event) { | 529 const ui::Event& event) { |
453 if (sender == done_button_) | 530 if (sender == done_button_) |
454 parent_->model()->OnDoneClicked(); | 531 parent_->model()->OnDoneClicked(); |
455 else if (sender == unblacklist_button_) | 532 else if (sender == unblacklist_button_) |
456 parent_->model()->OnUnblacklistClicked(); | 533 parent_->model()->OnUnblacklistClicked(); |
457 else | 534 else |
458 NOTREACHED(); | 535 NOTREACHED(); |
459 parent_->Close(); | 536 parent_->Close(); |
460 } | 537 } |
461 | 538 |
462 // ManagePasswordsBubbleView::SaveConfirmationView ---------------------------- | 539 // ManagePasswordsBubbleView::SaveConfirmationView ---------------------------- |
463 | 540 |
541 // A view confirming to the user that a password was saved and offering a link | |
542 // to the Google account manager. | |
543 class ManagePasswordsBubbleView::SaveConfirmationView | |
544 : public views::View, | |
545 public views::ButtonListener, | |
546 public views::StyledLabelListener { | |
547 public: | |
548 explicit SaveConfirmationView(ManagePasswordsBubbleView* parent); | |
549 | |
550 private: | |
551 // views::ButtonListener: | |
552 virtual void ButtonPressed(views::Button* sender, | |
553 const ui::Event& event) OVERRIDE; | |
554 | |
555 // views::StyledLabelListener implementation | |
556 virtual void StyledLabelLinkClicked(const gfx::Range& range, | |
557 int event_flags) OVERRIDE; | |
558 | |
559 ManagePasswordsBubbleView* parent_; | |
560 | |
561 views::LabelButton* ok_button_; | |
562 }; | |
563 | |
464 ManagePasswordsBubbleView::SaveConfirmationView::SaveConfirmationView( | 564 ManagePasswordsBubbleView::SaveConfirmationView::SaveConfirmationView( |
465 ManagePasswordsBubbleView* parent) | 565 ManagePasswordsBubbleView* parent) |
466 : parent_(parent) { | 566 : parent_(parent) { |
467 views::GridLayout* layout = new views::GridLayout(this); | 567 views::GridLayout* layout = new views::GridLayout(this); |
468 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 568 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
469 SetLayoutManager(layout); | 569 SetLayoutManager(layout); |
470 | 570 |
471 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 571 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
472 AddTitleRow(layout, parent_->model()); | 572 AddTitleRow(layout, parent_->model()); |
473 | 573 |
(...skipping 18 matching lines...) Expand all Loading... | |
492 layout->StartRowWithPadding( | 592 layout->StartRowWithPadding( |
493 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); | 593 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
494 layout->AddView(ok_button_); | 594 layout->AddView(ok_button_); |
495 | 595 |
496 // Extra padding for visual awesomeness. | 596 // Extra padding for visual awesomeness. |
497 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 597 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
498 | 598 |
499 parent_->set_initially_focused_view(ok_button_); | 599 parent_->set_initially_focused_view(ok_button_); |
500 } | 600 } |
501 | 601 |
502 ManagePasswordsBubbleView::SaveConfirmationView::~SaveConfirmationView() { | |
503 } | |
504 | |
505 void ManagePasswordsBubbleView::SaveConfirmationView::StyledLabelLinkClicked( | 602 void ManagePasswordsBubbleView::SaveConfirmationView::StyledLabelLinkClicked( |
506 const gfx::Range& range, int event_flags) { | 603 const gfx::Range& range, int event_flags) { |
507 DCHECK_EQ(range, parent_->model()->save_confirmation_link_range()); | 604 DCHECK_EQ(range, parent_->model()->save_confirmation_link_range()); |
508 parent_->model()->OnRemoteManageLinkClicked(); | 605 parent_->model()->OnRemoteManageLinkClicked(); |
509 parent_->Close(); | 606 parent_->Close(); |
510 } | 607 } |
511 | 608 |
512 void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed( | 609 void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed( |
513 views::Button* sender, const ui::Event& event) { | 610 views::Button* sender, const ui::Event& event) { |
514 DCHECK_EQ(sender, ok_button_); | 611 DCHECK_EQ(sender, ok_button_); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
671 screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd; | 768 screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd; |
672 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); | 769 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); |
673 } | 770 } |
674 | 771 |
675 void ManagePasswordsBubbleView::Close() { | 772 void ManagePasswordsBubbleView::Close() { |
676 fadeout_observer_.reset(); | 773 fadeout_observer_.reset(); |
677 mouse_handler_.reset(); | 774 mouse_handler_.reset(); |
678 GetWidget()->Close(); | 775 GetWidget()->Close(); |
679 } | 776 } |
680 | 777 |
681 void ManagePasswordsBubbleView::Init() { | |
682 views::FillLayout* layout = new views::FillLayout(); | |
683 SetLayoutManager(layout); | |
684 | |
685 Refresh(); | |
686 } | |
687 | |
688 void ManagePasswordsBubbleView::WindowClosing() { | |
689 // Close() closes the window asynchronously, so by the time we reach here, | |
690 // |manage_passwords_bubble_| may have already been reset. | |
691 if (manage_passwords_bubble_ == this) | |
692 manage_passwords_bubble_ = NULL; | |
693 } | |
694 | |
695 void ManagePasswordsBubbleView::OnWidgetActivationChanged(views::Widget* widget, | |
696 bool active) { | |
697 if (active && widget == GetWidget()) | |
698 CancelFadingOut(); | |
699 BubbleDelegateView::OnWidgetActivationChanged(widget, active); | |
700 } | |
701 | |
702 views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { | |
703 return initially_focused_view_; | |
704 } | |
705 | |
706 void ManagePasswordsBubbleView::OnMouseEntered(const ui::MouseEvent& event) { | |
707 CancelFadingOut(); | |
708 } | |
709 | |
710 void ManagePasswordsBubbleView::Refresh() { | 778 void ManagePasswordsBubbleView::Refresh() { |
711 RemoveAllChildViews(true); | 779 RemoveAllChildViews(true); |
712 initially_focused_view_ = NULL; | 780 initially_focused_view_ = NULL; |
713 if (password_manager::ui::IsPendingState(model()->state())) { | 781 if (password_manager::ui::IsPendingState(model()->state())) { |
714 if (never_save_passwords_) | 782 if (never_save_passwords_) |
715 AddChildView(new ConfirmNeverView(this)); | 783 AddChildView(new ConfirmNeverView(this)); |
716 else | 784 else |
717 AddChildView(new PendingView(this)); | 785 AddChildView(new PendingView(this)); |
718 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) { | 786 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) { |
719 AddChildView(new BlacklistedView(this)); | 787 AddChildView(new BlacklistedView(this)); |
(...skipping 19 matching lines...) Expand all Loading... | |
739 void ManagePasswordsBubbleView::NotifyConfirmedNeverForThisSite() { | 807 void ManagePasswordsBubbleView::NotifyConfirmedNeverForThisSite() { |
740 model()->OnNeverForThisSiteClicked(); | 808 model()->OnNeverForThisSiteClicked(); |
741 Close(); | 809 Close(); |
742 } | 810 } |
743 | 811 |
744 void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() { | 812 void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() { |
745 never_save_passwords_ = false; | 813 never_save_passwords_ = false; |
746 Refresh(); | 814 Refresh(); |
747 } | 815 } |
748 | 816 |
817 void ManagePasswordsBubbleView::Init() { | |
818 views::FillLayout* layout = new views::FillLayout(); | |
819 SetLayoutManager(layout); | |
820 | |
821 Refresh(); | |
822 } | |
823 | |
824 void ManagePasswordsBubbleView::WindowClosing() { | |
825 // Close() closes the window asynchronously, so by the time we reach here, | |
826 // |manage_passwords_bubble_| may have already been reset. | |
827 if (manage_passwords_bubble_ == this) | |
828 manage_passwords_bubble_ = NULL; | |
829 } | |
830 | |
831 void ManagePasswordsBubbleView::OnWidgetActivationChanged(views::Widget* widget, | |
832 bool active) { | |
833 if (active && widget == GetWidget()) | |
834 CancelFadingOut(); | |
835 BubbleDelegateView::OnWidgetActivationChanged(widget, active); | |
836 } | |
837 | |
838 views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { | |
839 return initially_focused_view_; | |
840 } | |
841 | |
842 void ManagePasswordsBubbleView::OnMouseEntered(const ui::MouseEvent& event) { | |
843 CancelFadingOut(); | |
844 } | |
845 | |
749 void ManagePasswordsBubbleView::StartFadingOut() { | 846 void ManagePasswordsBubbleView::StartFadingOut() { |
750 if (fadeout_observer_) | 847 if (fadeout_observer_) |
751 return; | 848 return; |
752 aura::Window* window = GetWidget()->GetNativeView(); | 849 aura::Window* window = GetWidget()->GetNativeView(); |
753 ui::ScopedLayerAnimationSettings animator(window->layer()->GetAnimator()); | 850 ui::ScopedLayerAnimationSettings animator(window->layer()->GetAnimator()); |
754 fadeout_observer_.reset(new FadeOutObserver(this)); | 851 fadeout_observer_.reset(new FadeOutObserver(this)); |
755 animator.AddObserver(fadeout_observer_.get()); | 852 animator.AddObserver(fadeout_observer_.get()); |
756 animator.SetTransitionDuration( | 853 animator.SetTransitionDuration( |
757 base::TimeDelta::FromSeconds(kBubbleFadeDelay)); | 854 base::TimeDelta::FromSeconds(kBubbleFadeDelay)); |
758 window->layer()->SetOpacity(0); | 855 window->layer()->SetOpacity(0); |
759 } | 856 } |
760 | 857 |
761 void ManagePasswordsBubbleView::CancelFadingOut() { | 858 void ManagePasswordsBubbleView::CancelFadingOut() { |
762 if (!fadeout_observer_) | 859 if (!fadeout_observer_) |
763 return; | 860 return; |
764 fadeout_observer_.reset(); | 861 fadeout_observer_.reset(); |
765 aura::Window* window = GetWidget()->GetNativeView(); | 862 aura::Window* window = GetWidget()->GetNativeView(); |
766 window->layer()->SetOpacity(1); | 863 window->layer()->SetOpacity(1); |
767 } | 864 } |
768 | 865 |
769 void ManagePasswordsBubbleView::OnBubbleDisappeared() { | 866 void ManagePasswordsBubbleView::OnBubbleDisappeared() { |
770 Close(); | 867 Close(); |
771 } | 868 } |
OLD | NEW |