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

Unified Diff: chrome/browser/ui/views/website_settings/website_settings_popup_view.cc

Issue 1280673003: [Mac] Enable MacViews site settings bubble behind --enable-mac-views-dialogs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@enabledialogs
Patch Set: Address comments. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
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..6faa455fb4a39a268b44cebba0601b0cfd02bdf7 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();
+ views::BubbleDelegateView::CreateBubble(this);
}
InternalPageInfoPopupView::~InternalPageInfoPopupView() {
@@ -270,15 +278,27 @@ WebsiteSettingsPopupView::~WebsiteSettingsPopupView() {
// static
void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view,
+ const gfx::Rect& anchor_rect,
Profile* profile,
content::WebContents* web_contents,
const GURL& url,
const content::SSLStatus& ssl) {
is_popup_showing = true;
+ gfx::NativeView parent_window =
+ anchor_view ? nullptr : web_contents->GetNativeView();
if (InternalChromePage(url)) {
- new InternalPageInfoPopupView(anchor_view);
+ // Use the concrete type so that SetAnchorRect() can be called as a friend.
+ InternalPageInfoPopupView* popup =
+ new InternalPageInfoPopupView(anchor_view, parent_window);
+ if (!anchor_view)
+ popup->SetAnchorRect(anchor_rect);
+ popup->GetWidget()->Show();
} else {
- new WebsiteSettingsPopupView(anchor_view, profile, web_contents, url, ssl);
+ WebsiteSettingsPopupView* popup = new WebsiteSettingsPopupView(
+ anchor_view, parent_window, profile, web_contents, url, ssl);
+ if (!anchor_view)
+ popup->SetAnchorRect(anchor_rect);
+ popup->GetWidget()->Show();
}
}
@@ -289,6 +309,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 +331,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 +377,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,
« no previous file with comments | « chrome/browser/ui/views/website_settings/website_settings_popup_view.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698