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

Side by Side Diff: chrome/browser/permissions/permission_request_manager.cc

Issue 2781803002: Don't delete the PermissionPromptAndroid when switching tabs (Closed)
Patch Set: . Created 3 years, 8 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
« no previous file with comments | « chrome/browser/android/chrome_jni_registrar.cc ('k') | chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/permissions/permission_request_manager.h" 5 #include "chrome/browser/permissions/permission_request_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PermissionRequestManager); 75 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PermissionRequestManager);
76 76
77 PermissionRequestManager::PermissionRequestManager( 77 PermissionRequestManager::PermissionRequestManager(
78 content::WebContents* web_contents) 78 content::WebContents* web_contents)
79 : content::WebContentsObserver(web_contents), 79 : content::WebContentsObserver(web_contents),
80 view_factory_(base::Bind(&PermissionPrompt::Create)), 80 view_factory_(base::Bind(&PermissionPrompt::Create)),
81 view_(nullptr), 81 view_(nullptr),
82 main_frame_has_fully_loaded_(false), 82 main_frame_has_fully_loaded_(false),
83 persist_(true), 83 persist_(true),
84 auto_response_for_test_(NONE), 84 auto_response_for_test_(NONE),
85 weak_factory_(this) {} 85 weak_factory_(this) {
86 #if defined(OS_ANDROID)
87 view_ = view_factory_.Run(web_contents);
88 view_->SetDelegate(this);
89 #endif
90 }
86 91
87 PermissionRequestManager::~PermissionRequestManager() { 92 PermissionRequestManager::~PermissionRequestManager() {
88 if (view_ != NULL) 93 if (view_ != NULL)
89 view_->SetDelegate(NULL); 94 view_->SetDelegate(NULL);
90 95
91 for (PermissionRequest* request : requests_) 96 for (PermissionRequest* request : requests_)
92 request->RequestFinished(); 97 request->RequestFinished();
93 for (PermissionRequest* request : queued_requests_) 98 for (PermissionRequest* request : queued_requests_)
94 request->RequestFinished(); 99 request->RequestFinished();
95 for (PermissionRequest* request : queued_frame_requests_) 100 for (PermissionRequest* request : queued_frame_requests_)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 it->second->RequestFinished(); 222 it->second->RequestFinished();
218 duplicate_requests_.erase(it); 223 duplicate_requests_.erase(it);
219 return; 224 return;
220 } 225 }
221 } 226 }
222 227
223 NOTREACHED(); // Callers should not cancel requests that are not pending. 228 NOTREACHED(); // Callers should not cancel requests that are not pending.
224 } 229 }
225 230
226 void PermissionRequestManager::HideBubble() { 231 void PermissionRequestManager::HideBubble() {
232 #if defined(ANDROID)
233 // The infobar system manages infobar lifetime and visibility so don't delete
234 // the PermissionPromptAndroid.
235 NOTREACHED();
236 #else
227 // Disengage from the existing view if there is one. 237 // Disengage from the existing view if there is one.
228 if (!view_) 238 if (!view_)
229 return; 239 return;
230 240
231 view_->SetDelegate(nullptr); 241 view_->SetDelegate(nullptr);
232 view_->Hide(); 242 view_->Hide();
233 view_.reset(); 243 view_.reset();
244 #endif
234 } 245 }
235 246
236 void PermissionRequestManager::DisplayPendingRequests() { 247 void PermissionRequestManager::DisplayPendingRequests() {
raymes 2017/04/03 04:28:25 I wonder if we should have NOTREACHED() here on An
raymes 2017/04/03 04:30:52 Another thought is that I wonder if in the long ru
237 if (IsBubbleVisible()) 248 if (IsBubbleVisible())
238 return; 249 return;
239 250
240 view_ = view_factory_.Run(web_contents()); 251 view_ = view_factory_.Run(web_contents());
241 view_->SetDelegate(this); 252 view_->SetDelegate(this);
242 253
243 TriggerShowBubble(); 254 TriggerShowBubble();
244 } 255 }
245 256
246 void PermissionRequestManager::UpdateAnchorPosition() { 257 void PermissionRequestManager::UpdateAnchorPosition() {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 case DENY_ALL: 532 case DENY_ALL:
522 Deny(); 533 Deny();
523 break; 534 break;
524 case DISMISS: 535 case DISMISS:
525 Closing(); 536 Closing();
526 break; 537 break;
527 case NONE: 538 case NONE:
528 NOTREACHED(); 539 NOTREACHED();
529 } 540 }
530 } 541 }
OLDNEW
« no previous file with comments | « chrome/browser/android/chrome_jni_registrar.cc ('k') | chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698