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

Side by Side Diff: chrome/browser/ui/views/browser_dialogs_views_mac.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 unified diff | Download patch
OLDNEW
(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 // Creates an anchor view for a bubble and deletes it when the bubble is closed.
17 // It also closes the bubble when the parent WebContents is destroyed since the
18 // anchor view does not have its own Widget for the BubbleDelegateView to
19 // observe. Owns itself.
20 class BubbleAnchorViewAdapter : public views::WidgetObserver,
21 public content::WebContentsObserver {
22 public:
23 BubbleAnchorViewAdapter(const gfx::Point& anchor_point,
24 Profile* profile,
25 content::WebContents* web_contents,
26 const GURL& url,
27 const content::SSLStatus& ssl)
28 : anchor_view_(new views::View) {
29 // Since the view doesn't have a container Widget,
30 // View::ConvertPointToScreen will assume its origin is 0,0. Create a rect
31 // where the midpoint of the bottom edge is at the anchor point.
32 anchor_view_->SetBounds(
33 0, 0, anchor_point.x() * 2,
tapted 2015/08/11 03:20:37 ooh - I just realised something... What happens in
tapted 2015/08/11 03:45:42 lgtm with a comment about the dual-screen thing (h
jackhou1 2015/08/11 03:54:02 Done.
34 anchor_point.y() +
35 WebsiteSettingsPopupView::kLocationIconVerticalMargin);
36 views::BubbleDelegateView* bubble_view =
37 WebsiteSettingsPopupView::ShowPopup(anchor_view_.get(), profile,
38 web_contents, url, ssl);
39
40 widget_ = bubble_view->GetWidget();
41 widget_->AddObserver(this);
42 Observe(web_contents);
43 }
44
45 ~BubbleAnchorViewAdapter() override {}
46
47 // WidgetObserver:
48 void OnWidgetDestroyed(views::Widget* widget) override { delete this; }
49
50 // content::WebContentsObserver:
51 void WebContentsDestroyed() override { widget_->Close(); }
52
53 private:
54 // This view should never be (or have been) inserted into a view heirarchy.
55 scoped_ptr<views::View> anchor_view_;
56 views::Widget* widget_;
57
58 DISALLOW_COPY_AND_ASSIGN(BubbleAnchorViewAdapter);
59 };
60
61 } // namespace
62
63 namespace chrome {
64
65 void ShowWebsiteSettingsBubbleViewsAtPoint(const gfx::Point& anchor_point,
66 Profile* profile,
67 content::WebContents* web_contents,
68 const GURL& url,
69 const content::SSLStatus& ssl) {
70 new BubbleAnchorViewAdapter(anchor_point, profile, web_contents, url, ssl);
71 }
72
73 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698