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

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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 PermissionMessage::kBrowsingHistory, 91 PermissionMessage::kBrowsingHistory,
92 PermissionMessage::kTabs); 92 PermissionMessage::kTabs);
93 return messages; 93 return messages;
94 } 94 }
95 95
96 std::vector<base::string16> ChromePermissionMessageProvider::GetWarningMessages( 96 std::vector<base::string16> ChromePermissionMessageProvider::GetWarningMessages(
97 const PermissionSet* permissions, 97 const PermissionSet* permissions,
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);
not at google - send to devlin 2014/06/09 16:57:31 honestly all this code and its looping is a bit we
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;
109 bool history = false;
108 for (PermissionMessages::const_iterator i = messages.begin(); 110 for (PermissionMessages::const_iterator i = messages.begin();
109 i != messages.end(); ++i) { 111 i != messages.end(); ++i) {
110 switch (i->id()) { 112 switch (i->id()) {
111 case PermissionMessage::kAudioCapture: 113 case PermissionMessage::kAudioCapture:
112 audio_capture = true; 114 audio_capture = true;
113 break; 115 break;
114 case PermissionMessage::kVideoCapture: 116 case PermissionMessage::kVideoCapture:
115 video_capture = true; 117 video_capture = true;
116 break; 118 break;
117 case PermissionMessage::kMediaGalleriesAllGalleriesRead: 119 case PermissionMessage::kMediaGalleriesAllGalleriesRead:
118 media_galleries_read = true; 120 media_galleries_read = true;
119 break; 121 break;
120 case PermissionMessage::kMediaGalleriesAllGalleriesCopyTo: 122 case PermissionMessage::kMediaGalleriesAllGalleriesCopyTo:
121 media_galleries_copy_to = true; 123 media_galleries_copy_to = true;
122 break; 124 break;
123 case PermissionMessage::kMediaGalleriesAllGalleriesDelete: 125 case PermissionMessage::kMediaGalleriesAllGalleriesDelete:
124 media_galleries_delete = true; 126 media_galleries_delete = true;
125 break; 127 break;
128 case PermissionMessage::kTabs:
129 tabs = true;
130 break;
131 case PermissionMessage::kBrowsingHistory:
132 history = true;
133 break;
126 default: 134 default:
127 break; 135 break;
128 } 136 }
129 } 137 }
130 138
131 for (PermissionMessages::const_iterator i = messages.begin(); 139 for (PermissionMessages::const_iterator i = messages.begin();
132 i != messages.end(); ++i) { 140 i != messages.end(); ++i) {
133 int id = i->id(); 141 int id = i->id();
134 if (audio_capture && video_capture) { 142 if (audio_capture && video_capture) {
135 if (id == PermissionMessage::kAudioCapture) { 143 if (id == PermissionMessage::kAudioCapture) {
(...skipping 12 matching lines...) Expand all
148 IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_READ_WRITE : 156 IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_READ_WRITE :
149 IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_READ_DELETE; 157 IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_READ_DELETE;
150 message_strings.push_back(l10n_util::GetStringUTF16(m_id)); 158 message_strings.push_back(l10n_util::GetStringUTF16(m_id));
151 continue; 159 continue;
152 } else if (id == PermissionMessage::kMediaGalleriesAllGalleriesCopyTo || 160 } else if (id == PermissionMessage::kMediaGalleriesAllGalleriesCopyTo ||
153 id == PermissionMessage::kMediaGalleriesAllGalleriesDelete) { 161 id == PermissionMessage::kMediaGalleriesAllGalleriesDelete) {
154 // The combined message will be pushed above. 162 // The combined message will be pushed above.
155 continue; 163 continue;
156 } 164 }
157 } 165 }
166 if (tabs && permissions->HasAPIPermission(APIPermission::kSessions) &&
167 id == PermissionMessage::kTabs) {
not at google - send to devlin 2014/06/09 16:57:31 am I missing something or is this check and the id
wjywbs 2014/06/09 20:06:28 You are right. A lot of lines are not necessary. T
168 message_strings.push_back(l10n_util::GetStringUTF16(
169 IDS_EXTENSION_PROMPT_WARNING_TABS_AND_SESSIONS));
170 continue;
171 }
172 if (history && permissions->HasAPIPermission(APIPermission::kSessions) &&
173 id == PermissionMessage::kBrowsingHistory) {
174 message_strings.push_back(l10n_util::GetStringUTF16(
175 IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY_AND_SESSIONS));
176 continue;
177 }
158 178
159 message_strings.push_back(i->message()); 179 message_strings.push_back(i->message());
160 } 180 }
161 181
162 return message_strings; 182 return message_strings;
163 } 183 }
164 184
165 std::vector<base::string16> 185 std::vector<base::string16>
166 ChromePermissionMessageProvider::GetWarningMessagesDetails( 186 ChromePermissionMessageProvider::GetWarningMessagesDetails(
167 const PermissionSet* permissions, 187 const PermissionSet* permissions,
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 std::set<std::string> old_hosts_set( 369 std::set<std::string> old_hosts_set(
350 permission_message_util::GetDistinctHosts(old_list, false, false)); 370 permission_message_util::GetDistinctHosts(old_list, false, false));
351 std::set<std::string> new_hosts_only = 371 std::set<std::string> new_hosts_only =
352 base::STLSetDifference<std::set<std::string> >(new_hosts_set, 372 base::STLSetDifference<std::set<std::string> >(new_hosts_set,
353 old_hosts_set); 373 old_hosts_set);
354 374
355 return !new_hosts_only.empty(); 375 return !new_hosts_only.empty();
356 } 376 }
357 377
358 } // namespace extensions 378 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/common/extensions/permissions/permission_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698