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/metrics/user_metrics.h" | 8 #include "base/metrics/user_metrics.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" | 25 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" |
26 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
27 #include "components/strings/grit/components_strings.h" | 27 #include "components/strings/grit/components_strings.h" |
28 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
29 #include "ui/base/material_design/material_design_controller.h" | 29 #include "ui/base/material_design/material_design_controller.h" |
30 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
31 #include "ui/base/ui_features.h" | 31 #include "ui/base/ui_features.h" |
32 #include "ui/gfx/color_palette.h" | 32 #include "ui/gfx/color_palette.h" |
33 #include "ui/gfx/image/image_skia.h" | 33 #include "ui/gfx/image/image_skia.h" |
34 #include "ui/native_theme/native_theme.h" | 34 #include "ui/native_theme/native_theme.h" |
35 #include "ui/views/bubble/bubble_frame_view.h" | |
35 #include "ui/views/controls/button/blue_button.h" | 36 #include "ui/views/controls/button/blue_button.h" |
36 #include "ui/views/controls/button/md_text_button.h" | 37 #include "ui/views/controls/button/md_text_button.h" |
37 #include "ui/views/controls/link.h" | 38 #include "ui/views/controls/link.h" |
38 #include "ui/views/controls/link_listener.h" | 39 #include "ui/views/controls/link_listener.h" |
39 #include "ui/views/controls/separator.h" | 40 #include "ui/views/controls/separator.h" |
40 #include "ui/views/controls/styled_label.h" | 41 #include "ui/views/controls/styled_label.h" |
41 #include "ui/views/controls/styled_label_listener.h" | |
42 #include "ui/views/layout/fill_layout.h" | 42 #include "ui/views/layout/fill_layout.h" |
43 #include "ui/views/layout/grid_layout.h" | 43 #include "ui/views/layout/grid_layout.h" |
44 #include "ui/views/widget/widget.h" | 44 #include "ui/views/widget/widget.h" |
45 | 45 |
46 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) | 46 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) |
47 #include "chrome/browser/ui/views/frame/browser_view.h" | 47 #include "chrome/browser/ui/views/frame/browser_view.h" |
48 #endif | 48 #endif |
49 | 49 |
50 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
51 #include "chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bu bble_view.h" | 51 #include "chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bu bble_view.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 break; | 163 break; |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 views::StyledLabel::RangeStyleInfo GetLinkStyle() { | 167 views::StyledLabel::RangeStyleInfo GetLinkStyle() { |
168 auto result = views::StyledLabel::RangeStyleInfo::CreateForLink(); | 168 auto result = views::StyledLabel::RangeStyleInfo::CreateForLink(); |
169 result.disable_line_wrapping = false; | 169 result.disable_line_wrapping = false; |
170 return result; | 170 return result; |
171 } | 171 } |
172 | 172 |
173 // If a special title is required (i.e. one that contains links), creates a | |
174 // title view and a row for it in |layout|. | |
175 // TODO(estade): this should be removed and a replaced by a normal title (via | |
176 // GetWindowTitle). | |
177 void AddTitleRowWithLink(views::GridLayout* layout, | |
178 ManagePasswordsBubbleModel* model, | |
179 views::StyledLabelListener* listener) { | |
180 if (model->title_brand_link_range().is_empty()) | |
181 return; | |
182 | |
183 views::StyledLabel* title_label = | |
184 new views::StyledLabel(model->title(), listener); | |
185 title_label->SetBaseFontList(views::style::GetFont( | |
186 views::style::CONTEXT_DIALOG_TITLE, views::style::STYLE_PRIMARY)); | |
187 title_label->AddStyleRange(model->title_brand_link_range(), GetLinkStyle()); | |
188 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | |
189 layout->AddView(title_label); | |
190 layout->AddPaddingRow(0, ChromeLayoutProvider::Get() | |
191 ->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS) | |
192 .top()); | |
193 } | |
194 | |
195 } // namespace | 173 } // namespace |
196 | 174 |
197 // ManagePasswordsBubbleView::AutoSigninView ---------------------------------- | 175 // ManagePasswordsBubbleView::AutoSigninView ---------------------------------- |
198 | 176 |
199 // A view containing just one credential that was used for for automatic signing | 177 // A view containing just one credential that was used for for automatic signing |
200 // in. | 178 // in. |
201 class ManagePasswordsBubbleView::AutoSigninView | 179 class ManagePasswordsBubbleView::AutoSigninView |
202 : public views::View, | 180 : public views::View, |
203 public views::ButtonListener, | 181 public views::ButtonListener, |
204 public views::WidgetObserver { | 182 public views::WidgetObserver { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 void ManagePasswordsBubbleView::AutoSigninView::OnTimer() { | 261 void ManagePasswordsBubbleView::AutoSigninView::OnTimer() { |
284 parent_->model()->OnAutoSignInToastTimeout(); | 262 parent_->model()->OnAutoSignInToastTimeout(); |
285 parent_->CloseBubble(); | 263 parent_->CloseBubble(); |
286 } | 264 } |
287 | 265 |
288 // ManagePasswordsBubbleView::PendingView ------------------------------------- | 266 // ManagePasswordsBubbleView::PendingView ------------------------------------- |
289 | 267 |
290 // A view offering the user the ability to save credentials. Contains a | 268 // A view offering the user the ability to save credentials. Contains a |
291 // single ManagePasswordItemsView, along with a "Save Passwords" button | 269 // single ManagePasswordItemsView, along with a "Save Passwords" button |
292 // and a "Never" button. | 270 // and a "Never" button. |
293 class ManagePasswordsBubbleView::PendingView | 271 class ManagePasswordsBubbleView::PendingView : public views::View, |
294 : public views::View, | 272 public views::ButtonListener { |
295 public views::ButtonListener, | |
296 public views::StyledLabelListener { | |
297 public: | 273 public: |
298 explicit PendingView(ManagePasswordsBubbleView* parent); | 274 explicit PendingView(ManagePasswordsBubbleView* parent); |
299 ~PendingView() override; | 275 ~PendingView() override; |
300 | 276 |
301 private: | 277 private: |
302 // views::ButtonListener: | 278 // views::ButtonListener: |
303 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 279 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
304 | 280 |
305 // views::StyledLabelListener: | |
306 void StyledLabelLinkClicked(views::StyledLabel* label, | |
307 const gfx::Range& range, | |
308 int event_flags) override; | |
309 | |
310 ManagePasswordsBubbleView* parent_; | 281 ManagePasswordsBubbleView* parent_; |
311 | 282 |
312 views::Button* save_button_; | 283 views::Button* save_button_; |
313 views::Button* never_button_; | 284 views::Button* never_button_; |
314 | 285 |
315 DISALLOW_COPY_AND_ASSIGN(PendingView); | 286 DISALLOW_COPY_AND_ASSIGN(PendingView); |
316 }; | 287 }; |
317 | 288 |
318 ManagePasswordsBubbleView::PendingView::PendingView( | 289 ManagePasswordsBubbleView::PendingView::PendingView( |
319 ManagePasswordsBubbleView* parent) | 290 ManagePasswordsBubbleView* parent) |
320 : parent_(parent) { | 291 : parent_(parent) { |
321 views::GridLayout* layout = new views::GridLayout(this); | 292 views::GridLayout* layout = new views::GridLayout(this); |
322 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 293 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
323 SetLayoutManager(layout); | 294 SetLayoutManager(layout); |
324 | 295 |
325 // Create the pending credential item, save button and refusal combobox. | 296 // Create the pending credential item, save button and refusal combobox. |
326 ManagePasswordItemsView* item = nullptr; | 297 ManagePasswordItemsView* item = nullptr; |
327 if (!parent->model()->pending_password().username_value.empty()) { | 298 if (!parent->model()->pending_password().username_value.empty()) { |
328 item = new ManagePasswordItemsView(parent_->model(), | 299 item = new ManagePasswordItemsView(parent_->model(), |
329 &parent->model()->pending_password()); | 300 &parent->model()->pending_password()); |
330 } | 301 } |
331 save_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( | 302 save_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( |
332 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); | 303 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); |
333 never_button_ = views::MdTextButton::CreateSecondaryUiButton( | 304 never_button_ = views::MdTextButton::CreateSecondaryUiButton( |
334 this, | 305 this, |
335 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BUBBLE_BLACKLIST_BUTTON)); | 306 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BUBBLE_BLACKLIST_BUTTON)); |
336 | 307 |
337 // Title row. | |
338 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 308 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
339 AddTitleRowWithLink(layout, parent_->model(), this); | |
340 | 309 |
341 // Credential row. | 310 // Credential row. |
342 if (item) { | 311 if (item) { |
343 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 312 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
344 layout->AddView(item); | 313 layout->AddView(item); |
345 layout->AddPaddingRow(0, | 314 layout->AddPaddingRow(0, |
346 ChromeLayoutProvider::Get() | 315 ChromeLayoutProvider::Get() |
347 ->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS) | 316 ->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS) |
348 .bottom()); | 317 .bottom()); |
349 } | 318 } |
(...skipping 21 matching lines...) Expand all Loading... | |
371 } | 340 } |
372 } else if (sender == never_button_) { | 341 } else if (sender == never_button_) { |
373 parent_->model()->OnNeverForThisSiteClicked(); | 342 parent_->model()->OnNeverForThisSiteClicked(); |
374 } else { | 343 } else { |
375 NOTREACHED(); | 344 NOTREACHED(); |
376 } | 345 } |
377 | 346 |
378 parent_->CloseBubble(); | 347 parent_->CloseBubble(); |
379 } | 348 } |
380 | 349 |
381 void ManagePasswordsBubbleView::PendingView::StyledLabelLinkClicked( | |
382 views::StyledLabel* label, | |
383 const gfx::Range& range, | |
384 int event_flags) { | |
385 DCHECK_EQ(range, parent_->model()->title_brand_link_range()); | |
386 parent_->model()->OnBrandLinkClicked(); | |
387 } | |
388 | |
389 // ManagePasswordsBubbleView::ManageView -------------------------------------- | 350 // ManagePasswordsBubbleView::ManageView -------------------------------------- |
390 | 351 |
391 // A view offering the user a list of their currently saved credentials | 352 // A view offering the user a list of their currently saved credentials |
392 // for the current page, along with a "Manage passwords" link and a | 353 // for the current page, along with a "Manage passwords" link and a |
393 // "Done" button. | 354 // "Done" button. |
394 class ManagePasswordsBubbleView::ManageView : public views::View, | 355 class ManagePasswordsBubbleView::ManageView : public views::View, |
395 public views::ButtonListener, | 356 public views::ButtonListener, |
396 public views::LinkListener { | 357 public views::LinkListener { |
397 public: | 358 public: |
398 explicit ManageView(ManagePasswordsBubbleView* parent); | 359 explicit ManageView(ManagePasswordsBubbleView* parent); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
619 } | 580 } |
620 | 581 |
621 // ManagePasswordsBubbleView::UpdatePendingView ------------------------------- | 582 // ManagePasswordsBubbleView::UpdatePendingView ------------------------------- |
622 | 583 |
623 // A view offering the user the ability to update credentials. Contains a | 584 // A view offering the user the ability to update credentials. Contains a |
624 // single ManagePasswordItemsView (in case of one credentials) or | 585 // single ManagePasswordItemsView (in case of one credentials) or |
625 // CredentialsSelectionView otherwise, along with a "Update Passwords" button | 586 // CredentialsSelectionView otherwise, along with a "Update Passwords" button |
626 // and a rejection button. | 587 // and a rejection button. |
627 class ManagePasswordsBubbleView::UpdatePendingView | 588 class ManagePasswordsBubbleView::UpdatePendingView |
628 : public views::View, | 589 : public views::View, |
629 public views::ButtonListener, | 590 public views::ButtonListener { |
630 public views::StyledLabelListener { | |
631 public: | 591 public: |
632 explicit UpdatePendingView(ManagePasswordsBubbleView* parent); | 592 explicit UpdatePendingView(ManagePasswordsBubbleView* parent); |
633 ~UpdatePendingView() override; | 593 ~UpdatePendingView() override; |
634 | 594 |
635 private: | 595 private: |
636 // views::ButtonListener: | 596 // views::ButtonListener: |
637 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 597 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
638 | 598 |
639 // views::StyledLabelListener: | |
640 void StyledLabelLinkClicked(views::StyledLabel* label, | |
641 const gfx::Range& range, | |
642 int event_flags) override; | |
643 | |
644 ManagePasswordsBubbleView* parent_; | 599 ManagePasswordsBubbleView* parent_; |
645 | 600 |
646 CredentialsSelectionView* selection_view_; | 601 CredentialsSelectionView* selection_view_; |
647 | 602 |
648 views::Button* update_button_; | 603 views::Button* update_button_; |
649 views::Button* nope_button_; | 604 views::Button* nope_button_; |
650 | 605 |
651 DISALLOW_COPY_AND_ASSIGN(UpdatePendingView); | 606 DISALLOW_COPY_AND_ASSIGN(UpdatePendingView); |
652 }; | 607 }; |
653 | 608 |
(...skipping 13 matching lines...) Expand all Loading... | |
667 } else { | 622 } else { |
668 item = new ManagePasswordItemsView(parent_->model(), | 623 item = new ManagePasswordItemsView(parent_->model(), |
669 &parent->model()->pending_password()); | 624 &parent->model()->pending_password()); |
670 } | 625 } |
671 nope_button_ = views::MdTextButton::CreateSecondaryUiButton( | 626 nope_button_ = views::MdTextButton::CreateSecondaryUiButton( |
672 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON)); | 627 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON)); |
673 | 628 |
674 update_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( | 629 update_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( |
675 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UPDATE_BUTTON)); | 630 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UPDATE_BUTTON)); |
676 | 631 |
677 // Title row. | |
678 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 632 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
679 AddTitleRowWithLink(layout, parent_->model(), this); | |
680 | 633 |
681 // Credential row. | 634 // Credential row. |
682 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 635 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
683 layout->AddView(item); | 636 layout->AddView(item); |
684 layout->AddPaddingRow( | 637 layout->AddPaddingRow( |
685 0, | 638 0, |
686 layout_provider->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS).bottom()); | 639 layout_provider->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS).bottom()); |
687 | 640 |
688 // Button row. | 641 // Button row. |
689 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); | 642 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); |
(...skipping 19 matching lines...) Expand all Loading... | |
709 *selection_view_->GetSelectedCredentials()); | 662 *selection_view_->GetSelectedCredentials()); |
710 } else { | 663 } else { |
711 parent_->model()->OnUpdateClicked(parent_->model()->pending_password()); | 664 parent_->model()->OnUpdateClicked(parent_->model()->pending_password()); |
712 } | 665 } |
713 } else { | 666 } else { |
714 parent_->model()->OnNopeUpdateClicked(); | 667 parent_->model()->OnNopeUpdateClicked(); |
715 } | 668 } |
716 parent_->CloseBubble(); | 669 parent_->CloseBubble(); |
717 } | 670 } |
718 | 671 |
719 void ManagePasswordsBubbleView::UpdatePendingView::StyledLabelLinkClicked( | |
720 views::StyledLabel* label, | |
721 const gfx::Range& range, | |
722 int event_flags) { | |
723 DCHECK_EQ(range, parent_->model()->title_brand_link_range()); | |
724 parent_->model()->OnBrandLinkClicked(); | |
725 } | |
726 | |
727 // ManagePasswordsBubbleView -------------------------------------------------- | 672 // ManagePasswordsBubbleView -------------------------------------------------- |
728 | 673 |
729 // static | 674 // static |
730 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ = | 675 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ = |
731 NULL; | 676 NULL; |
732 | 677 |
733 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) | 678 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) |
734 // static | 679 // static |
735 void ManagePasswordsBubbleView::ShowBubble( | 680 void ManagePasswordsBubbleView::ShowBubble( |
736 content::WebContents* web_contents, | 681 content::WebContents* web_contents, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
795 | 740 |
796 ManagePasswordsBubbleView::ManagePasswordsBubbleView( | 741 ManagePasswordsBubbleView::ManagePasswordsBubbleView( |
797 content::WebContents* web_contents, | 742 content::WebContents* web_contents, |
798 views::View* anchor_view, | 743 views::View* anchor_view, |
799 const gfx::Point& anchor_point, | 744 const gfx::Point& anchor_point, |
800 DisplayReason reason) | 745 DisplayReason reason) |
801 : LocationBarBubbleDelegateView(anchor_view, anchor_point, web_contents), | 746 : LocationBarBubbleDelegateView(anchor_view, anchor_point, web_contents), |
802 model_(PasswordsModelDelegateFromWebContents(web_contents), | 747 model_(PasswordsModelDelegateFromWebContents(web_contents), |
803 reason == AUTOMATIC ? ManagePasswordsBubbleModel::AUTOMATIC | 748 reason == AUTOMATIC ? ManagePasswordsBubbleModel::AUTOMATIC |
804 : ManagePasswordsBubbleModel::USER_ACTION), | 749 : ManagePasswordsBubbleModel::USER_ACTION), |
805 initially_focused_view_(nullptr) { | 750 initially_focused_view_(nullptr), |
751 title_view_(nullptr) { | |
806 mouse_handler_.reset(new WebContentMouseHandler(this, this->web_contents())); | 752 mouse_handler_.reset(new WebContentMouseHandler(this, this->web_contents())); |
807 manage_passwords_bubble_ = this; | 753 manage_passwords_bubble_ = this; |
808 chrome::RecordDialogCreation(chrome::DialogIdentifier::MANAGE_PASSWORDS); | 754 chrome::RecordDialogCreation(chrome::DialogIdentifier::MANAGE_PASSWORDS); |
809 } | 755 } |
810 | 756 |
811 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() { | 757 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() { |
812 if (manage_passwords_bubble_ == this) | 758 if (manage_passwords_bubble_ == this) |
813 manage_passwords_bubble_ = nullptr; | 759 manage_passwords_bubble_ = nullptr; |
814 } | 760 } |
815 | 761 |
(...skipping 10 matching lines...) Expand all Loading... | |
826 SetLayoutManager(new views::FillLayout); | 772 SetLayoutManager(new views::FillLayout); |
827 | 773 |
828 CreateChild(); | 774 CreateChild(); |
829 } | 775 } |
830 | 776 |
831 void ManagePasswordsBubbleView::CloseBubble() { | 777 void ManagePasswordsBubbleView::CloseBubble() { |
832 mouse_handler_.reset(); | 778 mouse_handler_.reset(); |
833 LocationBarBubbleDelegateView::CloseBubble(); | 779 LocationBarBubbleDelegateView::CloseBubble(); |
834 } | 780 } |
835 | 781 |
782 void ManagePasswordsBubbleView::AddedToWidget() { | |
783 title_view_ = new views::StyledLabel(base::string16(), this); | |
784 title_view_->SetBaseFontList(views::style::GetFont( | |
785 views::style::CONTEXT_DIALOG_TITLE, views::style::STYLE_PRIMARY)); | |
786 UpdateTitleText(); | |
787 GetBubbleFrameView()->SetTitleView(title_view_); | |
788 } | |
789 | |
790 void ManagePasswordsBubbleView::UpdateTitleText() { | |
791 title_view_->SetText(GetWindowTitle()); | |
Peter Kasting
2017/06/23 06:00:09
Same comment applies as in ManagePasswordsBubbleVi
Bret
2017/06/24 01:12:33
Done.
| |
792 if (!model_.title_brand_link_range().is_empty()) | |
793 title_view_->AddStyleRange(model_.title_brand_link_range(), GetLinkStyle()); | |
794 } | |
795 | |
836 base::string16 ManagePasswordsBubbleView::GetWindowTitle() const { | 796 base::string16 ManagePasswordsBubbleView::GetWindowTitle() const { |
837 return model_.title(); | 797 return model_.title(); |
838 } | 798 } |
839 | 799 |
840 gfx::ImageSkia ManagePasswordsBubbleView::GetWindowIcon() { | 800 gfx::ImageSkia ManagePasswordsBubbleView::GetWindowIcon() { |
841 #if defined(OS_WIN) | 801 #if defined(OS_WIN) |
842 if (model_.state() == password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE) { | 802 if (model_.state() == password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE) { |
843 return desktop_ios_promotion::GetPromoImage( | 803 return desktop_ios_promotion::GetPromoImage( |
844 GetNativeTheme()->GetSystemColor( | 804 GetNativeTheme()->GetSystemColor( |
845 ui::NativeTheme::kColorId_TextfieldDefaultColor)); | 805 ui::NativeTheme::kColorId_TextfieldDefaultColor)); |
846 } | 806 } |
847 #endif | 807 #endif |
848 return gfx::ImageSkia(); | 808 return gfx::ImageSkia(); |
849 } | 809 } |
850 | 810 |
851 bool ManagePasswordsBubbleView::ShouldShowWindowTitle() const { | |
852 // Since bubble titles don't support links, fall back to a custom title view | |
853 // if we need to show a link. Only use the normal title path if there's no | |
854 // link. | |
855 return model_.title_brand_link_range().is_empty(); | |
856 } | |
857 | |
858 bool ManagePasswordsBubbleView::ShouldShowWindowIcon() const { | 811 bool ManagePasswordsBubbleView::ShouldShowWindowIcon() const { |
859 return model_.state() == password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE; | 812 return model_.state() == password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE; |
860 } | 813 } |
861 | 814 |
862 bool ManagePasswordsBubbleView::ShouldShowCloseButton() const { | 815 bool ManagePasswordsBubbleView::ShouldShowCloseButton() const { |
863 return model_.state() == password_manager::ui::PENDING_PASSWORD_STATE || | 816 return model_.state() == password_manager::ui::PENDING_PASSWORD_STATE || |
864 model_.state() == password_manager::ui::CHROME_SIGN_IN_PROMO_STATE || | 817 model_.state() == password_manager::ui::CHROME_SIGN_IN_PROMO_STATE || |
865 model_.state() == password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE; | 818 model_.state() == password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE; |
866 } | 819 } |
867 | 820 |
821 void ManagePasswordsBubbleView::StyledLabelLinkClicked( | |
822 views::StyledLabel* label, | |
823 const gfx::Range& range, | |
824 int event_flags) { | |
825 DCHECK_EQ(model_.title_brand_link_range(), range); | |
826 model_.OnBrandLinkClicked(); | |
827 } | |
828 | |
868 void ManagePasswordsBubbleView::Refresh() { | 829 void ManagePasswordsBubbleView::Refresh() { |
869 RemoveAllChildViews(true); | 830 RemoveAllChildViews(true); |
870 initially_focused_view_ = NULL; | 831 initially_focused_view_ = NULL; |
871 CreateChild(); | 832 CreateChild(); |
872 // Show/hide the close button. | 833 // Show/hide the close button. |
873 GetWidget()->non_client_view()->ResetWindowControls(); | 834 GetWidget()->non_client_view()->ResetWindowControls(); |
874 GetWidget()->UpdateWindowIcon(); | 835 GetWidget()->UpdateWindowIcon(); |
875 GetWidget()->UpdateWindowTitle(); | 836 UpdateTitleText(); |
876 if (model_.state() == password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE) { | 837 if (model_.state() == password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE) { |
877 // Update the height and keep the existing width. | 838 // Update the height and keep the existing width. |
878 gfx::Rect bubble_bounds = GetWidget()->GetWindowBoundsInScreen(); | 839 gfx::Rect bubble_bounds = GetWidget()->GetWindowBoundsInScreen(); |
879 bubble_bounds.set_height( | 840 bubble_bounds.set_height( |
880 GetWidget()->GetRootView()->GetHeightForWidth(bubble_bounds.width())); | 841 GetWidget()->GetRootView()->GetHeightForWidth(bubble_bounds.width())); |
881 GetWidget()->SetBounds(bubble_bounds); | 842 GetWidget()->SetBounds(bubble_bounds); |
882 } else { | 843 } else { |
883 SizeToContents(); | 844 SizeToContents(); |
884 } | 845 } |
885 } | 846 } |
(...skipping 15 matching lines...) Expand all Loading... | |
901 } else if (model_.state() == | 862 } else if (model_.state() == |
902 password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE) { | 863 password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE) { |
903 AddChildView(new DesktopIOSPromotionBubbleView( | 864 AddChildView(new DesktopIOSPromotionBubbleView( |
904 model_.GetProfile(), | 865 model_.GetProfile(), |
905 desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE)); | 866 desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE)); |
906 #endif | 867 #endif |
907 } else { | 868 } else { |
908 AddChildView(new ManageView(this)); | 869 AddChildView(new ManageView(this)); |
909 } | 870 } |
910 } | 871 } |
OLD | NEW |