OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/page_info/page_info_bubble_view.h" | 5 #include "chrome/browser/ui/views/page_info/page_info_bubble_view.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 27 matching lines...) Expand all Loading... | |
38 #include "extensions/common/constants.h" | 38 #include "extensions/common/constants.h" |
39 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
40 #include "ui/base/material_design/material_design_controller.h" | 40 #include "ui/base/material_design/material_design_controller.h" |
41 #include "ui/base/models/simple_menu_model.h" | 41 #include "ui/base/models/simple_menu_model.h" |
42 #include "ui/base/resource/resource_bundle.h" | 42 #include "ui/base/resource/resource_bundle.h" |
43 #include "ui/gfx/canvas.h" | 43 #include "ui/gfx/canvas.h" |
44 #include "ui/gfx/font_list.h" | 44 #include "ui/gfx/font_list.h" |
45 #include "ui/gfx/geometry/insets.h" | 45 #include "ui/gfx/geometry/insets.h" |
46 #include "ui/gfx/image/image.h" | 46 #include "ui/gfx/image/image.h" |
47 #include "ui/views/border.h" | 47 #include "ui/views/border.h" |
48 #include "ui/views/bubble/bubble_frame_view.h" | |
48 #include "ui/views/controls/button/image_button.h" | 49 #include "ui/views/controls/button/image_button.h" |
49 #include "ui/views/controls/button/md_text_button.h" | 50 #include "ui/views/controls/button/md_text_button.h" |
50 #include "ui/views/controls/image_view.h" | 51 #include "ui/views/controls/image_view.h" |
51 #include "ui/views/controls/label.h" | 52 #include "ui/views/controls/label.h" |
52 #include "ui/views/controls/link.h" | 53 #include "ui/views/controls/link.h" |
53 #include "ui/views/controls/styled_label.h" | 54 #include "ui/views/controls/styled_label.h" |
54 #include "ui/views/layout/box_layout.h" | 55 #include "ui/views/layout/box_layout.h" |
55 #include "ui/views/layout/grid_layout.h" | 56 #include "ui/views/layout/grid_layout.h" |
56 #include "ui/views/layout/layout_manager.h" | 57 #include "ui/views/layout/layout_manager.h" |
57 #include "ui/views/view.h" | 58 #include "ui/views/view.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 views::View* anchor_view, | 429 views::View* anchor_view, |
429 gfx::NativeView parent_window, | 430 gfx::NativeView parent_window, |
430 Profile* profile, | 431 Profile* profile, |
431 content::WebContents* web_contents, | 432 content::WebContents* web_contents, |
432 const GURL& url, | 433 const GURL& url, |
433 const security_state::SecurityInfo& security_info) | 434 const security_state::SecurityInfo& security_info) |
434 : content::WebContentsObserver(web_contents), | 435 : content::WebContentsObserver(web_contents), |
435 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), | 436 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), |
436 profile_(profile), | 437 profile_(profile), |
437 header_(nullptr), | 438 header_(nullptr), |
439 title_(nullptr), | |
438 separator_(nullptr), | 440 separator_(nullptr), |
439 site_settings_view_(nullptr), | 441 site_settings_view_(nullptr), |
440 cookie_dialog_link_(nullptr), | 442 cookie_dialog_link_(nullptr), |
441 permissions_view_(nullptr), | 443 permissions_view_(nullptr), |
442 weak_factory_(this) { | 444 weak_factory_(this) { |
443 g_shown_bubble_type = BUBBLE_PAGE_INFO; | 445 g_shown_bubble_type = BUBBLE_PAGE_INFO; |
444 g_page_info_bubble = this; | 446 g_page_info_bubble = this; |
445 set_parent_window(parent_window); | 447 set_parent_window(parent_window); |
446 | 448 |
447 // Compensate for built-in vertical padding in the anchor view's image. | 449 // Compensate for built-in vertical padding in the anchor view's image. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 | 529 |
528 void PageInfoBubbleView::OnChosenObjectDeleted( | 530 void PageInfoBubbleView::OnChosenObjectDeleted( |
529 const PageInfoUI::ChosenObjectInfo& info) { | 531 const PageInfoUI::ChosenObjectInfo& info) { |
530 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); | 532 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); |
531 } | 533 } |
532 | 534 |
533 base::string16 PageInfoBubbleView::GetWindowTitle() const { | 535 base::string16 PageInfoBubbleView::GetWindowTitle() const { |
534 return summary_text_; | 536 return summary_text_; |
535 } | 537 } |
536 | 538 |
539 void PageInfoBubbleView::AddedToWidget() { | |
540 title_ = views::BubbleFrameView::CreateDefaultTitleLabel(GetWindowTitle()) | |
541 .release(); | |
542 title_->SetFontList( | |
543 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( | |
544 kSummaryFontSizeDelta)); | |
545 GetBubbleFrameView()->SetTitleView(title_); | |
Peter Kasting
2017/06/23 06:00:09
SetTitleView() basically "takes ownership" of this
Bret
2017/06/24 01:12:33
Done.
| |
546 } | |
547 | |
537 bool PageInfoBubbleView::ShouldShowCloseButton() const { | 548 bool PageInfoBubbleView::ShouldShowCloseButton() const { |
538 return true; | 549 return true; |
539 } | 550 } |
540 | 551 |
541 void PageInfoBubbleView::OnWidgetDestroying(views::Widget* widget) { | 552 void PageInfoBubbleView::OnWidgetDestroying(views::Widget* widget) { |
542 g_shown_bubble_type = BUBBLE_NONE; | 553 g_shown_bubble_type = BUBBLE_NONE; |
543 g_page_info_bubble = nullptr; | 554 g_page_info_bubble = nullptr; |
544 presenter_->OnUIClosing(); | 555 presenter_->OnUIClosing(); |
545 } | 556 } |
546 | 557 |
547 int PageInfoBubbleView::GetDialogButtons() const { | 558 int PageInfoBubbleView::GetDialogButtons() const { |
548 return ui::DIALOG_BUTTON_NONE; | 559 return ui::DIALOG_BUTTON_NONE; |
549 } | 560 } |
550 | 561 |
551 const gfx::FontList& PageInfoBubbleView::GetTitleFontList() const { | |
552 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( | |
553 kSummaryFontSizeDelta); | |
554 } | |
555 | |
556 void PageInfoBubbleView::ButtonPressed(views::Button* button, | 562 void PageInfoBubbleView::ButtonPressed(views::Button* button, |
557 const ui::Event& event) { | 563 const ui::Event& event) { |
558 DCHECK_EQ(VIEW_ID_PAGE_INFO_BUTTON_CLOSE, button->id()); | 564 DCHECK_EQ(VIEW_ID_PAGE_INFO_BUTTON_CLOSE, button->id()); |
559 GetWidget()->Close(); | 565 GetWidget()->Close(); |
560 } | 566 } |
561 | 567 |
562 void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) { | 568 void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) { |
563 // The bubble closes automatically when the collected cookies dialog or the | 569 // The bubble closes automatically when the collected cookies dialog or the |
564 // certificate viewer opens. So delay handling of the link clicked to avoid | 570 // certificate viewer opens. So delay handling of the link clicked to avoid |
565 // a crash in the base class which needs to complete the mouse event handling. | 571 // a crash in the base class which needs to complete the mouse event handling. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
675 site_settings_view_->AddChildView(link_section); | 681 site_settings_view_->AddChildView(link_section); |
676 | 682 |
677 SizeToContents(); | 683 SizeToContents(); |
678 } | 684 } |
679 | 685 |
680 void PageInfoBubbleView::SetIdentityInfo(const IdentityInfo& identity_info) { | 686 void PageInfoBubbleView::SetIdentityInfo(const IdentityInfo& identity_info) { |
681 std::unique_ptr<PageInfoUI::SecurityDescription> security_description = | 687 std::unique_ptr<PageInfoUI::SecurityDescription> security_description = |
682 identity_info.GetSecurityDescription(); | 688 identity_info.GetSecurityDescription(); |
683 | 689 |
684 summary_text_ = security_description->summary; | 690 summary_text_ = security_description->summary; |
685 GetWidget()->UpdateWindowTitle(); | 691 title_->SetText(GetWindowTitle()); |
Peter Kasting
2017/06/23 06:00:09
If the BubbleFrameView exposed the title() methods
Bret
2017/06/24 01:12:32
The new patchset has this version. I'm not sure wh
| |
686 | 692 |
687 if (identity_info.certificate) { | 693 if (identity_info.certificate) { |
688 certificate_ = identity_info.certificate; | 694 certificate_ = identity_info.certificate; |
689 | 695 |
690 if (identity_info.show_ssl_decision_revoke_button) | 696 if (identity_info.show_ssl_decision_revoke_button) |
691 header_->AddResetDecisionsLabel(); | 697 header_->AddResetDecisionsLabel(); |
692 | 698 |
693 if (PageInfoUI::ShouldShowCertificateLink()) { | 699 if (PageInfoUI::ShouldShowCertificateLink()) { |
694 // The text of link to the Certificate Viewer varies depending on the | 700 // The text of link to the Certificate Viewer varies depending on the |
695 // validity of the Certificate. | 701 // validity of the Certificate. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
795 PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED); | 801 PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED); |
796 break; | 802 break; |
797 case VIEW_ID_PAGE_INFO_LABEL_RESET_CERTIFICATE_DECISIONS: | 803 case VIEW_ID_PAGE_INFO_LABEL_RESET_CERTIFICATE_DECISIONS: |
798 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 804 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
799 GetWidget()->Close(); | 805 GetWidget()->Close(); |
800 break; | 806 break; |
801 default: | 807 default: |
802 NOTREACHED(); | 808 NOTREACHED(); |
803 } | 809 } |
804 } | 810 } |
OLD | NEW |