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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc

Issue 1802073002: Makes vertical alignment of location bar bubbles same (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Makes vertical alignment of location bar bubbles same (nits) Created 4 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view .h" 5 #include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view .h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_finder.h" 9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
11 #include "content/public/browser/notification_source.h" 11 #include "content/public/browser/notification_source.h"
12 #include "ui/base/material_design/material_design_controller.h" 12 #include "ui/base/material_design/material_design_controller.h"
13 #include "ui/gfx/geometry/rect.h" 13 #include "ui/gfx/geometry/rect.h"
14 14
15 LocationBarBubbleDelegateView::LocationBarBubbleDelegateView( 15 LocationBarBubbleDelegateView::LocationBarBubbleDelegateView(
16 views::View* anchor_view, 16 views::View* anchor_view,
17 content::WebContents* web_contents) 17 content::WebContents* web_contents)
18 : BubbleDialogDelegateView(anchor_view, 18 : BubbleDialogDelegateView(anchor_view,
19 anchor_view ? views::BubbleBorder::TOP_RIGHT 19 anchor_view ? views::BubbleBorder::TOP_RIGHT
20 : views::BubbleBorder::NONE) { 20 : views::BubbleBorder::NONE) {
21 // Add observer to close the bubble if the fullscreen state changes. 21 // Add observer to close the bubble if the fullscreen state changes.
22 if (web_contents) { 22 if (web_contents) {
23 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); 23 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
24 registrar_.Add( 24 registrar_.Add(
25 this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, 25 this, chrome::NOTIFICATION_FULLSCREEN_CHANGED,
26 content::Source<FullscreenController>( 26 content::Source<FullscreenController>(
27 browser->exclusive_access_manager()->fullscreen_controller())); 27 browser->exclusive_access_manager()->fullscreen_controller()));
28 } 28 }
29 // Compensate for built-in vertical padding in the anchor view's image.
30 set_anchor_view_insets(gfx::Insets(5, 0));
29 } 31 }
30 32
31 LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {} 33 LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {}
32 34
33 void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason) { 35 void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason) {
34 if (reason == USER_GESTURE) { 36 if (reason == USER_GESTURE) {
35 // In the USER_GESTURE case, the icon will be in an active state so the 37 // In the USER_GESTURE case, the icon will be in an active state so the
36 // bubble doesn't need an arrow. 38 // bubble doesn't need an arrow.
37 if (ui::MaterialDesignController::IsModeMaterial()) 39 if (ui::MaterialDesignController::IsModeMaterial())
38 SetArrowPaintType(views::BubbleBorder::PAINT_TRANSPARENT); 40 SetArrowPaintType(views::BubbleBorder::PAINT_TRANSPARENT);
(...skipping 25 matching lines...) Expand all
64 if (GetAnchorView()) 66 if (GetAnchorView())
65 return; 67 return;
66 68
67 const int kBubblePaddingFromScreenEdge = 20; 69 const int kBubblePaddingFromScreenEdge = 20;
68 int horizontal_offset = width() / 2 + kBubblePaddingFromScreenEdge; 70 int horizontal_offset = width() / 2 + kBubblePaddingFromScreenEdge;
69 const int x_pos = base::i18n::IsRTL() 71 const int x_pos = base::i18n::IsRTL()
70 ? (screen_bounds.x() + horizontal_offset) 72 ? (screen_bounds.x() + horizontal_offset)
71 : (screen_bounds.right() - horizontal_offset); 73 : (screen_bounds.right() - horizontal_offset);
72 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); 74 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0));
73 } 75 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc ('k') | chrome/browser/ui/views/location_bar/zoom_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698