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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest_nonmac.cc

Issue 2630473003: MacViews: Harmony for toolbar actions bubbles. (Closed)
Patch Set: Fix DialogBrowserTest Created 3 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
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698