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;
if (newContents) {
if (!permissionBubbleCocoa_.get()) {
permissionBubbleCocoa_.reset(new PermissionBubbleCocoa([self window]));
DCHECK(browser_.get());
permissionBubbleCocoa_.reset(new PermissionBubbleCocoa(browser_.get()));
}
manager = PermissionBubbleManager::FromWebContents(newContents);
if (manager)
......
......@@ -15,11 +15,12 @@
#include "chrome/browser/ui/website_settings/permission_bubble_view.h"
#include "content/public/browser/web_contents.h"
class Browser;
@class PermissionBubbleController;
class PermissionBubbleCocoa : public PermissionBubbleView {
public:
explicit PermissionBubbleCocoa(NSWindow* parent_window);
explicit PermissionBubbleCocoa(Browser* browser);
~PermissionBubbleCocoa() override;
// PermissionBubbleView interface.
......
......@@ -4,6 +4,7 @@
#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/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
......@@ -12,8 +13,12 @@
#include "content/public/browser/web_contents.h"
#import "ui/base/cocoa/nsview_additions.h"
PermissionBubbleCocoa::PermissionBubbleCocoa(NSWindow* parent_window)
: parent_window_(parent_window), delegate_(NULL), bubbleController_(nil) {}
PermissionBubbleCocoa::PermissionBubbleCocoa(Browser* browser)
: 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() {
if (delegate_)
......
......@@ -14,8 +14,8 @@
namespace {
class MockPermissionBubbleCocoa : public PermissionBubbleCocoa {
public:
MockPermissionBubbleCocoa(NSWindow* parent_window)
: PermissionBubbleCocoa(parent_window) {}
MockPermissionBubbleCocoa(Browser* browser)
: PermissionBubbleCocoa(browser) {}
MOCK_METHOD0(HasLocationBar, bool());
......@@ -25,7 +25,7 @@ class MockPermissionBubbleCocoa : public PermissionBubbleCocoa {
}
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) {
PermissionBubbleCocoa bubble(browser()->window()->GetNativeWindow());
PermissionBubbleCocoa bubble(browser());
bubble.SetDelegate(test_delegate());
bubble.Show(requests(), accept_states());
EXPECT_TRUE(bubble.HasLocationBar());
......@@ -33,7 +33,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) {
}
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, FullscreenHasLocationBar) {
PermissionBubbleCocoa bubble(browser()->window()->GetNativeWindow());
PermissionBubbleCocoa bubble(browser());
bubble.SetDelegate(test_delegate());
bubble.Show(requests(), accept_states());
......@@ -50,7 +50,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, FullscreenHasLocationBar) {
}
IN_PROC_BROWSER_TEST_F(PermissionBubbleAppBrowserTest, AppHasNoLocationBar) {
PermissionBubbleCocoa bubble(app_browser()->window()->GetNativeWindow());
PermissionBubbleCocoa bubble(app_browser());
bubble.SetDelegate(test_delegate());
bubble.Show(requests(), accept_states());
EXPECT_FALSE(bubble.HasLocationBar());
......@@ -61,7 +61,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleAppBrowserTest, AppHasNoLocationBar) {
// Kiosk mode on Mac has a location bar but it shouldn't.
IN_PROC_BROWSER_TEST_F(PermissionBubbleKioskBrowserTest,
DISABLED_KioskHasNoLocationBar) {
PermissionBubbleCocoa bubble(browser()->window()->GetNativeWindow());
PermissionBubbleCocoa bubble(browser());
bubble.SetDelegate(test_delegate());
bubble.Show(requests(), accept_states());
EXPECT_FALSE(bubble.HasLocationBar());
......@@ -70,8 +70,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleKioskBrowserTest,
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
AnchorPositionWithLocationBar) {
testing::NiceMock<MockPermissionBubbleCocoa> bubble(
browser()->window()->GetNativeWindow());
testing::NiceMock<MockPermissionBubbleCocoa> bubble(browser());
bubble.SetDelegate(test_delegate());
bubble.Show(requests(), accept_states());
ON_CALL(bubble, HasLocationBar()).WillByDefault(testing::Return(true));
......@@ -91,8 +90,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
AnchorPositionWithoutLocationBar) {
testing::NiceMock<MockPermissionBubbleCocoa> bubble(
browser()->window()->GetNativeWindow());
testing::NiceMock<MockPermissionBubbleCocoa> bubble(browser());
bubble.SetDelegate(test_delegate());
bubble.Show(requests(), accept_states());
ON_CALL(bubble, HasLocationBar()).WillByDefault(testing::Return(false));
......@@ -110,8 +108,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
AnchorPositionDifferentWithAndWithoutLocationBar) {
testing::NiceMock<MockPermissionBubbleCocoa> bubble(
browser()->window()->GetNativeWindow());
testing::NiceMock<MockPermissionBubbleCocoa> bubble(browser());
bubble.SetDelegate(test_delegate());
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