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

Side by Side Diff: chrome/common/extensions/permissions/chrome_permission_message_provider.cc

Issue 323633003: Change tabs + sessions permission warning (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/extensions/permissions/chrome_permission_message_provide r.h" 5 #include "chrome/common/extensions/permissions/chrome_permission_message_provide r.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "extensions/common/extensions_client.h" 9 #include "extensions/common/extensions_client.h"
10 #include "extensions/common/permissions/permission_message.h" 10 #include "extensions/common/permissions/permission_message.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 Manifest::Type extension_type) const { 98 Manifest::Type extension_type) const {
99 std::vector<base::string16> message_strings; 99 std::vector<base::string16> message_strings;
100 PermissionMessages messages = 100 PermissionMessages messages =
101 GetPermissionMessages(permissions, extension_type); 101 GetPermissionMessages(permissions, extension_type);
102 102
103 bool audio_capture = false; 103 bool audio_capture = false;
104 bool video_capture = false; 104 bool video_capture = false;
105 bool media_galleries_read = false; 105 bool media_galleries_read = false;
106 bool media_galleries_copy_to = false; 106 bool media_galleries_copy_to = false;
107 bool media_galleries_delete = false; 107 bool media_galleries_delete = false;
108 bool tabs = false;
108 for (PermissionMessages::const_iterator i = messages.begin(); 109 for (PermissionMessages::const_iterator i = messages.begin();
109 i != messages.end(); ++i) { 110 i != messages.end(); ++i) {
110 switch (i->id()) { 111 switch (i->id()) {
111 case PermissionMessage::kAudioCapture: 112 case PermissionMessage::kAudioCapture:
112 audio_capture = true; 113 audio_capture = true;
113 break; 114 break;
114 case PermissionMessage::kVideoCapture: 115 case PermissionMessage::kVideoCapture:
115 video_capture = true; 116 video_capture = true;
116 break; 117 break;
117 case PermissionMessage::kMediaGalleriesAllGalleriesRead: 118 case PermissionMessage::kMediaGalleriesAllGalleriesRead:
118 media_galleries_read = true; 119 media_galleries_read = true;
119 break; 120 break;
120 case PermissionMessage::kMediaGalleriesAllGalleriesCopyTo: 121 case PermissionMessage::kMediaGalleriesAllGalleriesCopyTo:
121 media_galleries_copy_to = true; 122 media_galleries_copy_to = true;
122 break; 123 break;
123 case PermissionMessage::kMediaGalleriesAllGalleriesDelete: 124 case PermissionMessage::kMediaGalleriesAllGalleriesDelete:
124 media_galleries_delete = true; 125 media_galleries_delete = true;
125 break; 126 break;
127 case PermissionMessage::kTabs:
128 tabs = true;
129 break;
126 default: 130 default:
127 break; 131 break;
128 } 132 }
129 } 133 }
130 134
131 for (PermissionMessages::const_iterator i = messages.begin(); 135 for (PermissionMessages::const_iterator i = messages.begin();
132 i != messages.end(); ++i) { 136 i != messages.end(); ++i) {
133 int id = i->id(); 137 int id = i->id();
134 if (audio_capture && video_capture) { 138 if (audio_capture && video_capture) {
135 if (id == PermissionMessage::kAudioCapture) { 139 if (id == PermissionMessage::kAudioCapture) {
(...skipping 12 matching lines...) Expand all
148 IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_READ_WRITE : 152 IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_READ_WRITE :
149 IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_READ_DELETE; 153 IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_READ_DELETE;
150 message_strings.push_back(l10n_util::GetStringUTF16(m_id)); 154 message_strings.push_back(l10n_util::GetStringUTF16(m_id));
151 continue; 155 continue;
152 } else if (id == PermissionMessage::kMediaGalleriesAllGalleriesCopyTo || 156 } else if (id == PermissionMessage::kMediaGalleriesAllGalleriesCopyTo ||
153 id == PermissionMessage::kMediaGalleriesAllGalleriesDelete) { 157 id == PermissionMessage::kMediaGalleriesAllGalleriesDelete) {
154 // The combined message will be pushed above. 158 // The combined message will be pushed above.
155 continue; 159 continue;
156 } 160 }
157 } 161 }
162 if (tabs && permissions->HasAPIPermission(APIPermission::kSessions) &&
163 id == PermissionMessage::kTabs) {
164 message_strings.push_back(l10n_util::GetStringUTF16(
165 IDS_EXTENSION_PROMPT_WARNING_TABS_AND_SESSIONS));
166 continue;
167 }
158 168
159 message_strings.push_back(i->message()); 169 message_strings.push_back(i->message());
160 } 170 }
161 171
162 return message_strings; 172 return message_strings;
163 } 173 }
164 174
165 std::vector<base::string16> 175 std::vector<base::string16>
166 ChromePermissionMessageProvider::GetWarningMessagesDetails( 176 ChromePermissionMessageProvider::GetWarningMessagesDetails(
167 const PermissionSet* permissions, 177 const PermissionSet* permissions,
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 std::set<std::string> old_hosts_set( 359 std::set<std::string> old_hosts_set(
350 permission_message_util::GetDistinctHosts(old_list, false, false)); 360 permission_message_util::GetDistinctHosts(old_list, false, false));
351 std::set<std::string> new_hosts_only = 361 std::set<std::string> new_hosts_only =
352 base::STLSetDifference<std::set<std::string> >(new_hosts_set, 362 base::STLSetDifference<std::set<std::string> >(new_hosts_set,
353 old_hosts_set); 363 old_hosts_set);
354 364
355 return !new_hosts_only.empty(); 365 return !new_hosts_only.empty();
356 } 366 }
357 367
358 } // namespace extensions 368 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698