Commit 4369139d authored by groby's avatar groby Committed by Commit bot

[PermissionBubble] identical ctor across platforms.

Views and Cocoa ctors were taking entirely different parameters -
parent window vs Browser*. We need those to be consistent, in
preparation for work at managed bubbles.

BUG = none

Review URL: https://codereview.chromium.org/1140223003

Cr-Commit-Position: refs/heads/master@{#330730}
parent ab040479
...@@ -1278,7 +1278,8 @@ using content::WebContents; ...@@ -1278,7 +1278,8 @@ using content::WebContents;
if (newContents) { if (newContents) {
if (!permissionBubbleCocoa_.get()) { if (!permissionBubbleCocoa_.get()) {
permissionBubbleCocoa_.reset(new PermissionBubbleCocoa([self window])); DCHECK(browser_.get());
permissionBubbleCocoa_.reset(new PermissionBubbleCocoa(browser_.get()));
} }
manager = PermissionBubbleManager::FromWebContents(newContents); manager = PermissionBubbleManager::FromWebContents(newContents);
if (manager) if (manager)
......
...@@ -15,11 +15,12 @@ ...@@ -15,11 +15,12 @@
#include "chrome/browser/ui/website_settings/permission_bubble_view.h" #include "chrome/browser/ui/website_settings/permission_bubble_view.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
class Browser;
@class PermissionBubbleController; @class PermissionBubbleController;
class PermissionBubbleCocoa : public PermissionBubbleView { class PermissionBubbleCocoa : public PermissionBubbleView {
public: public:
explicit PermissionBubbleCocoa(NSWindow* parent_window); explicit PermissionBubbleCocoa(Browser* browser);
~PermissionBubbleCocoa() override; ~PermissionBubbleCocoa() override;
// PermissionBubbleView interface. // PermissionBubbleView interface.
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h"
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/base_bubble_controller.h" #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
...@@ -12,8 +13,12 @@ ...@@ -12,8 +13,12 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#import "ui/base/cocoa/nsview_additions.h" #import "ui/base/cocoa/nsview_additions.h"
PermissionBubbleCocoa::PermissionBubbleCocoa(NSWindow* parent_window) PermissionBubbleCocoa::PermissionBubbleCocoa(Browser* browser)
: parent_window_(parent_window), delegate_(NULL), bubbleController_(nil) {} : parent_window_(nil), delegate_(nullptr), bubbleController_(nil) {
// Browser is allowed to be nullptr for testing purposes.
if (browser)
parent_window_ = browser->window()->GetNativeWindow();
}
PermissionBubbleCocoa::~PermissionBubbleCocoa() { PermissionBubbleCocoa::~PermissionBubbleCocoa() {
if (delegate_) if (delegate_)
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
namespace { namespace {
class MockPermissionBubbleCocoa : public PermissionBubbleCocoa { class MockPermissionBubbleCocoa : public PermissionBubbleCocoa {
public: public:
MockPermissionBubbleCocoa(NSWindow* parent_window) MockPermissionBubbleCocoa(Browser* browser)
: PermissionBubbleCocoa(parent_window) {} : PermissionBubbleCocoa(browser) {}
MOCK_METHOD0(HasLocationBar, bool()); MOCK_METHOD0(HasLocationBar, bool());
...@@ -25,7 +25,7 @@ class MockPermissionBubbleCocoa : public PermissionBubbleCocoa { ...@@ -25,7 +25,7 @@ class MockPermissionBubbleCocoa : public PermissionBubbleCocoa {
} }
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) { IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) {
PermissionBubbleCocoa bubble(browser()->window()->GetNativeWindow()); PermissionBubbleCocoa bubble(browser());
bubble.SetDelegate(test_delegate()); bubble.SetDelegate(test_delegate());
bubble.Show(requests(), accept_states()); bubble.Show(requests(), accept_states());
EXPECT_TRUE(bubble.HasLocationBar()); EXPECT_TRUE(bubble.HasLocationBar());
...@@ -33,7 +33,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) { ...@@ -33,7 +33,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) {
} }
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, FullscreenHasLocationBar) { IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, FullscreenHasLocationBar) {
PermissionBubbleCocoa bubble(browser()->window()->GetNativeWindow()); PermissionBubbleCocoa bubble(browser());
bubble.SetDelegate(test_delegate()); bubble.SetDelegate(test_delegate());
bubble.Show(requests(), accept_states()); bubble.Show(requests(), accept_states());
...@@ -50,7 +50,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, FullscreenHasLocationBar) { ...@@ -50,7 +50,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, FullscreenHasLocationBar) {
} }
IN_PROC_BROWSER_TEST_F(PermissionBubbleAppBrowserTest, AppHasNoLocationBar) { IN_PROC_BROWSER_TEST_F(PermissionBubbleAppBrowserTest, AppHasNoLocationBar) {
PermissionBubbleCocoa bubble(app_browser()->window()->GetNativeWindow()); PermissionBubbleCocoa bubble(app_browser());
bubble.SetDelegate(test_delegate()); bubble.SetDelegate(test_delegate());
bubble.Show(requests(), accept_states()); bubble.Show(requests(), accept_states());
EXPECT_FALSE(bubble.HasLocationBar()); EXPECT_FALSE(bubble.HasLocationBar());
...@@ -61,7 +61,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleAppBrowserTest, AppHasNoLocationBar) { ...@@ -61,7 +61,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleAppBrowserTest, AppHasNoLocationBar) {
// Kiosk mode on Mac has a location bar but it shouldn't. // Kiosk mode on Mac has a location bar but it shouldn't.
IN_PROC_BROWSER_TEST_F(PermissionBubbleKioskBrowserTest, IN_PROC_BROWSER_TEST_F(PermissionBubbleKioskBrowserTest,
DISABLED_KioskHasNoLocationBar) { DISABLED_KioskHasNoLocationBar) {
PermissionBubbleCocoa bubble(browser()->window()->GetNativeWindow()); PermissionBubbleCocoa bubble(browser());
bubble.SetDelegate(test_delegate()); bubble.SetDelegate(test_delegate());
bubble.Show(requests(), accept_states()); bubble.Show(requests(), accept_states());
EXPECT_FALSE(bubble.HasLocationBar()); EXPECT_FALSE(bubble.HasLocationBar());
...@@ -70,8 +70,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleKioskBrowserTest, ...@@ -70,8 +70,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleKioskBrowserTest,
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
AnchorPositionWithLocationBar) { AnchorPositionWithLocationBar) {
testing::NiceMock<MockPermissionBubbleCocoa> bubble( testing::NiceMock<MockPermissionBubbleCocoa> bubble(browser());
browser()->window()->GetNativeWindow());
bubble.SetDelegate(test_delegate()); bubble.SetDelegate(test_delegate());
bubble.Show(requests(), accept_states()); bubble.Show(requests(), accept_states());
ON_CALL(bubble, HasLocationBar()).WillByDefault(testing::Return(true)); ON_CALL(bubble, HasLocationBar()).WillByDefault(testing::Return(true));
...@@ -91,8 +90,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, ...@@ -91,8 +90,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
AnchorPositionWithoutLocationBar) { AnchorPositionWithoutLocationBar) {
testing::NiceMock<MockPermissionBubbleCocoa> bubble( testing::NiceMock<MockPermissionBubbleCocoa> bubble(browser());
browser()->window()->GetNativeWindow());
bubble.SetDelegate(test_delegate()); bubble.SetDelegate(test_delegate());
bubble.Show(requests(), accept_states()); bubble.Show(requests(), accept_states());
ON_CALL(bubble, HasLocationBar()).WillByDefault(testing::Return(false)); ON_CALL(bubble, HasLocationBar()).WillByDefault(testing::Return(false));
...@@ -110,8 +108,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, ...@@ -110,8 +108,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
AnchorPositionDifferentWithAndWithoutLocationBar) { AnchorPositionDifferentWithAndWithoutLocationBar) {
testing::NiceMock<MockPermissionBubbleCocoa> bubble( testing::NiceMock<MockPermissionBubbleCocoa> bubble(browser());
browser()->window()->GetNativeWindow());
bubble.SetDelegate(test_delegate()); bubble.SetDelegate(test_delegate());
bubble.Show(requests(), accept_states()); bubble.Show(requests(), accept_states());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment