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

Side by Side 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: Factor out the GetPermissionBubbleManager calls 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 5 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/user_metrics_action.h" 9 #include "base/metrics/user_metrics_action.h"
10 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" 10 #include "chrome/browser/ui/website_settings/permission_bubble_request.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 base::string16 message_text_; 50 base::string16 message_text_;
51 base::string16 message_fragment_; 51 base::string16 message_fragment_;
52 bool user_gesture_; 52 bool user_gesture_;
53 GURL hostname_; 53 GURL hostname_;
54 }; 54 };
55 55
56 } // namespace 56 } // namespace
57 57
58 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PermissionBubbleManager); 58 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PermissionBubbleManager);
59 59
60 // PermissionBubbleManager::Observer -------------------------------------------
61 PermissionBubbleManager::Observer::~Observer() {
62 }
63
64 void PermissionBubbleManager::Observer::OnBubbleAdded() {
65 }
66
67 // PermissionBubbleManager -----------------------------------------------------
68
60 // static 69 // static
61 bool PermissionBubbleManager::Enabled() { 70 bool PermissionBubbleManager::Enabled() {
62 // Command line flags take precedence. 71 // Command line flags take precedence.
63 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 72 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
64 switches::kEnablePermissionsBubbles)) 73 switches::kEnablePermissionsBubbles))
65 return true; 74 return true;
66 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 75 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
67 switches::kDisablePermissionsBubbles)) 76 switches::kDisablePermissionsBubbles))
68 return false; 77 return false;
69 78
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // TODO(leng): Currently all requests default to true. If that changes: 348 // TODO(leng): Currently all requests default to true. If that changes:
340 // a) Add additional accept_state queues to store default values. 349 // a) Add additional accept_state queues to store default values.
341 // b) Change the request API to provide the default value. 350 // b) Change the request API to provide the default value.
342 accept_states_.resize(requests_.size(), true); 351 accept_states_.resize(requests_.size(), true);
343 } 352 }
344 353
345 // Note: this should appear above Show() for testing, since in that 354 // Note: this should appear above Show() for testing, since in that
346 // case we may do in-line calling of finalization. 355 // case we may do in-line calling of finalization.
347 bubble_showing_ = true; 356 bubble_showing_ = true;
348 view_->Show(requests_, accept_states_); 357 view_->Show(requests_, accept_states_);
358 NotifyBubbleAdded(view_);
msw 2015/06/04 01:22:08 Instead of adding the observer and responder class
felt 2015/06/05 00:38:21 There is one disadvantage of the set_auto_response
349 } 359 }
350 360
351 void PermissionBubbleManager::FinalizeBubble() { 361 void PermissionBubbleManager::FinalizeBubble() {
352 if (view_) 362 if (view_)
353 view_->Hide(); 363 view_->Hide();
354 bubble_showing_ = false; 364 bubble_showing_ = false;
355 365
356 std::vector<PermissionBubbleRequest*>::iterator requests_iter; 366 std::vector<PermissionBubbleRequest*>::iterator requests_iter;
357 for (requests_iter = requests_.begin(); 367 for (requests_iter = requests_.begin();
358 requests_iter != requests_.end(); 368 requests_iter != requests_.end();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 bool PermissionBubbleManager::HasUserGestureRequest( 417 bool PermissionBubbleManager::HasUserGestureRequest(
408 const std::vector<PermissionBubbleRequest*>& queue) { 418 const std::vector<PermissionBubbleRequest*>& queue) {
409 std::vector<PermissionBubbleRequest*>::const_iterator iter; 419 std::vector<PermissionBubbleRequest*>::const_iterator iter;
410 for (iter = queue.begin(); iter != queue.end(); iter++) { 420 for (iter = queue.begin(); iter != queue.end(); iter++) {
411 if ((*iter)->HasUserGesture()) 421 if ((*iter)->HasUserGesture())
412 return true; 422 return true;
413 } 423 }
414 return false; 424 return false;
415 } 425 }
416 426
427 void PermissionBubbleManager::AddObserver(Observer* obs) {
428 observer_list_.AddObserver(obs);
429 }
430
431 void PermissionBubbleManager::RemoveObserver(Observer* obs) {
432 observer_list_.RemoveObserver(obs);
433 }
434
435 void PermissionBubbleManager::NotifyBubbleAdded(PermissionBubbleView* bubble) {
436 FOR_EACH_OBSERVER(Observer, observer_list_, OnBubbleAdded());
437 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698