Chromium Code Reviews| Index: chrome/browser/ui/views/website_settings/website_settings_popup_view.cc |
| diff --git a/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc b/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc |
| index 54229954826b7a0420da6b852ea3c14a066b8097..d809da46926a2e573dc9f36bbfba4f56c37fb134 100644 |
| --- a/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc |
| +++ b/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc |
| @@ -141,13 +141,18 @@ class PopupHeaderView : public views::View { |
| // displayed. |
| class InternalPageInfoPopupView : public views::BubbleDelegateView { |
| public: |
| - explicit InternalPageInfoPopupView(views::View* anchor_view); |
| + // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be |
| + // provided to ensure this bubble is closed when the parent closes. |
| + InternalPageInfoPopupView(views::View* anchor_view, |
| + gfx::NativeView parent_window); |
| ~InternalPageInfoPopupView() override; |
| // views::BubbleDelegateView: |
| void OnWidgetDestroying(views::Widget* widget) override; |
| private: |
| + friend class WebsiteSettingsPopupView; |
| + |
| DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); |
| }; |
| @@ -229,8 +234,12 @@ void PopupHeaderView::SetIdentityStatus(const base::string16& status, |
| // InternalPageInfoPopupView |
| //////////////////////////////////////////////////////////////////////////////// |
| -InternalPageInfoPopupView::InternalPageInfoPopupView(views::View* anchor_view) |
| +InternalPageInfoPopupView::InternalPageInfoPopupView( |
| + views::View* anchor_view, |
| + gfx::NativeView parent_window) |
| : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { |
| + set_parent_window(parent_window); |
| + |
| // Compensate for built-in vertical padding in the anchor view's image. |
| set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, |
| kLocationIconVerticalMargin, 0)); |
| @@ -250,8 +259,7 @@ InternalPageInfoPopupView::InternalPageInfoPopupView(views::View* anchor_view) |
| label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| AddChildView(label); |
| - views::BubbleDelegateView::CreateBubble(this)->Show(); |
| - SizeToContents(); |
|
msw
2015/08/17 17:31:45
Is removing these calls okay? (no regressions?)
jackhou1
2015/08/18 01:20:53
Tests pass. Tried it on my Windows machine, no reg
msw
2015/08/18 02:40:32
Acknowledged.
|
| + views::BubbleDelegateView::CreateBubble(this); |
| } |
| InternalPageInfoPopupView::~InternalPageInfoPopupView() { |
| @@ -275,10 +283,36 @@ void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, |
| const GURL& url, |
| const content::SSLStatus& ssl) { |
| is_popup_showing = true; |
| + views::BubbleDelegateView* popup = nullptr; |
| + if (InternalChromePage(url)) { |
| + popup = new InternalPageInfoPopupView(anchor_view, nullptr); |
| + } else { |
| + popup = new WebsiteSettingsPopupView(anchor_view, nullptr, profile, |
| + web_contents, url, ssl); |
| + } |
| + popup->GetWidget()->Show(); |
| +} |
| + |
| +// static |
| +void WebsiteSettingsPopupView::ShowPopupAtRect( |
| + const gfx::Rect& anchor_rect, |
| + Profile* profile, |
| + content::WebContents* web_contents, |
| + const GURL& url, |
| + const content::SSLStatus& ssl) { |
| + is_popup_showing = true; |
| if (InternalChromePage(url)) { |
| - new InternalPageInfoPopupView(anchor_view); |
| + // Use the concrete type so that SetAnchorRect() can be called as a friend. |
| + InternalPageInfoPopupView* popup = |
| + new InternalPageInfoPopupView(nullptr, web_contents->GetNativeView()); |
| + popup->SetAnchorRect(anchor_rect); |
| + popup->GetWidget()->Show(); |
| } else { |
| - new WebsiteSettingsPopupView(anchor_view, profile, web_contents, url, ssl); |
| + WebsiteSettingsPopupView* popup = |
| + new WebsiteSettingsPopupView(nullptr, web_contents->GetNativeView(), |
| + profile, web_contents, url, ssl); |
| + popup->SetAnchorRect(anchor_rect); |
| + popup->GetWidget()->Show(); |
| } |
| } |
| @@ -289,6 +323,7 @@ bool WebsiteSettingsPopupView::IsPopupShowing() { |
| WebsiteSettingsPopupView::WebsiteSettingsPopupView( |
| views::View* anchor_view, |
| + gfx::NativeView parent_window, |
| Profile* profile, |
| content::WebContents* web_contents, |
| const GURL& url, |
| @@ -310,6 +345,8 @@ WebsiteSettingsPopupView::WebsiteSettingsPopupView( |
| help_center_link_(nullptr), |
| connection_info_content_(nullptr), |
| weak_factory_(this) { |
| + set_parent_window(parent_window); |
| + |
| // Compensate for built-in vertical padding in the anchor view's image. |
| set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, |
| kLocationIconVerticalMargin, 0)); |
| @@ -354,8 +391,7 @@ WebsiteSettingsPopupView::WebsiteSettingsPopupView( |
| set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, |
| kPopupMarginBottom, kPopupMarginRight)); |
| - views::BubbleDelegateView::CreateBubble(this)->Show(); |
| - SizeToContents(); |
| + views::BubbleDelegateView::CreateBubble(this); |
| presenter_.reset(new WebsiteSettings( |
| this, profile, |