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

Unified Diff: chrome/browser/ui/website_settings/permission_bubble_manager.cc

Issue 1154943008: Update push messaging tests to use both infobars and bubbles (w/ autoresponse) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Put the auto-responder directly into the PermissionBubbleManager Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/website_settings/permission_bubble_manager.cc
diff --git a/chrome/browser/ui/website_settings/permission_bubble_manager.cc b/chrome/browser/ui/website_settings/permission_bubble_manager.cc
index b8a53e5f08765fb3e7b7617707defa9c23b538b6..4f383dd52d5c9602e5ce1d5f5e5cdd89bb6bedd8 100644
--- a/chrome/browser/ui/website_settings/permission_bubble_manager.cc
+++ b/chrome/browser/ui/website_settings/permission_bubble_manager.cc
@@ -78,12 +78,14 @@ bool PermissionBubbleManager::Enabled() {
PermissionBubbleManager::PermissionBubbleManager(
content::WebContents* web_contents)
- : content::WebContentsObserver(web_contents),
- require_user_gesture_(false),
- bubble_showing_(false),
- view_(NULL),
- request_url_has_loaded_(false),
- weak_factory_(this) {}
+ : content::WebContentsObserver(web_contents),
+ require_user_gesture_(false),
+ bubble_showing_(false),
+ view_(NULL),
+ request_url_has_loaded_(false),
+ auto_response_for_testing_only_(NOT_TESTING),
+ weak_factory_(this) {
+}
PermissionBubbleManager::~PermissionBubbleManager() {
if (view_ != NULL)
@@ -346,6 +348,10 @@ void PermissionBubbleManager::TriggerShowBubble() {
// case we may do in-line calling of finalization.
bubble_showing_ = true;
view_->Show(requests_, accept_states_);
+
+ // If in testing mode, automatically respond to the bubble that was shown.
+ if (auto_response_for_testing_only_ != NOT_TESTING)
+ DoAutoResponseForTesting();
}
void PermissionBubbleManager::FinalizeBubble() {
@@ -414,3 +420,23 @@ bool PermissionBubbleManager::HasUserGestureRequest(
return false;
}
+void PermissionBubbleManager::set_auto_response_for_testing_only_(
+ AutoResponseType response) {
+ auto_response_for_testing_only_ = response;
msw 2015/06/05 01:51:59 nit: inline the body for a simple setter with a un
felt 2015/06/05 06:37:29 Done.
+}
+
+void PermissionBubbleManager::DoAutoResponseForTesting() {
+ switch (auto_response_for_testing_only_) {
+ case NOT_TESTING:
+ return;
msw 2015/06/05 01:51:59 nit: maybe NOTREACHED() here if you check outside
felt 2015/06/05 06:37:29 Done.
+ case ACCEPT_ALL:
+ Accept();
+ break;
+ case DENY_ALL:
+ Deny();
+ break;
+ case DISMISS:
+ Closing();
+ break;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698