| OLD | NEW |
| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 76 } // namespace | 76 } // namespace |
| 77 | 77 |
| 78 ChromePermissionMessageProvider::ChromePermissionMessageProvider() { | 78 ChromePermissionMessageProvider::ChromePermissionMessageProvider() { |
| 79 } | 79 } |
| 80 | 80 |
| 81 ChromePermissionMessageProvider::~ChromePermissionMessageProvider() { | 81 ChromePermissionMessageProvider::~ChromePermissionMessageProvider() { |
| 82 } | 82 } |
| 83 | 83 |
| 84 // static | |
| 85 PermissionMessages ChromePermissionMessageProvider::GetPermissionMessages( | 84 PermissionMessages ChromePermissionMessageProvider::GetPermissionMessages( |
| 86 const PermissionSet* permissions, | 85 const PermissionSet* permissions, |
| 87 Manifest::Type extension_type) const { | 86 Manifest::Type extension_type) const { |
| 88 PermissionMessages messages; | 87 PermissionMessages messages; |
| 89 | 88 |
| 90 if (permissions->HasEffectiveFullAccess()) { | 89 if (permissions->HasEffectiveFullAccess()) { |
| 91 messages.push_back(PermissionMessage( | 90 messages.push_back(PermissionMessage( |
| 92 PermissionMessage::kFullAccess, | 91 PermissionMessage::kFullAccess, |
| 93 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); | 92 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); |
| 94 return messages; | 93 return messages; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 110 FindMessageByID(messages, PermissionMessage::kOverrideBookmarksUI); | 109 FindMessageByID(messages, PermissionMessage::kOverrideBookmarksUI); |
| 111 if (override_bookmarks_ui != messages.end() && | 110 if (override_bookmarks_ui != messages.end() && |
| 112 FindMessageByID(messages, PermissionMessage::kBookmarks) != | 111 FindMessageByID(messages, PermissionMessage::kBookmarks) != |
| 113 messages.end()) { | 112 messages.end()) { |
| 114 messages.erase(override_bookmarks_ui); | 113 messages.erase(override_bookmarks_ui); |
| 115 } | 114 } |
| 116 | 115 |
| 117 return messages; | 116 return messages; |
| 118 } | 117 } |
| 119 | 118 |
| 120 // static | |
| 121 std::vector<base::string16> ChromePermissionMessageProvider::GetWarningMessages( | 119 std::vector<base::string16> ChromePermissionMessageProvider::GetWarningMessages( |
| 122 const PermissionSet* permissions, | 120 const PermissionSet* permissions, |
| 123 Manifest::Type extension_type) const { | 121 Manifest::Type extension_type) const { |
| 124 std::vector<base::string16> message_strings; | 122 std::vector<base::string16> message_strings; |
| 125 PermissionMessages messages = | 123 PermissionMessages messages = |
| 126 GetPermissionMessages(permissions, extension_type); | 124 GetPermissionMessages(permissions, extension_type); |
| 127 | 125 |
| 128 bool audio_capture = false; | 126 bool audio_capture = false; |
| 129 bool video_capture = false; | 127 bool video_capture = false; |
| 130 bool media_galleries_read = false; | 128 bool media_galleries_read = false; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 continue; | 178 continue; |
| 181 } | 179 } |
| 182 } | 180 } |
| 183 | 181 |
| 184 message_strings.push_back(i->message()); | 182 message_strings.push_back(i->message()); |
| 185 } | 183 } |
| 186 | 184 |
| 187 return message_strings; | 185 return message_strings; |
| 188 } | 186 } |
| 189 | 187 |
| 190 // static | |
| 191 std::vector<base::string16> | 188 std::vector<base::string16> |
| 192 ChromePermissionMessageProvider::GetWarningMessagesDetails( | 189 ChromePermissionMessageProvider::GetWarningMessagesDetails( |
| 193 const PermissionSet* permissions, | 190 const PermissionSet* permissions, |
| 194 Manifest::Type extension_type) const { | 191 Manifest::Type extension_type) const { |
| 195 std::vector<base::string16> message_strings; | 192 std::vector<base::string16> message_strings; |
| 196 PermissionMessages messages = | 193 PermissionMessages messages = |
| 197 GetPermissionMessages(permissions, extension_type); | 194 GetPermissionMessages(permissions, extension_type); |
| 198 | 195 |
| 199 for (PermissionMessages::const_iterator i = messages.begin(); | 196 for (PermissionMessages::const_iterator i = messages.begin(); |
| 200 i != messages.end(); ++i) | 197 i != messages.end(); ++i) |
| 201 message_strings.push_back(i->details()); | 198 message_strings.push_back(i->details()); |
| 202 | 199 |
| 203 return message_strings; | 200 return message_strings; |
| 204 } | 201 } |
| 205 | 202 |
| 206 // static | |
| 207 bool ChromePermissionMessageProvider::IsPrivilegeIncrease( | 203 bool ChromePermissionMessageProvider::IsPrivilegeIncrease( |
| 208 const PermissionSet* old_permissions, | 204 const PermissionSet* old_permissions, |
| 209 const PermissionSet* new_permissions, | 205 const PermissionSet* new_permissions, |
| 210 Manifest::Type extension_type) const { | 206 Manifest::Type extension_type) const { |
| 211 // Things can't get worse than native code access. | 207 // Things can't get worse than native code access. |
| 212 if (old_permissions->HasEffectiveFullAccess()) | 208 if (old_permissions->HasEffectiveFullAccess()) |
| 213 return false; | 209 return false; |
| 214 | 210 |
| 215 // Otherwise, it's a privilege increase if the new one has full access. | 211 // Otherwise, it's a privilege increase if the new one has full access. |
| 216 if (new_permissions->HasEffectiveFullAccess()) | 212 if (new_permissions->HasEffectiveFullAccess()) |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 std::set<std::string> old_hosts_set( | 389 std::set<std::string> old_hosts_set( |
| 394 permission_message_util::GetDistinctHosts(old_list, false, false)); | 390 permission_message_util::GetDistinctHosts(old_list, false, false)); |
| 395 std::set<std::string> new_hosts_only = | 391 std::set<std::string> new_hosts_only = |
| 396 base::STLSetDifference<std::set<std::string> >(new_hosts_set, | 392 base::STLSetDifference<std::set<std::string> >(new_hosts_set, |
| 397 old_hosts_set); | 393 old_hosts_set); |
| 398 | 394 |
| 399 return !new_hosts_only.empty(); | 395 return !new_hosts_only.empty(); |
| 400 } | 396 } |
| 401 | 397 |
| 402 } // namespace extensions | 398 } // namespace extensions |
| OLD | NEW |