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

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

Issue 2941013002: Hook up persist toggle UMA for PermissionRequestManager on Android (Closed)
Patch Set: Created 3 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
« 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/permissions/grouped_permission_infobar_delegate_android .h" 9 #include "chrome/browser/permissions/grouped_permission_infobar_delegate_android .h"
10 #include "chrome/browser/permissions/permission_dialog_delegate.h" 10 #include "chrome/browser/permissions/permission_dialog_delegate.h"
11 #include "chrome/browser/permissions/permission_request.h" 11 #include "chrome/browser/permissions/permission_request.h"
12 #include "chrome/browser/permissions/permission_uma_util.h"
12 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
13 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
14 #include "chrome/grit/theme_resources.h" 15 #include "chrome/grit/theme_resources.h"
15 #include "components/strings/grit/components_strings.h" 16 #include "components/strings/grit/components_strings.h"
16 #include "components/url_formatter/elide_url.h" 17 #include "components/url_formatter/elide_url.h"
17 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
18 19
19 PermissionPromptAndroid::PermissionPromptAndroid( 20 PermissionPromptAndroid::PermissionPromptAndroid(
20 content::WebContents* web_contents) 21 content::WebContents* web_contents)
21 : web_contents_(web_contents), delegate_(nullptr) { 22 : web_contents_(web_contents), delegate_(nullptr) {
raymes 2017/06/15 04:41:36 nit: initialize persist_
Timothy Loh 2017/06/15 06:00:58 Done.
22 DCHECK(web_contents); 23 DCHECK(web_contents);
23 } 24 }
24 25
25 PermissionPromptAndroid::~PermissionPromptAndroid() {} 26 PermissionPromptAndroid::~PermissionPromptAndroid() {}
26 27
27 void PermissionPromptAndroid::SetDelegate(Delegate* delegate) { 28 void PermissionPromptAndroid::SetDelegate(Delegate* delegate) {
28 delegate_ = delegate; 29 delegate_ = delegate;
29 } 30 }
30 31
31 void PermissionPromptAndroid::Show() { 32 void PermissionPromptAndroid::Show() {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 NOTREACHED() << "GetNativeWindow is not implemented"; 71 NOTREACHED() << "GetNativeWindow is not implemented";
71 return nullptr; 72 return nullptr;
72 } 73 }
73 74
74 void PermissionPromptAndroid::Closing() { 75 void PermissionPromptAndroid::Closing() {
75 if (delegate_) 76 if (delegate_)
76 delegate_->Closing(); 77 delegate_->Closing();
77 } 78 }
78 79
79 void PermissionPromptAndroid::TogglePersist(bool value) { 80 void PermissionPromptAndroid::TogglePersist(bool value) {
81 persist_ = value;
80 if (delegate_) 82 if (delegate_)
81 delegate_->TogglePersist(value); 83 delegate_->TogglePersist(value);
82 } 84 }
83 85
84 void PermissionPromptAndroid::Accept() { 86 void PermissionPromptAndroid::Accept() {
85 if (delegate_) 87 if (delegate_) {
88 if (ShouldShowPersistenceToggle()) {
89 for (const PermissionRequest* request : delegate_->Requests()) {
90 PermissionUmaUtil::PermissionPromptAcceptedWithPersistenceToggle(
91 request->GetContentSettingsType(), persist_);
raymes 2017/06/15 04:41:36 Dom said there is a way to test the histograms fro
Timothy Loh 2017/06/15 06:00:58 I added an assert in GeolocationTest.java, could d
92 }
93 }
86 delegate_->Accept(); 94 delegate_->Accept();
95 }
87 } 96 }
88 97
89 void PermissionPromptAndroid::Deny() { 98 void PermissionPromptAndroid::Deny() {
90 if (delegate_) 99 if (delegate_) {
100 if (ShouldShowPersistenceToggle()) {
101 for (const PermissionRequest* request : delegate_->Requests()) {
102 PermissionUmaUtil::PermissionPromptDeniedWithPersistenceToggle(
103 request->GetContentSettingsType(), persist_);
104 }
105 }
91 delegate_->Deny(); 106 delegate_->Deny();
107 }
92 } 108 }
93 109
94 size_t PermissionPromptAndroid::PermissionCount() const { 110 size_t PermissionPromptAndroid::PermissionCount() const {
95 return delegate_->Requests().size(); 111 return delegate_->Requests().size();
96 } 112 }
97 113
98 bool PermissionPromptAndroid::ShouldShowPersistenceToggle() const { 114 bool PermissionPromptAndroid::ShouldShowPersistenceToggle() const {
99 for (const PermissionRequest* request : delegate_->Requests()) { 115 for (const PermissionRequest* request : delegate_->Requests()) {
100 if (!request->ShouldShowPersistenceToggle()) 116 if (!request->ShouldShowPersistenceToggle())
101 return false; 117 return false;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 return GURL(chrome::kEnhancedPlaybackNotificationLearnMoreURL); 175 return GURL(chrome::kEnhancedPlaybackNotificationLearnMoreURL);
160 } 176 }
161 return GURL(); 177 return GURL();
162 } 178 }
163 179
164 // static 180 // static
165 std::unique_ptr<PermissionPrompt> PermissionPrompt::Create( 181 std::unique_ptr<PermissionPrompt> PermissionPrompt::Create(
166 content::WebContents* web_contents) { 182 content::WebContents* web_contents) {
167 return base::MakeUnique<PermissionPromptAndroid>(web_contents); 183 return base::MakeUnique<PermissionPromptAndroid>(web_contents);
168 } 184 }
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