Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/ui/views/page_info/page_info_bubble_view.cc

Issue 2907983002: Allow dialogs to use a custom View as their title. (Closed)
Patch Set: merge Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 535
535 void PageInfoBubbleView::OnChosenObjectDeleted( 536 void PageInfoBubbleView::OnChosenObjectDeleted(
536 const PageInfoUI::ChosenObjectInfo& info) { 537 const PageInfoUI::ChosenObjectInfo& info) {
537 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); 538 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object);
538 } 539 }
539 540
540 base::string16 PageInfoBubbleView::GetWindowTitle() const { 541 base::string16 PageInfoBubbleView::GetWindowTitle() const {
541 return summary_text_; 542 return summary_text_;
542 } 543 }
543 544
545 void PageInfoBubbleView::AddedToWidget() {
546 std::unique_ptr<views::Label> title =
547 views::BubbleFrameView::CreateDefaultTitleLabel(GetWindowTitle());
548 title->SetFontList(
549 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
550 kSummaryFontSizeDelta));
551 GetBubbleFrameView()->SetTitleView(std::move(title));
552 }
553
544 bool PageInfoBubbleView::ShouldShowCloseButton() const { 554 bool PageInfoBubbleView::ShouldShowCloseButton() const {
545 return true; 555 return true;
546 } 556 }
547 557
548 void PageInfoBubbleView::OnWidgetDestroying(views::Widget* widget) { 558 void PageInfoBubbleView::OnWidgetDestroying(views::Widget* widget) {
549 g_shown_bubble_type = BUBBLE_NONE; 559 g_shown_bubble_type = BUBBLE_NONE;
550 g_page_info_bubble = nullptr; 560 g_page_info_bubble = nullptr;
551 presenter_->OnUIClosing(); 561 presenter_->OnUIClosing();
552 } 562 }
553 563
554 int PageInfoBubbleView::GetDialogButtons() const { 564 int PageInfoBubbleView::GetDialogButtons() const {
555 return ui::DIALOG_BUTTON_NONE; 565 return ui::DIALOG_BUTTON_NONE;
556 } 566 }
557 567
558 const gfx::FontList& PageInfoBubbleView::GetTitleFontList() const {
559 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
560 kSummaryFontSizeDelta);
561 }
562
563 void PageInfoBubbleView::ButtonPressed(views::Button* button, 568 void PageInfoBubbleView::ButtonPressed(views::Button* button,
564 const ui::Event& event) { 569 const ui::Event& event) {
565 DCHECK_EQ(VIEW_ID_PAGE_INFO_BUTTON_CLOSE, button->id()); 570 DCHECK_EQ(VIEW_ID_PAGE_INFO_BUTTON_CLOSE, button->id());
566 GetWidget()->Close(); 571 GetWidget()->Close();
567 } 572 }
568 573
569 void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) { 574 void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) {
570 // The bubble closes automatically when the collected cookies dialog or the 575 // The bubble closes automatically when the collected cookies dialog or the
571 // certificate viewer opens. So delay handling of the link clicked to avoid 576 // certificate viewer opens. So delay handling of the link clicked to avoid
572 // a crash in the base class which needs to complete the mouse event handling. 577 // a crash in the base class which needs to complete the mouse event handling.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 site_settings_view_->AddChildView(link_section); 694 site_settings_view_->AddChildView(link_section);
690 695
691 SizeToContents(); 696 SizeToContents();
692 } 697 }
693 698
694 void PageInfoBubbleView::SetIdentityInfo(const IdentityInfo& identity_info) { 699 void PageInfoBubbleView::SetIdentityInfo(const IdentityInfo& identity_info) {
695 std::unique_ptr<PageInfoUI::SecurityDescription> security_description = 700 std::unique_ptr<PageInfoUI::SecurityDescription> security_description =
696 identity_info.GetSecurityDescription(); 701 identity_info.GetSecurityDescription();
697 702
698 summary_text_ = security_description->summary; 703 summary_text_ = security_description->summary;
699 GetWidget()->UpdateWindowTitle(); 704 static_cast<views::Label*>(GetBubbleFrameView()->title())
705 ->SetText(GetWindowTitle());
700 706
701 if (identity_info.certificate) { 707 if (identity_info.certificate) {
702 certificate_ = identity_info.certificate; 708 certificate_ = identity_info.certificate;
703 709
704 if (identity_info.show_ssl_decision_revoke_button) { 710 if (identity_info.show_ssl_decision_revoke_button) {
705 header_->AddResetDecisionsLabel(); 711 header_->AddResetDecisionsLabel();
706 } 712 }
707 713
708 if (PageInfoUI::ShouldShowCertificateLink()) { 714 if (PageInfoUI::ShouldShowCertificateLink()) {
709 // The text of link to the Certificate Viewer varies depending on the 715 // The text of link to the Certificate Viewer varies depending on the
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED); 817 PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED);
812 break; 818 break;
813 case VIEW_ID_PAGE_INFO_LABEL_RESET_CERTIFICATE_DECISIONS: 819 case VIEW_ID_PAGE_INFO_LABEL_RESET_CERTIFICATE_DECISIONS:
814 presenter_->OnRevokeSSLErrorBypassButtonPressed(); 820 presenter_->OnRevokeSSLErrorBypassButtonPressed();
815 GetWidget()->Close(); 821 GetWidget()->Close();
816 break; 822 break;
817 default: 823 default:
818 NOTREACHED(); 824 NOTREACHED();
819 } 825 }
820 } 826 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698