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

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

Issue 1913413002: [WIP][POC] Base URL: https://chromium.googlesource.com/chromium/src.git@permission-request-rename
Patch Set: rebase Created 4 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/permissions/permission_request_impl.cc ('k') | chrome/browser/ui/tab_helpers.cc » ('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/metrics/user_metrics_action.h" 10 #include "base/metrics/user_metrics_action.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 void PermissionRequestManager::Observer::OnBubbleAdded() { 74 void PermissionRequestManager::Observer::OnBubbleAdded() {
75 } 75 }
76 76
77 // PermissionRequestManager ---------------------------------------------------- 77 // PermissionRequestManager ----------------------------------------------------
78 78
79 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PermissionRequestManager); 79 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PermissionRequestManager);
80 80
81 PermissionRequestManager::PermissionRequestManager( 81 PermissionRequestManager::PermissionRequestManager(
82 content::WebContents* web_contents) 82 content::WebContents* web_contents)
83 : content::WebContentsObserver(web_contents), 83 : content::WebContentsObserver(web_contents),
84 #if !defined(OS_ANDROID) // No bubbles in android tests. 84 // #if !defined(OS_ANDROID) // No bubbles in android tests.
85 view_factory_(base::Bind(&PermissionBubbleView::Create)), 85 view_factory_(base::Bind(&PermissionBubbleView::Create)),
86 #endif 86 // #endif
87 view_(nullptr), 87 // view_(nullptr),
88 main_frame_has_fully_loaded_(false), 88 main_frame_has_fully_loaded_(false),
89 auto_response_for_test_(NONE), 89 auto_response_for_test_(NONE),
90 weak_factory_(this) { 90 weak_factory_(this) {
91 } 91 }
92 92
93 PermissionRequestManager::~PermissionRequestManager() { 93 PermissionRequestManager::~PermissionRequestManager() {
94 if (view_ != NULL) 94 if (view_ != NULL)
95 view_->SetDelegate(NULL); 95 view_->SetDelegate(NULL);
96 96
97 for (PermissionRequest* request : requests_) 97 for (PermissionRequest* request : requests_)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 duplicate_requests_.insert(std::make_pair(existing_request, request)); 133 duplicate_requests_.insert(std::make_pair(existing_request, request));
134 return; 134 return;
135 } 135 }
136 136
137 if (IsBubbleVisible()) { 137 if (IsBubbleVisible()) {
138 if (is_main_frame) { 138 if (is_main_frame) {
139 content::RecordAction( 139 content::RecordAction(
140 base::UserMetricsAction("PermissionBubbleRequestQueued")); 140 base::UserMetricsAction("PermissionBubbleRequestQueued"));
141 queued_requests_.push_back(request); 141 queued_requests_.push_back(request);
142 LOG(INFO) << "QUEUING REQUEST";
142 } else { 143 } else {
143 content::RecordAction( 144 content::RecordAction(
144 base::UserMetricsAction("PermissionBubbleIFrameRequestQueued")); 145 base::UserMetricsAction("PermissionBubbleIFrameRequestQueued"));
145 queued_frame_requests_.push_back(request); 146 queued_frame_requests_.push_back(request);
146 } 147 }
147 return; 148 return;
148 } 149 }
149 150
150 if (is_main_frame) { 151 if (is_main_frame) {
151 requests_.push_back(request); 152 requests_.push_back(request);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 238
238 view_->SetDelegate(nullptr); 239 view_->SetDelegate(nullptr);
239 view_->Hide(); 240 view_->Hide();
240 view_.reset(); 241 view_.reset();
241 } 242 }
242 243
243 void PermissionRequestManager::DisplayPendingRequests() { 244 void PermissionRequestManager::DisplayPendingRequests() {
244 if (IsBubbleVisible()) 245 if (IsBubbleVisible())
245 return; 246 return;
246 247
248 // #if defined(OS_ANDROID)
249 // NOTREACHED();
250 // return;
251 // #else
247 #if defined(OS_ANDROID) 252 #if defined(OS_ANDROID)
248 NOTREACHED(); 253 view_ = view_factory_.Run(web_contents());
249 return;
250 #else 254 #else
251 view_ = view_factory_.Run(chrome::FindBrowserWithWebContents(web_contents())); 255 view_ = view_factory_.Run(chrome::FindBrowserWithWebContents(web_contents()));
256 #endif
252 view_->SetDelegate(this); 257 view_->SetDelegate(this);
253 #endif 258 // #endif
254 259
255 TriggerShowBubble(); 260 TriggerShowBubble();
256 } 261 }
257 262
258 void PermissionRequestManager::UpdateAnchorPosition() { 263 void PermissionRequestManager::UpdateAnchorPosition() {
259 if (view_) 264 if (view_)
260 view_->UpdateAnchorPosition(); 265 view_->UpdateAnchorPosition();
261 } 266 }
262 267
263 bool PermissionRequestManager::IsBubbleVisible() { 268 bool PermissionRequestManager::IsBubbleVisible() {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return; 361 return;
357 362
358 content::BrowserThread::PostTask( 363 content::BrowserThread::PostTask(
359 content::BrowserThread::UI, 364 content::BrowserThread::UI,
360 FROM_HERE, 365 FROM_HERE,
361 base::Bind(&PermissionRequestManager::TriggerShowBubble, 366 base::Bind(&PermissionRequestManager::TriggerShowBubble,
362 weak_factory_.GetWeakPtr())); 367 weak_factory_.GetWeakPtr()));
363 } 368 }
364 369
365 void PermissionRequestManager::TriggerShowBubble() { 370 void PermissionRequestManager::TriggerShowBubble() {
371 LOG(INFO) << "TRIGGER SHOW BUBBLE";
372
373 // TODO: set up calls when tab is created like on Desktop.
374 if (!view_)
375 view_ = view_factory_.Run(web_contents());
376
366 if (!view_) 377 if (!view_)
367 return; 378 return;
379 LOG(INFO) << "HAS VIEW";
368 if (IsBubbleVisible()) 380 if (IsBubbleVisible())
369 return; 381 return;
382 LOG(INFO) << "IS NOT VISIBLE";
370 if (!main_frame_has_fully_loaded_) 383 if (!main_frame_has_fully_loaded_)
371 return; 384 return;
372 if (requests_.empty() && queued_requests_.empty() && 385 if (requests_.empty() && queued_requests_.empty() &&
373 queued_frame_requests_.empty()) { 386 queued_frame_requests_.empty()) {
374 return; 387 return;
375 } 388 }
376 389
377 if (requests_.empty()) { 390 if (requests_.empty()) {
378 if (queued_requests_.size()) 391 if (queued_requests_.size())
379 requests_.swap(queued_requests_); 392 requests_.swap(queued_requests_);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 case DENY_ALL: 523 case DENY_ALL:
511 Deny(); 524 Deny();
512 break; 525 break;
513 case DISMISS: 526 case DISMISS:
514 Closing(); 527 Closing();
515 break; 528 break;
516 case NONE: 529 case NONE:
517 NOTREACHED(); 530 NOTREACHED();
518 } 531 }
519 } 532 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_request_impl.cc ('k') | chrome/browser/ui/tab_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698