Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/browser_dialogs.h" | |
| 6 | |
| 7 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h " | |
| 8 #include "content/public/browser/web_contents_observer.h" | |
| 9 #include "ui/views/widget/widget_observer.h" | |
| 10 | |
| 11 // This file provides definitions of desktop browser dialog-creation methods for | |
| 12 // Mac where a Cocoa browser is using Views dialogs. | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 // Closes the bubble when the parent WebContents is destroyed since there is no | |
| 17 // anchor Widget for the BubbleDelegateView to observe. Owns itself. | |
| 18 // TODO(jackhou): Make this adapter manage a Widget that is a child window of | |
| 19 // BrowserWindowCocoa. This is needed for bubbles that can stay open, e.g. | |
| 20 // extensions. | |
| 21 class BubbleAnchorAdapter : public views::WidgetObserver, | |
|
tapted
2015/08/17 05:15:03
(as discussed, I think we can get rid of the adapt
tapted
2015/08/17 05:15:45
uhh set_parent_window(..) that is.
jackhou1
2015/08/17 05:42:36
Done.
| |
| 22 public content::WebContentsObserver { | |
| 23 public: | |
| 24 BubbleAnchorAdapter(const gfx::Point& anchor_point, | |
| 25 Profile* profile, | |
| 26 content::WebContents* web_contents, | |
| 27 const GURL& url, | |
| 28 const content::SSLStatus& ssl) { | |
| 29 views::BubbleDelegateView* bubble_view = | |
| 30 WebsiteSettingsPopupView::ShowPopupAtRect( | |
| 31 gfx::Rect(anchor_point, gfx::Size()), profile, web_contents, url, | |
| 32 ssl); | |
| 33 widget_ = bubble_view->GetWidget(); | |
| 34 widget_->AddObserver(this); | |
| 35 Observe(web_contents); | |
| 36 } | |
| 37 | |
| 38 ~BubbleAnchorAdapter() override {} | |
| 39 | |
| 40 // WidgetObserver: | |
| 41 void OnWidgetDestroyed(views::Widget* widget) override { delete this; } | |
| 42 | |
| 43 // content::WebContentsObserver: | |
| 44 void WebContentsDestroyed() override { widget_->Close(); } | |
| 45 | |
| 46 private: | |
| 47 views::Widget* widget_; | |
| 48 | |
| 49 DISALLOW_COPY_AND_ASSIGN(BubbleAnchorAdapter); | |
| 50 }; | |
| 51 | |
| 52 } // namespace | |
| 53 | |
| 54 namespace chrome { | |
| 55 | |
| 56 void ShowWebsiteSettingsBubbleViewsAtPoint(const gfx::Point& anchor_point, | |
| 57 Profile* profile, | |
| 58 content::WebContents* web_contents, | |
| 59 const GURL& url, | |
| 60 const content::SSLStatus& ssl) { | |
| 61 new BubbleAnchorAdapter(anchor_point, profile, web_contents, url, ssl); | |
| 62 } | |
| 63 | |
| 64 } // namespace chrome | |
| OLD | NEW |