| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/new_credit_card_bubble_views.h" | 5 #include "chrome/browser/ui/views/autofill/new_credit_card_bubble_views.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h" | 8 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h" |
| 9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
| 10 #include "chrome/browser/ui/host_desktop.h" | 10 #include "chrome/browser/ui/host_desktop.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // The space between the bubble and edges of the web contents when showing | 28 // The space between the bubble and edges of the web contents when showing |
| 29 // without an anchor (e.g. when requestAutocomplete() is called from a popup). | 29 // without an anchor (e.g. when requestAutocomplete() is called from a popup). |
| 30 const int kAnchorlessEndPadding = 20; | 30 const int kAnchorlessEndPadding = 20; |
| 31 const int kAnchorlessTopPadding = 10; | 31 const int kAnchorlessTopPadding = 10; |
| 32 | 32 |
| 33 // Get the view this bubble will be anchored to via |controller|. | 33 // Get the view this bubble will be anchored to via |controller|. |
| 34 views::View* GetAnchor(NewCreditCardBubbleController* controller) { | 34 views::View* GetAnchor(NewCreditCardBubbleController* controller) { |
| 35 Browser* browser = chrome::FindTabbedBrowser(controller->profile(), false, | 35 Browser* browser = chrome::FindTabbedBrowser(controller->profile(), false); |
| 36 chrome::GetActiveDesktop()); | |
| 37 if (!browser) | 36 if (!browser) |
| 38 return NULL; | 37 return NULL; |
| 39 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | 38 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| 40 return browser_view->GetToolbarView()->app_menu_button(); | 39 return browser_view->GetToolbarView()->app_menu_button(); |
| 41 } | 40 } |
| 42 | 41 |
| 43 views::BubbleBorder::Arrow GetArrow(NewCreditCardBubbleController* controller) { | 42 views::BubbleBorder::Arrow GetArrow(NewCreditCardBubbleController* controller) { |
| 44 views::View* anchor = GetAnchor(controller); | 43 views::View* anchor = GetAnchor(controller); |
| 45 return anchor ? views::BubbleBorder::TOP_RIGHT : views::BubbleBorder::NONE; | 44 return anchor ? views::BubbleBorder::TOP_RIGHT : views::BubbleBorder::NONE; |
| 46 } | 45 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 link->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 102 link->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 104 link->set_listener(this); | 103 link->set_listener(this); |
| 105 AddChildView(link); | 104 AddChildView(link); |
| 106 } | 105 } |
| 107 | 106 |
| 108 gfx::Rect NewCreditCardBubbleViews::GetBubbleBounds() { | 107 gfx::Rect NewCreditCardBubbleViews::GetBubbleBounds() { |
| 109 gfx::Rect bounds = views::BubbleDelegateView::GetBubbleBounds(); | 108 gfx::Rect bounds = views::BubbleDelegateView::GetBubbleBounds(); |
| 110 if (GetAnchorView()) | 109 if (GetAnchorView()) |
| 111 return bounds; | 110 return bounds; |
| 112 | 111 |
| 113 Browser* browser = chrome::FindBrowserWithProfile(controller_->profile(), | 112 Browser* browser = chrome::FindBrowserWithProfile(controller_->profile()); |
| 114 chrome::GetActiveDesktop()); | |
| 115 DCHECK(browser); | 113 DCHECK(browser); |
| 116 | 114 |
| 117 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | 115 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| 118 views::View* contents_view = browser_view->GetContentsView(); | 116 views::View* contents_view = browser_view->GetContentsView(); |
| 119 gfx::Rect web_contents_bounds = contents_view->GetBoundsInScreen(); | 117 gfx::Rect web_contents_bounds = contents_view->GetBoundsInScreen(); |
| 120 gfx::Insets border_insets(GetBubbleFrameView()->bubble_border()->GetInsets()); | 118 gfx::Insets border_insets(GetBubbleFrameView()->bubble_border()->GetInsets()); |
| 121 | 119 |
| 122 int x; | 120 int x; |
| 123 if (base::i18n::IsRTL()) { | 121 if (base::i18n::IsRTL()) { |
| 124 x = web_contents_bounds.x() - border_insets.left() + kAnchorlessEndPadding; | 122 x = web_contents_bounds.x() - border_insets.left() + kAnchorlessEndPadding; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 153 NewCreditCardBubbleViews::NewCreditCardBubbleViews( | 151 NewCreditCardBubbleViews::NewCreditCardBubbleViews( |
| 154 NewCreditCardBubbleController* controller) | 152 NewCreditCardBubbleController* controller) |
| 155 : BubbleDelegateView(GetAnchor(controller), GetArrow(controller)), | 153 : BubbleDelegateView(GetAnchor(controller), GetArrow(controller)), |
| 156 controller_(controller), | 154 controller_(controller), |
| 157 weak_ptr_factory_(this) { | 155 weak_ptr_factory_(this) { |
| 158 gfx::Insets insets = views::BubbleFrameView::GetTitleInsets(); | 156 gfx::Insets insets = views::BubbleFrameView::GetTitleInsets(); |
| 159 set_margins(gfx::Insets(0, insets.left(), insets.top(), insets.left())); | 157 set_margins(gfx::Insets(0, insets.left(), insets.top(), insets.left())); |
| 160 } | 158 } |
| 161 | 159 |
| 162 } // namespace autofill | 160 } // namespace autofill |
| OLD | NEW |