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

Side by Side Diff: chrome/browser/ui/permission_bubble/mock_permission_prompt_factory.cc

Issue 2770423002: Do not show permission bubble when browser is not active (Closed)
Patch Set: BrowserListObserver Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/permission_bubble/mock_permission_prompt_factory.h" 5 #include "chrome/browser/ui/permission_bubble/mock_permission_prompt_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 bool MockPermissionPromptFactory::is_visible() { 58 bool MockPermissionPromptFactory::is_visible() {
59 for (auto* prompt : prompts_) { 59 for (auto* prompt : prompts_) {
60 if (prompt->IsVisible()) 60 if (prompt->IsVisible())
61 return true; 61 return true;
62 } 62 }
63 return false; 63 return false;
64 } 64 }
65 65
66 void MockPermissionPromptFactory::WaitForPermissionBubble() { 66 void MockPermissionPromptFactory::WaitForPermissionBubble() {
67 if (is_visible()) 67 if (is_visible() || !manager_->browser_active_)
68 return; 68 return;
69 DCHECK(show_bubble_quit_closure_.is_null()); 69 DCHECK(show_bubble_quit_closure_.is_null());
70 base::RunLoop loop; 70 base::RunLoop loop;
71 show_bubble_quit_closure_ = loop.QuitClosure(); 71 show_bubble_quit_closure_ = loop.QuitClosure();
72 loop.Run(); 72 loop.Run();
73 show_bubble_quit_closure_ = base::Closure(); 73 show_bubble_quit_closure_ = base::Closure();
74 } 74 }
75 75
76 // static 76 // static
77 std::unique_ptr<PermissionPrompt> MockPermissionPromptFactory::DoNotCreate( 77 std::unique_ptr<PermissionPrompt> MockPermissionPromptFactory::DoNotCreate(
(...skipping 13 matching lines...) Expand all
91 91
92 if (!show_bubble_quit_closure_.is_null()) 92 if (!show_bubble_quit_closure_.is_null())
93 show_bubble_quit_closure_.Run(); 93 show_bubble_quit_closure_.Run();
94 } 94 }
95 95
96 void MockPermissionPromptFactory::HideView(MockPermissionPrompt* prompt) { 96 void MockPermissionPromptFactory::HideView(MockPermissionPrompt* prompt) {
97 auto it = std::find(prompts_.begin(), prompts_.end(), prompt); 97 auto it = std::find(prompts_.begin(), prompts_.end(), prompt);
98 if (it != prompts_.end()) 98 if (it != prompts_.end())
99 prompts_.erase(it); 99 prompts_.erase(it);
100 } 100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698