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

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

Issue 2443463003: Remove PermissionInfoBarDelegate from desktop builds. (Closed)
Patch Set: Address comments Created 4 years, 2 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 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_infobar_delegate.h" 5 #include "chrome/browser/permissions/permission_infobar_delegate.h"
6 6
7 #include "build/build_config.h"
8 #include "chrome/browser/geolocation/geolocation_infobar_delegate_android.h"
9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "chrome/browser/media/midi_permission_infobar_delegate_android.h"
11 #include "chrome/browser/media/protected_media_identifier_infobar_delegate_andro id.h"
12 #include "chrome/browser/notifications/notification_permission_infobar_delegate. h"
7 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" 13 #include "chrome/browser/permissions/permission_decision_auto_blocker.h"
8 #include "chrome/browser/permissions/permission_request.h" 14 #include "chrome/browser/permissions/permission_request.h"
9 #include "chrome/browser/permissions/permission_uma_util.h" 15 #include "chrome/browser/permissions/permission_uma_util.h"
10 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
17 #include "components/infobars/core/infobar.h"
11 #include "components/url_formatter/elide_url.h" 18 #include "components/url_formatter/elide_url.h"
12 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
13 20
21 // static
22 infobars::InfoBar* PermissionInfoBarDelegate::Create(
23 content::PermissionType type,
24 InfoBarService* infobar_service,
25 const GURL& requesting_frame,
26 bool user_gesture,
27 Profile* profile,
28 const PermissionSetCallback& callback) {
29 switch (type) {
30 case content::PermissionType::GEOLOCATION:
31 return infobar_service->AddInfoBar(
32 CreatePermissionInfoBar(std::unique_ptr<PermissionInfoBarDelegate>(
33 new GeolocationInfoBarDelegateAndroid(
34 requesting_frame, user_gesture, profile, callback))));
35 #if defined(ENABLE_NOTIFICATIONS)
36 case content::PermissionType::NOTIFICATIONS:
37 case content::PermissionType::PUSH_MESSAGING:
38 return infobar_service->AddInfoBar(
39 CreatePermissionInfoBar(std::unique_ptr<PermissionInfoBarDelegate>(
40 new NotificationPermissionInfoBarDelegate(
41 requesting_frame, user_gesture, profile, callback))));
42 #endif // ENABLE_NOTIFICATIONS
43 case content::PermissionType::MIDI_SYSEX:
44 return infobar_service->AddInfoBar(
45 CreatePermissionInfoBar(std::unique_ptr<PermissionInfoBarDelegate>(
46 new MidiPermissionInfoBarDelegateAndroid(
47 requesting_frame, user_gesture, profile, callback))));
48 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
49 return infobar_service->AddInfoBar(
50 CreatePermissionInfoBar(std::unique_ptr<PermissionInfoBarDelegate>(
51 new ProtectedMediaIdentifierInfoBarDelegateAndroid(
52 requesting_frame, user_gesture, profile, callback))));
53 default:
54 NOTREACHED();
55 return nullptr;
56 }
57 }
58
14 PermissionInfoBarDelegate::~PermissionInfoBarDelegate() { 59 PermissionInfoBarDelegate::~PermissionInfoBarDelegate() {
15 if (!action_taken_) { 60 if (!action_taken_) {
16 PermissionUmaUtil::PermissionIgnored( 61 PermissionUmaUtil::PermissionIgnored(
17 permission_type_, 62 permission_type_,
18 user_gesture_ ? PermissionRequestGestureType::GESTURE 63 user_gesture_ ? PermissionRequestGestureType::GESTURE
19 : PermissionRequestGestureType::NO_GESTURE, 64 : PermissionRequestGestureType::NO_GESTURE,
20 requesting_origin_, profile_); 65 requesting_origin_, profile_);
21 } 66 }
22 } 67 }
23 68
69 std::vector<int> PermissionInfoBarDelegate::content_settings() const {
70 return std::vector<int>{content_settings_type_};
71 }
72
73 bool PermissionInfoBarDelegate::ShouldShowPersistenceToggle() const {
74 return (permission_type_ == content::PermissionType::GEOLOCATION ||
75 permission_type_ == content::PermissionType::AUDIO_CAPTURE ||
76 permission_type_ == content::PermissionType::VIDEO_CAPTURE) &&
77 PermissionUtil::ShouldShowPersistenceToggle();
78 }
lshang 2016/10/24 07:10:55 Since you're here, could you also move the method
dominickn 2016/10/24 08:32:53 Done.
79
24 PermissionInfoBarDelegate::PermissionInfoBarDelegate( 80 PermissionInfoBarDelegate::PermissionInfoBarDelegate(
25 const GURL& requesting_origin, 81 const GURL& requesting_origin,
26 content::PermissionType permission_type, 82 content::PermissionType permission_type,
27 ContentSettingsType content_settings_type, 83 ContentSettingsType content_settings_type,
28 bool user_gesture, 84 bool user_gesture,
29 Profile* profile, 85 Profile* profile,
30 const PermissionSetCallback& callback) 86 const PermissionSetCallback& callback)
31 : requesting_origin_(requesting_origin), 87 : requesting_origin_(requesting_origin),
32 permission_type_(permission_type), 88 permission_type_(permission_type),
33 content_settings_type_(content_settings_type), 89 content_settings_type_(content_settings_type),
34 profile_(profile), 90 profile_(profile),
35 callback_(callback), 91 callback_(callback),
36 action_taken_(false), 92 action_taken_(false),
37 user_gesture_(user_gesture), 93 user_gesture_(user_gesture),
38 persist_(true) {} 94 persist_(true) {}
39 95
40 std::vector<int> PermissionInfoBarDelegate::content_settings() const {
41 return std::vector<int>{content_settings_type_};
42 }
43
44 bool PermissionInfoBarDelegate::ShouldShowPersistenceToggle() const {
45 return (permission_type_ == content::PermissionType::GEOLOCATION ||
46 permission_type_ == content::PermissionType::AUDIO_CAPTURE ||
47 permission_type_ == content::PermissionType::VIDEO_CAPTURE) &&
48 PermissionUtil::ShouldShowPersistenceToggle();
49 }
50
51 base::string16 PermissionInfoBarDelegate::GetMessageText() const { 96 base::string16 PermissionInfoBarDelegate::GetMessageText() const {
52 return l10n_util::GetStringFUTF16( 97 return l10n_util::GetStringFUTF16(
53 GetMessageResourceId(), 98 GetMessageResourceId(),
54 url_formatter::FormatUrlForSecurityDisplay( 99 url_formatter::FormatUrlForSecurityDisplay(
55 requesting_origin_, 100 requesting_origin_,
56 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); 101 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC));
57 } 102 }
58 103
59 infobars::InfoBarDelegate::Type PermissionInfoBarDelegate::GetInfoBarType() 104 infobars::InfoBarDelegate::Type PermissionInfoBarDelegate::GetInfoBarType()
60 const { 105 const {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 143
99 SetPermission(update_content_setting, DENIED); 144 SetPermission(update_content_setting, DENIED);
100 return true; 145 return true;
101 } 146 }
102 147
103 void PermissionInfoBarDelegate::SetPermission(bool update_content_setting, 148 void PermissionInfoBarDelegate::SetPermission(bool update_content_setting,
104 PermissionAction decision) { 149 PermissionAction decision) {
105 action_taken_ = true; 150 action_taken_ = true;
106 callback_.Run(update_content_setting, decision); 151 callback_.Run(update_content_setting, decision);
107 } 152 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_infobar_delegate.h ('k') | chrome/browser/permissions/permission_queue_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698