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

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

Issue 2755593002: Remove pointer from PermissionPromptAndroid to InfoBar (Closed)
Patch Set: rebase over 2757483002 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
« no previous file with comments | « chrome/browser/permissions/permission_prompt_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/permissions/permission_prompt_android.h" 5 #include "chrome/browser/permissions/permission_prompt_android.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/infobars/infobar_service.h" 8 #include "chrome/browser/infobars/infobar_service.h"
9 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" 9 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h"
10 #include "chrome/browser/permissions/grouped_permission_infobar_delegate_android .h" 10 #include "chrome/browser/permissions/grouped_permission_infobar_delegate_android .h"
11 #include "chrome/browser/permissions/permission_request.h" 11 #include "chrome/browser/permissions/permission_request.h"
12 #include "chrome/browser/permissions/permission_request_id.h" 12 #include "chrome/browser/permissions/permission_request_id.h"
13 #include "components/infobars/core/infobar.h" 13 #include "components/infobars/core/infobar.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 15
16 PermissionPromptAndroid::PermissionPromptAndroid( 16 PermissionPromptAndroid::PermissionPromptAndroid(
17 content::WebContents* web_contents) 17 content::WebContents* web_contents)
18 : web_contents_(web_contents), delegate_(nullptr), infobar_(nullptr) { 18 : web_contents_(web_contents), delegate_(nullptr) {
19 DCHECK(web_contents); 19 DCHECK(web_contents);
20 } 20 }
21 21
22 PermissionPromptAndroid::~PermissionPromptAndroid() { 22 PermissionPromptAndroid::~PermissionPromptAndroid() {
23 if (infobar_) {
24 GroupedPermissionInfoBarDelegate* infobar_delegate =
25 static_cast<GroupedPermissionInfoBarDelegate*>(infobar_->delegate());
26 infobar_delegate->PermissionPromptDestroyed();
dominickn 2017/03/16 03:58:23 Since this is the only method that calls Permissio
Timothy Loh 2017/03/17 00:52:47 Done.
27 }
28 } 23 }
29 24
30 void PermissionPromptAndroid::SetDelegate(Delegate* delegate) { 25 void PermissionPromptAndroid::SetDelegate(Delegate* delegate) {
31 delegate_ = delegate; 26 delegate_ = delegate;
32 } 27 }
33 28
34 void PermissionPromptAndroid::Show( 29 void PermissionPromptAndroid::Show(
35 const std::vector<PermissionRequest*>& requests, 30 const std::vector<PermissionRequest*>& requests,
36 const std::vector<bool>& values) { 31 const std::vector<bool>& values) {
37 InfoBarService* infobar_service = 32 InfoBarService* infobar_service =
38 InfoBarService::FromWebContents(web_contents_); 33 InfoBarService::FromWebContents(web_contents_);
39 if (!infobar_service) 34 if (!infobar_service)
40 return; 35 return;
41 36
42 requests_ = requests; 37 requests_ = requests;
43 infobar_ = GroupedPermissionInfoBarDelegate::Create(this, infobar_service, 38 GroupedPermissionInfoBarDelegate::Create(this, infobar_service,
44 requests[0]->GetOrigin()); 39 requests[0]->GetOrigin());
45 } 40 }
46 41
47 bool PermissionPromptAndroid::CanAcceptRequestUpdate() { 42 bool PermissionPromptAndroid::CanAcceptRequestUpdate() {
48 return false; 43 return false;
49 } 44 }
50 45
51 void PermissionPromptAndroid::Hide() { 46 void PermissionPromptAndroid::Hide() {
52 InfoBarService* infobar_service = 47 // No-op. Hide() is called in three cases:
53 InfoBarService::FromWebContents(web_contents_); 48 // - After the user resolves a prompt. The infobar manager will hide the
54 if (infobar_ && infobar_service) { 49 // prompt for us.
55 infobar_service->RemoveInfoBar(infobar_); 50 // - DidFinishNavigation, etc. The infobar manager handles this.
56 } 51 // - PermissionManager::CancelRequest(). As CanAcceptRequestUpdate() returns
57 infobar_ = nullptr; 52 // false, it doesn't call into here and instead dummies out the callbacks.
58 } 53 }
59 54
60 bool PermissionPromptAndroid::IsVisible() { 55 bool PermissionPromptAndroid::IsVisible() {
61 return infobar_ != nullptr; 56 return !requests_.empty();
62 } 57 }
63 58
64 void PermissionPromptAndroid::UpdateAnchorPosition() { 59 void PermissionPromptAndroid::UpdateAnchorPosition() {
65 NOTREACHED() << "UpdateAnchorPosition is not implemented"; 60 NOTREACHED() << "UpdateAnchorPosition is not implemented";
66 } 61 }
67 62
68 gfx::NativeWindow PermissionPromptAndroid::GetNativeWindow() { 63 gfx::NativeWindow PermissionPromptAndroid::GetNativeWindow() {
69 NOTREACHED() << "GetNativeWindow is not implemented"; 64 NOTREACHED() << "GetNativeWindow is not implemented";
70 return nullptr; 65 return nullptr;
71 } 66 }
(...skipping 19 matching lines...) Expand all
91 requests_.clear(); 86 requests_.clear();
92 if (delegate_) 87 if (delegate_)
93 delegate_->Deny(); 88 delegate_->Deny();
94 } 89 }
95 90
96 // static 91 // static
97 std::unique_ptr<PermissionPrompt> PermissionPrompt::Create( 92 std::unique_ptr<PermissionPrompt> PermissionPrompt::Create(
98 content::WebContents* web_contents) { 93 content::WebContents* web_contents) {
99 return base::MakeUnique<PermissionPromptAndroid>(web_contents); 94 return base::MakeUnique<PermissionPromptAndroid>(web_contents);
100 } 95 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_prompt_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698