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

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

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