OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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/extensions/extension_message_bubble_browsertest.h" | |
6 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" | |
Devlin
2017/03/09 02:49:49
Do we need all these includes?
tapted
2017/03/09 10:24:16
heh this one I'd assumed yes, since I moved it out
| |
7 #include "chrome/browser/ui/views/frame/browser_view.h" | |
8 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" | |
9 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" | |
10 #include "chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h" | |
11 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | |
12 #include "ui/views/bubble/bubble_dialog_delegate.h" | |
13 | |
14 namespace { | |
15 | |
16 // Returns the ToolbarView for the given |browser|. | |
17 ToolbarView* GetToolbarViewForBrowser(Browser* browser) { | |
18 return BrowserView::GetBrowserViewForBrowser(browser)->toolbar(); | |
19 } | |
20 | |
21 } // namespace | |
22 | |
23 // static | |
24 ToolbarActionsBarBubbleViews* | |
25 ExtensionMessageBubbleBrowserTest::GetViewsBubbleForBrowser(Browser* browser) { | |
26 return static_cast<ToolbarActionsBarBubbleViews*>( | |
27 GetToolbarViewForBrowser(browser)->browser_actions()->active_bubble()); | |
28 } | |
29 | |
30 // static | |
31 gfx::Rect ExtensionMessageBubbleBrowserTest::GetAnchorReferenceBoundsForBrowser( | |
32 Browser* browser, | |
33 AnchorPosition anchor) { | |
34 ToolbarView* toolbar_view = GetToolbarViewForBrowser(browser); | |
35 BrowserActionsContainer* container = toolbar_view->browser_actions(); | |
36 views::BubbleDialogDelegateView* bubble = container->active_bubble(); | |
37 views::View* anchor_view = nullptr; | |
38 switch (anchor) { | |
39 case ExtensionMessageBubbleBrowserTest::ANCHOR_BROWSER_ACTION: | |
40 DCHECK_GT(container->num_toolbar_actions(), 0u); | |
41 anchor_view = container->GetToolbarActionViewAt(0); | |
42 break; | |
43 case ExtensionMessageBubbleBrowserTest::ANCHOR_APP_MENU: | |
44 anchor_view = toolbar_view->app_menu_button(); | |
45 break; | |
46 } | |
47 | |
48 EXPECT_TRUE(anchor_view); | |
49 EXPECT_EQ(anchor_view, bubble->GetAnchorView()); | |
50 return anchor_view->GetBoundsInScreen(); | |
51 } | |
OLD | NEW |