| 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/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 13 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 13 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| 14 #include "chrome/browser/ui/passwords/password_dialog_prompts.h" | 14 #include "chrome/browser/ui/passwords/password_dialog_prompts.h" |
| 15 #include "chrome/browser/ui/passwords/passwords_model_delegate.h" | 15 #include "chrome/browser/ui/passwords/passwords_model_delegate.h" |
| 16 #include "chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_vi
ew.h" |
| 16 #include "chrome/browser/ui/views/frame/browser_view.h" | 17 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 17 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" | 18 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" |
| 18 #include "chrome/browser/ui/views/passwords/credentials_selection_view.h" | 19 #include "chrome/browser/ui/views/passwords/credentials_selection_view.h" |
| 19 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" | 20 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" |
| 20 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" | 21 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" |
| 21 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 22 #include "components/strings/grit/components_strings.h" | 23 #include "components/strings/grit/components_strings.h" |
| 23 #include "content/public/browser/user_metrics.h" | 24 #include "content/public/browser/user_metrics.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/base/material_design/material_design_controller.h" | 26 #include "ui/base/material_design/material_design_controller.h" |
| 26 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 27 #include "ui/views/controls/button/blue_button.h" | 28 #include "ui/views/controls/button/blue_button.h" |
| 28 #include "ui/views/controls/button/md_text_button.h" | 29 #include "ui/views/controls/button/md_text_button.h" |
| 29 #include "ui/views/controls/link.h" | 30 #include "ui/views/controls/link.h" |
| 30 #include "ui/views/controls/link_listener.h" | 31 #include "ui/views/controls/link_listener.h" |
| 31 #include "ui/views/controls/separator.h" | 32 #include "ui/views/controls/separator.h" |
| 32 #include "ui/views/controls/styled_label.h" | 33 #include "ui/views/controls/styled_label.h" |
| 33 #include "ui/views/controls/styled_label_listener.h" | 34 #include "ui/views/controls/styled_label_listener.h" |
| 34 #include "ui/views/layout/fill_layout.h" | 35 #include "ui/views/layout/fill_layout.h" |
| 35 #include "ui/views/layout/grid_layout.h" | 36 #include "ui/views/layout/grid_layout.h" |
| 36 #include "ui/views/layout/layout_constants.h" | 37 #include "ui/views/layout/layout_constants.h" |
| 37 #include "ui/views/widget/widget.h" | 38 #include "ui/views/widget/widget.h" |
| 38 | 39 |
| 39 int ManagePasswordsBubbleView::auto_signin_toast_timeout_ = 3; | 40 int ManagePasswordsBubbleView::auto_signin_toast_timeout_ = 3; |
| 40 | 41 |
| 41 // Helpers -------------------------------------------------------------------- | 42 // Helpers -------------------------------------------------------------------- |
| 42 | 43 |
| 43 namespace { | 44 namespace { |
| 44 | 45 |
| 45 const int kDesiredBubbleWidth = 370; | |
| 46 | |
| 47 enum ColumnSetType { | 46 enum ColumnSetType { |
| 48 // | | (FILL, FILL) | | | 47 // | | (FILL, FILL) | | |
| 49 // Used for the bubble's header, the credentials list, and for simple | 48 // Used for the bubble's header, the credentials list, and for simple |
| 50 // messages like "No passwords". | 49 // messages like "No passwords". |
| 51 SINGLE_VIEW_COLUMN_SET, | 50 SINGLE_VIEW_COLUMN_SET, |
| 52 | 51 |
| 53 // | | (TRAILING, CENTER) | | (TRAILING, CENTER) | | | 52 // | | (TRAILING, CENTER) | | (TRAILING, CENTER) | | |
| 54 // Used for buttons at the bottom of the bubble which should nest at the | 53 // Used for buttons at the bottom of the bubble which should nest at the |
| 55 // bottom-right corner. | 54 // bottom-right corner. |
| 56 DOUBLE_BUTTON_COLUMN_SET, | 55 DOUBLE_BUTTON_COLUMN_SET, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 69 // Used when there are three buttons. | 68 // Used when there are three buttons. |
| 70 TRIPLE_BUTTON_COLUMN_SET, | 69 TRIPLE_BUTTON_COLUMN_SET, |
| 71 }; | 70 }; |
| 72 | 71 |
| 73 enum TextRowType { ROW_SINGLE, ROW_MULTILINE }; | 72 enum TextRowType { ROW_SINGLE, ROW_MULTILINE }; |
| 74 | 73 |
| 75 // Construct an appropriate ColumnSet for the given |type|, and add it | 74 // Construct an appropriate ColumnSet for the given |type|, and add it |
| 76 // to |layout|. | 75 // to |layout|. |
| 77 void BuildColumnSet(views::GridLayout* layout, ColumnSetType type) { | 76 void BuildColumnSet(views::GridLayout* layout, ColumnSetType type) { |
| 78 views::ColumnSet* column_set = layout->AddColumnSet(type); | 77 views::ColumnSet* column_set = layout->AddColumnSet(type); |
| 79 int full_width = kDesiredBubbleWidth; | 78 int full_width = ManagePasswordsBubbleView::kDesiredBubbleWidth; |
| 80 switch (type) { | 79 switch (type) { |
| 81 case SINGLE_VIEW_COLUMN_SET: | 80 case SINGLE_VIEW_COLUMN_SET: |
| 82 column_set->AddColumn(views::GridLayout::FILL, | 81 column_set->AddColumn(views::GridLayout::FILL, |
| 83 views::GridLayout::FILL, | 82 views::GridLayout::FILL, |
| 84 0, | 83 0, |
| 85 views::GridLayout::FIXED, | 84 views::GridLayout::FIXED, |
| 86 full_width, | 85 full_width, |
| 87 0); | 86 0); |
| 88 break; | 87 break; |
| 89 case DOUBLE_BUTTON_COLUMN_SET: | 88 case DOUBLE_BUTTON_COLUMN_SET: |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 327 } |
| 329 | 328 |
| 330 ManagePasswordsBubbleView::PendingView::~PendingView() { | 329 ManagePasswordsBubbleView::PendingView::~PendingView() { |
| 331 } | 330 } |
| 332 | 331 |
| 333 void ManagePasswordsBubbleView::PendingView::ButtonPressed( | 332 void ManagePasswordsBubbleView::PendingView::ButtonPressed( |
| 334 views::Button* sender, | 333 views::Button* sender, |
| 335 const ui::Event& event) { | 334 const ui::Event& event) { |
| 336 if (sender == save_button_) { | 335 if (sender == save_button_) { |
| 337 parent_->model()->OnSaveClicked(); | 336 parent_->model()->OnSaveClicked(); |
| 338 if (parent_->model()->ReplaceToShowSignInPromoIfNeeded()) { | 337 if (parent_->model()->ReplaceToShowPromotionIfNeeded()) { |
| 339 parent_->Refresh(); | 338 parent_->Refresh(); |
| 340 return; | 339 return; |
| 341 } | 340 } |
| 342 } else if (sender == never_button_) { | 341 } else if (sender == never_button_) { |
| 343 parent_->model()->OnNeverForThisSiteClicked(); | 342 parent_->model()->OnNeverForThisSiteClicked(); |
| 344 } else { | 343 } else { |
| 345 NOTREACHED(); | 344 NOTREACHED(); |
| 346 } | 345 } |
| 347 | 346 |
| 348 parent_->CloseBubble(); | 347 parent_->CloseBubble(); |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 | 789 |
| 791 bool ManagePasswordsBubbleView::ShouldShowWindowTitle() const { | 790 bool ManagePasswordsBubbleView::ShouldShowWindowTitle() const { |
| 792 // Since bubble titles don't support links, fall back to a custom title view | 791 // Since bubble titles don't support links, fall back to a custom title view |
| 793 // if we need to show a link. Only use the normal title path if there's no | 792 // if we need to show a link. Only use the normal title path if there's no |
| 794 // link. | 793 // link. |
| 795 return model_.title_brand_link_range().is_empty(); | 794 return model_.title_brand_link_range().is_empty(); |
| 796 } | 795 } |
| 797 | 796 |
| 798 bool ManagePasswordsBubbleView::ShouldShowCloseButton() const { | 797 bool ManagePasswordsBubbleView::ShouldShowCloseButton() const { |
| 799 return model_.state() == password_manager::ui::PENDING_PASSWORD_STATE || | 798 return model_.state() == password_manager::ui::PENDING_PASSWORD_STATE || |
| 800 model_.state() == password_manager::ui::CHROME_SIGN_IN_PROMO_STATE; | 799 model_.state() == password_manager::ui::CHROME_SIGN_IN_PROMO_STATE || |
| 800 model_.state() == password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE; |
| 801 } | 801 } |
| 802 | 802 |
| 803 void ManagePasswordsBubbleView::Refresh() { | 803 void ManagePasswordsBubbleView::Refresh() { |
| 804 RemoveAllChildViews(true); | 804 RemoveAllChildViews(true); |
| 805 initially_focused_view_ = NULL; | 805 initially_focused_view_ = NULL; |
| 806 CreateChild(); | 806 CreateChild(); |
| 807 | 807 |
| 808 // Show/hide the close button. | 808 // Show/hide the close button. |
| 809 GetWidget()->non_client_view()->ResetWindowControls(); | 809 GetWidget()->non_client_view()->ResetWindowControls(); |
| 810 GetWidget()->UpdateWindowTitle(); | 810 GetWidget()->UpdateWindowTitle(); |
| 811 SizeToContents(); | 811 SizeToContents(); |
| 812 } | 812 } |
| 813 | 813 |
| 814 void ManagePasswordsBubbleView::CreateChild() { | 814 void ManagePasswordsBubbleView::CreateChild() { |
| 815 if (model_.state() == password_manager::ui::PENDING_PASSWORD_STATE) { | 815 if (model_.state() == password_manager::ui::PENDING_PASSWORD_STATE) { |
| 816 AddChildView(new PendingView(this)); | 816 AddChildView(new PendingView(this)); |
| 817 } else if (model_.state() == | 817 } else if (model_.state() == |
| 818 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) { | 818 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) { |
| 819 AddChildView(new UpdatePendingView(this)); | 819 AddChildView(new UpdatePendingView(this)); |
| 820 } else if (model_.state() == password_manager::ui::CONFIRMATION_STATE) { | 820 } else if (model_.state() == password_manager::ui::CONFIRMATION_STATE) { |
| 821 AddChildView(new SaveConfirmationView(this)); | 821 AddChildView(new SaveConfirmationView(this)); |
| 822 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) { | 822 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) { |
| 823 AddChildView(new AutoSigninView(this)); | 823 AddChildView(new AutoSigninView(this)); |
| 824 } else if (model_.state() == | 824 } else if (model_.state() == |
| 825 password_manager::ui::CHROME_SIGN_IN_PROMO_STATE) { | 825 password_manager::ui::CHROME_SIGN_IN_PROMO_STATE) { |
| 826 AddChildView(new SignInPromoView(this)); | 826 AddChildView(new SignInPromoView(this)); |
| 827 } else if (model_.state() == |
| 828 password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE) { |
| 829 AddChildView(new DesktopIOSPromotionView( |
| 830 desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE)); |
| 827 } else { | 831 } else { |
| 828 AddChildView(new ManageView(this)); | 832 AddChildView(new ManageView(this)); |
| 829 } | 833 } |
| 830 } | 834 } |
| OLD | NEW |