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

Side by Side Diff: chrome/browser/ui/views/website_settings/permissions_bubble_view_views.cc

Issue 2109663005: Permission prompts show in the top-left corner in fullscreen mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission-bubble-detach-from-fullscreen
Patch Set: Take into account RTL displays and multiple monitors. Created 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/memory/ptr_util.h" 5 #include "base/memory/ptr_util.h"
6 #include "chrome/browser/ui/browser.h" 6 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/browser_window.h" 7 #include "chrome/browser/ui/browser_window.h"
8 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" 8 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h"
9 #include "chrome/browser/ui/views/frame/browser_view.h" 9 #include "chrome/browser/ui/views/frame/browser_view.h"
10 #include "chrome/browser/ui/views/frame/top_container_view.h" 10 #include "chrome/browser/ui/views/frame/top_container_view.h"
11 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 11 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
12 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" 12 #include "chrome/browser/ui/views/location_bar/location_icon_view.h"
13 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h" 13 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h"
14 #include "ui/gfx/geometry/point.h" 14 #include "ui/gfx/geometry/point.h"
15 #include "ui/gfx/geometry/vector2d.h"
15 16
16 // The Views browser implementation of PermissionBubbleViewViews' 17 // The Views browser implementation of PermissionBubbleViewViews'
17 // anchor methods. Views browsers have a native View to anchor the bubble to, 18 // anchor methods. Views browsers have a native View to anchor the bubble to,
18 // which these functions provide. 19 // which these functions provide.
19 20
21 // Left margin for the bubble when anchored to the top of the screen in
22 // fullscreen mode.
23 const int kFullscreenLeftMargin = 40;
24
20 views::View* PermissionBubbleViewViews::GetAnchorView() { 25 views::View* PermissionBubbleViewViews::GetAnchorView() {
21 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); 26 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
22 27
23 if (browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) 28 if (browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR))
24 return browser_view->GetLocationBarView()->location_icon_view(); 29 return browser_view->GetLocationBarView()->location_icon_view();
25 30
26 return browser_view->top_container(); 31 // Fall back to GetAnchorPoint().
32 return nullptr;
27 } 33 }
28 34
29 gfx::Point PermissionBubbleViewViews::GetAnchorPoint() { 35 gfx::Point PermissionBubbleViewViews::GetAnchorPoint() {
30 return gfx::Point(); 36 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
37 // Get position in view (taking RTL displays into account).
38 int x_within_browser_view =
39 browser_view->GetMirroredXInView(kFullscreenLeftMargin);
40 // Get position in screen (taking browser view origin into account, which may
41 // not be 0,0 if there are multiple displays).
42 gfx::Point browser_view_origin = browser_view->GetBoundsInScreen().origin();
43 return browser_view_origin + gfx::Vector2d(x_within_browser_view, 0);
31 } 44 }
32 45
33 views::BubbleBorder::Arrow PermissionBubbleViewViews::GetAnchorArrow() { 46 views::BubbleBorder::Arrow PermissionBubbleViewViews::GetAnchorArrow() {
34 if (browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) 47 return views::BubbleBorder::TOP_LEFT;
35 return views::BubbleBorder::TOP_LEFT;
36 return views::BubbleBorder::NONE;
37 } 48 }
38 49
39 // static 50 // static
40 std::unique_ptr<PermissionBubbleView> PermissionBubbleView::Create( 51 std::unique_ptr<PermissionBubbleView> PermissionBubbleView::Create(
41 Browser* browser) { 52 Browser* browser) {
42 return base::WrapUnique(new PermissionBubbleViewViews(browser)); 53 return base::WrapUnique(new PermissionBubbleViewViews(browser));
43 } 54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698