Commit 2baad015 authored by Timothy Loh's avatar Timothy Loh Committed by Commit Bot

Clean up interface to PermissionPrompt and subclasses

Following https://crrev.com/c/567940, this patch greatly simplifies the
interface to PermissionPrompt as follows:
- Object creation and showing a prompt are now tied. Move Show() and
  SetDelegate() logic into the ctor.
- Hiding only happens by object destruction. Remove HidesAutomatically()
  and move Hide() logic ino the dtor.

This patch also cleans up MockPermissionPrompt{,Factory} accordingly,
moving some logic previously from MockPermissionPrompt::Show() to the
factory.

Change-Id: I7868d645df6dbba8ea5706a8d9e7e59cfe1b157f
Reviewed-on: https://chromium-review.googlesource.com/572894
Commit-Queue: Timothy Loh <timloh@chromium.org>
Reviewed-by: default avatarRaymes Khoury <raymes@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487421}
parent 83bc18b1
......@@ -18,21 +18,14 @@
#include "ui/base/l10n/l10n_util.h"
PermissionPromptAndroid::PermissionPromptAndroid(
content::WebContents* web_contents)
content::WebContents* web_contents,
Delegate* delegate)
: web_contents_(web_contents),
delegate_(nullptr),
delegate_(delegate),
persist_(true),
weak_factory_(this) {
DCHECK(web_contents);
}
PermissionPromptAndroid::~PermissionPromptAndroid() {}
void PermissionPromptAndroid::SetDelegate(Delegate* delegate) {
delegate_ = delegate;
}
void PermissionPromptAndroid::Show() {
bool has_gesture = true;
for (const PermissionRequest* request : delegate_->Requests()) {
has_gesture &=
......@@ -53,20 +46,12 @@ void PermissionPromptAndroid::Show() {
delegate_->Requests()[0]->GetOrigin());
}
PermissionPromptAndroid::~PermissionPromptAndroid() {}
bool PermissionPromptAndroid::CanAcceptRequestUpdate() {
return false;
}
bool PermissionPromptAndroid::HidesAutomatically() {
return true;
}
void PermissionPromptAndroid::Hide() {
// Hide() is only called if HidesAutomatically() returns false or
// CanAcceptRequestUpdate() return true.
NOTREACHED();
}
void PermissionPromptAndroid::UpdateAnchorPosition() {
NOTREACHED() << "UpdateAnchorPosition is not implemented";
}
......@@ -77,38 +62,32 @@ gfx::NativeWindow PermissionPromptAndroid::GetNativeWindow() {
}
void PermissionPromptAndroid::Closing() {
if (delegate_)
delegate_->Closing();
delegate_->Closing();
}
void PermissionPromptAndroid::TogglePersist(bool value) {
persist_ = value;
if (delegate_)
delegate_->TogglePersist(value);
delegate_->TogglePersist(value);
}
void PermissionPromptAndroid::Accept() {
if (delegate_) {
if (ShouldShowPersistenceToggle()) {
for (const PermissionRequest* request : delegate_->Requests()) {
PermissionUmaUtil::PermissionPromptAcceptedWithPersistenceToggle(
request->GetContentSettingsType(), persist_);
}
if (ShouldShowPersistenceToggle()) {
for (const PermissionRequest* request : delegate_->Requests()) {
PermissionUmaUtil::PermissionPromptAcceptedWithPersistenceToggle(
request->GetContentSettingsType(), persist_);
}
delegate_->Accept();
}
delegate_->Accept();
}
void PermissionPromptAndroid::Deny() {
if (delegate_) {
if (ShouldShowPersistenceToggle()) {
for (const PermissionRequest* request : delegate_->Requests()) {
PermissionUmaUtil::PermissionPromptDeniedWithPersistenceToggle(
request->GetContentSettingsType(), persist_);
}
if (ShouldShowPersistenceToggle()) {
for (const PermissionRequest* request : delegate_->Requests()) {
PermissionUmaUtil::PermissionPromptDeniedWithPersistenceToggle(
request->GetContentSettingsType(), persist_);
}
delegate_->Deny();
}
delegate_->Deny();
}
size_t PermissionPromptAndroid::PermissionCount() const {
......@@ -183,6 +162,7 @@ GURL PermissionPromptAndroid::GetLinkURL() const {
// static
std::unique_ptr<PermissionPrompt> PermissionPrompt::Create(
content::WebContents* web_contents) {
return base::MakeUnique<PermissionPromptAndroid>(web_contents);
content::WebContents* web_contents,
Delegate* delegate) {
return base::MakeUnique<PermissionPromptAndroid>(web_contents, delegate);
}
......@@ -19,15 +19,12 @@ class WebContents;
class PermissionPromptAndroid : public PermissionPrompt {
public:
explicit PermissionPromptAndroid(content::WebContents* web_contents);
PermissionPromptAndroid(content::WebContents* web_contents,
Delegate* delegate);
~PermissionPromptAndroid() override;
// PermissionPrompt:
void SetDelegate(Delegate* delegate) override;
void Show() override;
bool CanAcceptRequestUpdate() override;
bool HidesAutomatically() override;
void Hide() override;
void UpdateAnchorPosition() override;
gfx::NativeWindow GetNativeWindow() override;
......
......@@ -404,9 +404,7 @@ void PermissionRequestManager::ShowBubble() {
DCHECK(main_frame_has_fully_loaded_);
DCHECK(tab_can_show_prompts_);
view_ = view_factory_.Run(web_contents());
view_->SetDelegate(this);
view_->Show();
view_ = view_factory_.Run(web_contents(), this);
PermissionUmaUtil::PermissionPromptShown(requests_);
NotifyBubbleAdded();
......@@ -417,9 +415,6 @@ void PermissionRequestManager::ShowBubble() {
void PermissionRequestManager::DeleteBubble() {
DCHECK(view_);
if (!view_->HidesAutomatically())
view_->Hide();
view_->SetDelegate(nullptr);
view_.reset();
}
......
......@@ -118,7 +118,6 @@ class PermissionRequestManager
// lot of friends.
friend class GeolocationBrowserTest;
friend class GeolocationPermissionContextTests;
friend class MockPermissionPrompt;
friend class MockPermissionPromptFactory;
friend class PermissionContextBaseTests;
friend class PermissionRequestManagerTest;
......
......@@ -20,15 +20,11 @@ class Browser;
class PermissionBubbleCocoa : public PermissionPrompt {
public:
explicit PermissionBubbleCocoa(Browser* browser);
PermissionBubbleCocoa(Browser* browser, Delegate* delegate);
~PermissionBubbleCocoa() override;
// PermissionPrompt:
void Show() override;
void Hide() override;
void SetDelegate(Delegate* delegate) override;
bool CanAcceptRequestUpdate() override;
bool HidesAutomatically() override;
void UpdateAnchorPosition() override;
gfx::NativeWindow GetNativeWindow() override;
......
......@@ -11,13 +11,9 @@
#include "content/public/browser/web_contents.h"
#import "ui/base/cocoa/nsview_additions.h"
PermissionBubbleCocoa::PermissionBubbleCocoa(Browser* browser)
: browser_(browser), delegate_(nullptr), bubbleController_(nil) {}
PermissionBubbleCocoa::~PermissionBubbleCocoa() {
}
void PermissionBubbleCocoa::Show() {
PermissionBubbleCocoa::PermissionBubbleCocoa(Browser* browser,
Delegate* delegate)
: browser_(browser), delegate_(delegate), bubbleController_(nil) {
DCHECK(browser_);
if (!bubbleController_) {
......@@ -29,24 +25,14 @@ void PermissionBubbleCocoa::Show() {
[bubbleController_ showWithDelegate:delegate_];
}
void PermissionBubbleCocoa::Hide() {
PermissionBubbleCocoa::~PermissionBubbleCocoa() {
[bubbleController_ close];
}
void PermissionBubbleCocoa::SetDelegate(Delegate* delegate) {
if (delegate_ == delegate)
return;
delegate_ = delegate;
}
bool PermissionBubbleCocoa::CanAcceptRequestUpdate() {
return ![[[bubbleController_ window] contentView] cr_isMouseInView];
}
bool PermissionBubbleCocoa::HidesAutomatically() {
return false;
}
void PermissionBubbleCocoa::UpdateAnchorPosition() {
[bubbleController_ updateAnchorPosition];
}
......
......@@ -15,20 +15,15 @@
#include "ui/base/test/scoped_fake_nswindow_fullscreen.h"
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) {
PermissionBubbleCocoa bubble(browser());
bubble.SetDelegate(test_delegate());
bubble.Show();
PermissionBubbleCocoa bubble(browser(), test_delegate());
EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
bubble.Hide();
}
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
BrowserFullscreenHasLocationBar) {
ui::test::ScopedFakeNSWindowFullscreen faker;
PermissionBubbleCocoa bubble(browser());
bubble.SetDelegate(test_delegate());
bubble.Show();
PermissionBubbleCocoa bubble(browser(), test_delegate());
EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
FullscreenController* controller =
......@@ -52,16 +47,13 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
faker.FinishTransition();
EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
bubble.Hide();
}
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
TabFullscreenHasLocationBar) {
ui::test::ScopedFakeNSWindowFullscreen faker;
PermissionBubbleCocoa bubble(browser());
bubble.SetDelegate(test_delegate());
bubble.Show();
PermissionBubbleCocoa bubble(browser(), test_delegate());
EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
FullscreenController* controller =
......@@ -76,25 +68,18 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
faker.FinishTransition();
EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
bubble.Hide();
}
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, AppHasNoLocationBar) {
Browser* app_browser = OpenExtensionAppWindow();
PermissionBubbleCocoa bubble(app_browser);
bubble.SetDelegate(test_delegate());
bubble.Show();
PermissionBubbleCocoa bubble(app_browser, test_delegate());
EXPECT_FALSE([bubble.bubbleController_ hasVisibleLocationBar]);
bubble.Hide();
}
// http://crbug.com/470724
// Kiosk mode on Mac has a location bar but it shouldn't.
IN_PROC_BROWSER_TEST_F(PermissionBubbleKioskBrowserTest,
DISABLED_KioskHasNoLocationBar) {
PermissionBubbleCocoa bubble(browser());
bubble.SetDelegate(test_delegate());
bubble.Show();
PermissionBubbleCocoa bubble(browser(), test_delegate());
EXPECT_FALSE([bubble.bubbleController_ hasVisibleLocationBar]);
bubble.Hide();
}
......@@ -78,8 +78,8 @@ class PermissionBubbleControllerTest : public CocoaProfileTest,
void SetUp() override {
CocoaProfileTest::SetUp();
bridge_.reset(new PermissionBubbleCocoa(browser()));
AddRequest(kPermissionA);
bridge_.reset(new PermissionBubbleCocoa(browser(), this));
controller_ =
[[PermissionBubbleController alloc] initWithBrowser:browser()
bridge:bridge_.get()];
......
......@@ -35,11 +35,12 @@ views::BubbleBorder::Arrow PermissionPromptImpl::GetAnchorArrow() {
// static
std::unique_ptr<PermissionPrompt> PermissionPrompt::Create(
content::WebContents* web_contents) {
content::WebContents* web_contents,
Delegate* delegate) {
if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
return base::WrapUnique(new PermissionPromptImpl(
chrome::FindBrowserWithWebContents(web_contents)));
chrome::FindBrowserWithWebContents(web_contents), delegate));
}
return base::MakeUnique<PermissionBubbleCocoa>(
chrome::FindBrowserWithWebContents(web_contents));
chrome::FindBrowserWithWebContents(web_contents), delegate);
}
......@@ -6,7 +6,7 @@
#include "base/bind.h"
#include "base/run_loop.h"
#include "chrome/browser/permissions/permission_request_manager.h"
#include "build/build_config.h"
#include "chrome/browser/ui/permission_bubble/mock_permission_prompt_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -15,43 +15,14 @@
#endif
MockPermissionPrompt::~MockPermissionPrompt() {
Hide();
}
void MockPermissionPrompt::Show() {
factory_->ShowView(this);
factory_->show_count_++;
factory_->requests_count_ = manager_->requests_.size();
for (const PermissionRequest* request : manager_->requests_) {
factory_->request_types_seen_.push_back(
request->GetPermissionRequestType());
// The actual prompt will call these, so test they're sane.
EXPECT_FALSE(request->GetMessageTextFragment().empty());
#if defined(OS_ANDROID)
EXPECT_FALSE(request->GetMessageText().empty());
EXPECT_NE(0, request->GetIconId());
#else
EXPECT_FALSE(request->GetIconId().is_empty());
#endif
}
factory_->UpdateResponseType();
is_visible_ = true;
if (factory_)
factory_->HideView(this);
}
bool MockPermissionPrompt::CanAcceptRequestUpdate() {
return can_update_ui_;
}
bool MockPermissionPrompt::HidesAutomatically() {
return false;
}
void MockPermissionPrompt::Hide() {
if (is_visible_ && factory_)
factory_->HideView(this);
is_visible_ = false;
}
void MockPermissionPrompt::UpdateAnchorPosition() {}
gfx::NativeWindow MockPermissionPrompt::GetNativeWindow() {
......@@ -60,13 +31,18 @@ gfx::NativeWindow MockPermissionPrompt::GetNativeWindow() {
return nullptr;
}
bool MockPermissionPrompt::IsVisible() {
return is_visible_;
}
MockPermissionPrompt::MockPermissionPrompt(MockPermissionPromptFactory* factory,
PermissionRequestManager* manager)
: factory_(factory),
manager_(manager),
can_update_ui_(true),
is_visible_(false) {}
Delegate* delegate,
bool can_update_ui)
: factory_(factory), delegate_(delegate), can_update_ui_(can_update_ui) {
for (const PermissionRequest* request : delegate_->Requests()) {
// The actual prompt will call these, so test they're sane.
EXPECT_FALSE(request->GetMessageTextFragment().empty());
#if defined(OS_ANDROID)
EXPECT_FALSE(request->GetMessageText().empty());
EXPECT_NE(0, request->GetIconId());
#else
EXPECT_FALSE(request->GetIconId().is_empty());
#endif
}
}
......@@ -8,7 +8,6 @@
#include "chrome/browser/ui/permission_bubble/permission_prompt.h"
class MockPermissionPromptFactory;
class PermissionRequestManager;
// Provides a skeleton class for unit and browser testing when trying to test
// the request manager logic. Should not be used for anything that requires
......@@ -19,11 +18,7 @@ class MockPermissionPrompt : public PermissionPrompt {
~MockPermissionPrompt() override;
// PermissionPrompt:
void SetDelegate(Delegate* delegate) override {}
void Show() override;
bool CanAcceptRequestUpdate() override;
bool HidesAutomatically() override;
void Hide() override;
void UpdateAnchorPosition() override;
gfx::NativeWindow GetNativeWindow() override;
......@@ -33,12 +28,12 @@ class MockPermissionPrompt : public PermissionPrompt {
friend class MockPermissionPromptFactory;
MockPermissionPrompt(MockPermissionPromptFactory* factory,
PermissionRequestManager* manager);
Delegate* delegate,
bool can_update_ui);
MockPermissionPromptFactory* factory_;
PermissionRequestManager* manager_;
Delegate* delegate_;
bool can_update_ui_;
bool is_visible_;
};
#endif // CHROME_BROWSER_UI_PERMISSION_BUBBLE_MOCK_PERMISSION_PROMPT_H_
......@@ -32,9 +32,21 @@ MockPermissionPromptFactory::~MockPermissionPromptFactory() {
}
std::unique_ptr<PermissionPrompt> MockPermissionPromptFactory::Create(
content::WebContents* web_contents) {
MockPermissionPrompt* prompt = new MockPermissionPrompt(this, manager_);
prompt->can_update_ui_ = can_update_ui_;
content::WebContents* web_contents,
PermissionPrompt::Delegate* delegate) {
MockPermissionPrompt* prompt =
new MockPermissionPrompt(this, delegate, can_update_ui_);
prompts_.push_back(prompt);
show_count_++;
requests_count_ = delegate->Requests().size();
for (const PermissionRequest* request : delegate->Requests())
request_types_seen_.push_back(request->GetPermissionRequestType());
if (!show_bubble_quit_closure_.is_null())
show_bubble_quit_closure_.Run();
manager_->set_auto_response_for_test(response_type_);
return base::WrapUnique(prompt);
}
......@@ -55,11 +67,7 @@ void MockPermissionPromptFactory::DocumentOnLoadCompletedInMainFrame() {
}
bool MockPermissionPromptFactory::is_visible() {
for (auto* prompt : prompts_) {
if (prompt->IsVisible())
return true;
}
return false;
return !prompts_.empty();
}
int MockPermissionPromptFactory::TotalRequestCount() {
......@@ -82,22 +90,10 @@ void MockPermissionPromptFactory::WaitForPermissionBubble() {
// static
std::unique_ptr<PermissionPrompt> MockPermissionPromptFactory::DoNotCreate(
content::WebContents* web_contents) {
content::WebContents* web_contents,
PermissionPrompt::Delegate* delegate) {
NOTREACHED();
return base::WrapUnique(new MockPermissionPrompt(nullptr, nullptr));
}
void MockPermissionPromptFactory::UpdateResponseType() {
manager_->set_auto_response_for_test(response_type_);
}
void MockPermissionPromptFactory::ShowView(MockPermissionPrompt* prompt) {
if (base::ContainsValue(prompts_, prompt))
return;
prompts_.push_back(prompt);
if (!show_bubble_quit_closure_.is_null())
show_bubble_quit_closure_.Run();
return base::WrapUnique(new MockPermissionPrompt(nullptr, nullptr, false));
}
void MockPermissionPromptFactory::HideView(MockPermissionPrompt* prompt) {
......
......@@ -10,9 +10,9 @@
#include "chrome/browser/permissions/permission_request.h"
#include "chrome/browser/permissions/permission_request_manager.h"
#include "chrome/browser/ui/permission_bubble/permission_prompt.h"
class MockPermissionPrompt;
class PermissionPrompt;
namespace content {
class WebContents;
......@@ -29,7 +29,9 @@ class MockPermissionPromptFactory {
~MockPermissionPromptFactory();
// Create method called by the PBM to show a bubble.
std::unique_ptr<PermissionPrompt> Create(content::WebContents* web_contents);
std::unique_ptr<PermissionPrompt> Create(
content::WebContents* web_contents,
PermissionPrompt::Delegate* delegate);
void SetCanUpdateUi(bool can_update_ui);
......@@ -64,10 +66,9 @@ class MockPermissionPromptFactory {
// This shouldn't be called. Is here to fail tests that try to create a bubble
// after the factory has been destroyed.
static std::unique_ptr<PermissionPrompt> DoNotCreate(
content::WebContents* web_contents);
content::WebContents* web_contents,
PermissionPrompt::Delegate* delegate);
void UpdateResponseType();
void ShowView(MockPermissionPrompt* view);
void HideView(MockPermissionPrompt* view);
bool can_update_ui_;
......
......@@ -39,34 +39,21 @@ class PermissionPrompt {
virtual void Closing() = 0;
};
typedef base::Callback<std::unique_ptr<PermissionPrompt>(
content::WebContents*)>
typedef base::Callback<
std::unique_ptr<PermissionPrompt>(content::WebContents*, Delegate*)>
Factory;
// Create a platform specific instance.
// Create and display a platform specific prompt.
static std::unique_ptr<PermissionPrompt> Create(
content::WebContents* web_contents);
content::WebContents* web_contents,
Delegate* delegate);
virtual ~PermissionPrompt() {}
// Sets the delegate which will receive UI events forwarded from the prompt.
virtual void SetDelegate(Delegate* delegate) = 0;
// Show a prompt with the requests from the delegate. This will only be called
// if there is no prompt showing.
virtual void Show() = 0;
// Returns true if the view can accept a new Show() command to coalesce
// requests. Currently the policy is that this should return true if the view
// is being shown and the mouse is not over the view area (!IsMouseHovered).
virtual bool CanAcceptRequestUpdate() = 0;
// Returns true if the prompt UI will manage hiding itself when the user
// resolves the prompt, on page navigation/destruction, and on tab switching.
virtual bool HidesAutomatically() = 0;
// Hides the permission prompt.
virtual void Hide() = 0;
// Updates where the prompt should be anchored. ex: fullscreen toggle.
virtual void UpdateAnchorPosition() = 0;
......
......@@ -249,68 +249,20 @@ void PermissionsBubbleDialogDelegateView::UpdateAnchor(
//////////////////////////////////////////////////////////////////////////////
// PermissionPromptImpl
PermissionPromptImpl::PermissionPromptImpl(Browser* browser)
: browser_(browser),
delegate_(nullptr),
bubble_delegate_(nullptr) {}
PermissionPromptImpl::~PermissionPromptImpl() {
PermissionPromptImpl::PermissionPromptImpl(Browser* browser, Delegate* delegate)
: browser_(browser), delegate_(delegate), bubble_delegate_(nullptr) {
Show();
}
void PermissionPromptImpl::SetDelegate(Delegate* delegate) {
delegate_ = delegate;
}
void PermissionPromptImpl::Show() {
DCHECK(browser_);
DCHECK(browser_->window());
PermissionPromptImpl::~PermissionPromptImpl() {
if (bubble_delegate_)
bubble_delegate_->CloseBubble();
bubble_delegate_ =
new PermissionsBubbleDialogDelegateView(this, delegate_->Requests());
// Set |parent_window| because some valid anchors can become hidden.
bubble_delegate_->set_parent_window(
platform_util::GetViewForWindow(browser_->window()->GetNativeWindow()));
// Compensate for vertical padding in the anchor view's image. Note this is
// ignored whenever the anchor view is null.
bubble_delegate_->set_anchor_view_insets(gfx::Insets(
GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0));
views::Widget* widget =
views::BubbleDialogDelegateView::CreateBubble(bubble_delegate_);
// If a browser window (or popup) other than the bubble parent has focus,
// don't take focus.
if (browser_->window()->IsActive())
widget->Show();
else
widget->ShowInactive();
bubble_delegate_->SizeToContents();
bubble_delegate_->UpdateAnchor(GetAnchorView(),
GetAnchorPoint(),
GetAnchorArrow());
}
bool PermissionPromptImpl::CanAcceptRequestUpdate() {
return !(bubble_delegate_ && bubble_delegate_->IsMouseHovered());
}
bool PermissionPromptImpl::HidesAutomatically() {
return false;
}
void PermissionPromptImpl::Hide() {
if (bubble_delegate_) {
bubble_delegate_->CloseBubble();
bubble_delegate_ = nullptr;
}
}
void PermissionPromptImpl::UpdateAnchorPosition() {
DCHECK(browser_);
DCHECK(browser_->window());
......@@ -351,3 +303,34 @@ void PermissionPromptImpl::Deny() {
if (delegate_)
delegate_->Deny();
}
void PermissionPromptImpl::Show() {
DCHECK(browser_);
DCHECK(browser_->window());
bubble_delegate_ =
new PermissionsBubbleDialogDelegateView(this, delegate_->Requests());
// Set |parent_window| because some valid anchors can become hidden.
bubble_delegate_->set_parent_window(
platform_util::GetViewForWindow(browser_->window()->GetNativeWindow()));
// Compensate for vertical padding in the anchor view's image. Note this is
// ignored whenever the anchor view is null.
bubble_delegate_->set_anchor_view_insets(gfx::Insets(
GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0));
views::Widget* widget =
views::BubbleDialogDelegateView::CreateBubble(bubble_delegate_);
// If a browser window (or popup) other than the bubble parent has focus,
// don't take focus.
if (browser_->window()->IsActive())
widget->Show();
else
widget->ShowInactive();
bubble_delegate_->SizeToContents();
bubble_delegate_->UpdateAnchor(GetAnchorView(), GetAnchorPoint(),
GetAnchorArrow());
}
......@@ -23,15 +23,11 @@ class PermissionsBubbleDialogDelegateView;
class PermissionPromptImpl : public PermissionPrompt {
public:
explicit PermissionPromptImpl(Browser* browser);
PermissionPromptImpl(Browser* browser, Delegate* delegate);
~PermissionPromptImpl() override;
// PermissionPrompt:
void SetDelegate(Delegate* delegate) override;
void Show() override;
bool CanAcceptRequestUpdate() override;
bool HidesAutomatically() override;
void Hide() override;
void UpdateAnchorPosition() override;
gfx::NativeWindow GetNativeWindow() override;
......@@ -41,6 +37,8 @@ class PermissionPromptImpl : public PermissionPrompt {
void Deny();
private:
void Show();
// These three functions have separate implementations for Views-based and
// Cocoa-based browsers, to allow this bubble to be used in either.
......
......@@ -50,7 +50,8 @@ views::BubbleBorder::Arrow PermissionPromptImpl::GetAnchorArrow() {
// static
std::unique_ptr<PermissionPrompt> PermissionPrompt::Create(
content::WebContents* web_contents) {
content::WebContents* web_contents,
Delegate* delegate) {
return base::WrapUnique(new PermissionPromptImpl(
chrome::FindBrowserWithWebContents(web_contents)));
chrome::FindBrowserWithWebContents(web_contents), delegate));
}
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