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

Side by Side Diff: chrome/browser/extensions/extension_install_prompt.cc

Issue 2858013002: PS - Showing permission prompt for activeTab (Closed)
Patch Set: Changed permission prompt message Created 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/extension_install_prompt.h" 5 #include "chrome/browser/extensions/extension_install_prompt.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 rating_count_(0), 154 rating_count_(0),
155 show_user_count_(false), 155 show_user_count_(false),
156 has_webstore_data_(false) { 156 has_webstore_data_(false) {
157 DCHECK_NE(type_, UNSET_PROMPT_TYPE); 157 DCHECK_NE(type_, UNSET_PROMPT_TYPE);
158 DCHECK_NE(type_, NUM_PROMPT_TYPES); 158 DCHECK_NE(type_, NUM_PROMPT_TYPES);
159 } 159 }
160 160
161 ExtensionInstallPrompt::Prompt::~Prompt() { 161 ExtensionInstallPrompt::Prompt::~Prompt() {
162 } 162 }
163 163
164 void ExtensionInstallPrompt::Prompt::SetPermissions( 164 void ExtensionInstallPrompt::Prompt::AddPermissions(
165 const PermissionMessages& permissions, 165 const PermissionMessages& permissions,
166 PermissionsType permissions_type) { 166 PermissionsType permissions_type) {
167 InstallPromptPermissions& install_permissions = 167 InstallPromptPermissions& install_permissions =
168 GetPermissionsForType(permissions_type); 168 GetPermissionsForType(permissions_type);
169 169
170 install_permissions.permissions.clear();
171 install_permissions.details.clear();
172 install_permissions.is_showing_details.clear();
173
174 for (const PermissionMessage& msg : permissions) { 170 for (const PermissionMessage& msg : permissions) {
175 install_permissions.permissions.push_back(msg.message()); 171 install_permissions.permissions.push_back(msg.message());
176 // Add a dash to the front of each permission detail. 172 // Add a dash to the front of each permission detail.
177 base::string16 details; 173 base::string16 details;
178 if (!msg.submessages().empty()) { 174 if (!msg.submessages().empty()) {
179 std::vector<base::string16> detail_lines_with_bullets; 175 std::vector<base::string16> detail_lines_with_bullets;
180 for (const auto& detail_line : msg.submessages()) { 176 for (const auto& detail_line : msg.submessages()) {
181 detail_lines_with_bullets.push_back(base::ASCIIToUTF16("- ") + 177 detail_lines_with_bullets.push_back(base::ASCIIToUTF16("- ") +
182 detail_line); 178 detail_line);
183 } 179 }
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 781
786 if (permissions_to_display && 782 if (permissions_to_display &&
787 (!extension_ || 783 (!extension_ ||
788 !extensions::PermissionsData::ShouldSkipPermissionWarnings( 784 !extensions::PermissionsData::ShouldSkipPermissionWarnings(
789 extension_->id()))) { 785 extension_->id()))) {
790 Manifest::Type type = 786 Manifest::Type type =
791 extension_ ? extension_->GetType() : Manifest::TYPE_UNKNOWN; 787 extension_ ? extension_->GetType() : Manifest::TYPE_UNKNOWN;
792 const extensions::PermissionMessageProvider* message_provider = 788 const extensions::PermissionMessageProvider* message_provider =
793 extensions::PermissionMessageProvider::Get(); 789 extensions::PermissionMessageProvider::Get();
794 790
795 prompt_->SetPermissions(message_provider->GetPermissionMessages( 791 prompt_->AddPermissions(message_provider->GetPermissionMessages(
796 message_provider->GetAllPermissionIDs( 792 message_provider->GetAllPermissionIDs(
797 *permissions_to_display, type)), 793 *permissions_to_display, type)),
798 REGULAR_PERMISSIONS); 794 REGULAR_PERMISSIONS);
799 795
800 const PermissionSet* withheld = 796 const PermissionSet* withheld =
801 extension_ ? &extension_->permissions_data()->withheld_permissions() 797 extension_ ? &extension_->permissions_data()->withheld_permissions()
802 : nullptr; 798 : nullptr;
803 if (withheld && !withheld->IsEmpty()) { 799 if (withheld && !withheld->IsEmpty()) {
804 prompt_->SetPermissions( 800 prompt_->AddPermissions(
805 message_provider->GetPermissionMessages( 801 message_provider->GetPermissionMessages(
806 message_provider->GetAllPermissionIDs(*withheld, type)), 802 message_provider->GetAllPermissionIDs(*withheld, type)),
807 WITHHELD_PERMISSIONS); 803 WITHHELD_PERMISSIONS);
808 } 804 }
809 } 805 }
810 806
811 prompt_->set_extension(extension_); 807 prompt_->set_extension(extension_);
812 prompt_->set_icon(gfx::Image::CreateFrom1xBitmap(icon_)); 808 prompt_->set_icon(gfx::Image::CreateFrom1xBitmap(icon_));
813 809
814 if (show_params_->WasParentDestroyed()) { 810 if (show_params_->WasParentDestroyed()) {
815 base::ResetAndReturn(&done_callback_).Run(Result::ABORTED); 811 base::ResetAndReturn(&done_callback_).Run(Result::ABORTED);
816 return; 812 return;
817 } 813 }
818 814
819 g_last_prompt_type_for_tests = prompt_->type(); 815 g_last_prompt_type_for_tests = prompt_->type();
820 did_call_show_dialog_ = true; 816 did_call_show_dialog_ = true;
821 817
822 if (AutoConfirmPrompt(&done_callback_)) 818 if (AutoConfirmPrompt(&done_callback_))
823 return; 819 return;
824 820
825 if (show_dialog_callback_.is_null()) 821 if (show_dialog_callback_.is_null())
826 show_dialog_callback_ = GetDefaultShowDialogCallback(); 822 show_dialog_callback_ = GetDefaultShowDialogCallback();
827 base::ResetAndReturn(&show_dialog_callback_) 823 base::ResetAndReturn(&show_dialog_callback_)
828 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_), 824 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_),
829 std::move(prompt_)); 825 std::move(prompt_));
830 } 826 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698