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

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

Issue 18854021: Making the extension permissions dialog scrollable, when needed (adding expandable sections for thi… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Polishing Created 7 years, 5 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 (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 <map> 7 #include <map>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 extension_(NULL), 191 extension_(NULL),
192 bundle_(NULL), 192 bundle_(NULL),
193 average_rating_(0.0), 193 average_rating_(0.0),
194 rating_count_(0) { 194 rating_count_(0) {
195 } 195 }
196 196
197 ExtensionInstallPrompt::Prompt::~Prompt() { 197 ExtensionInstallPrompt::Prompt::~Prompt() {
198 } 198 }
199 199
200 void ExtensionInstallPrompt::Prompt::SetPermissions( 200 void ExtensionInstallPrompt::Prompt::SetPermissions(
201 const std::vector<string16>& permissions) { 201 const std::vector<string16>& permissions, bool verbose) {
202 permissions_ = permissions; 202 if (verbose)
203 permissions_verbose_ = permissions;
204 else
205 permissions_ = permissions;
203 } 206 }
204 207
205 void ExtensionInstallPrompt::Prompt::SetOAuthIssueAdvice( 208 void ExtensionInstallPrompt::Prompt::SetOAuthIssueAdvice(
206 const IssueAdviceInfo& issue_advice) { 209 const IssueAdviceInfo& issue_advice) {
207 oauth_issue_advice_ = issue_advice; 210 oauth_issue_advice_ = issue_advice;
208 } 211 }
209 212
210 void ExtensionInstallPrompt::Prompt::SetUserNameFromProfile(Profile* profile) { 213 void ExtensionInstallPrompt::Prompt::SetUserNameFromProfile(Profile* profile) {
211 // |profile| can be NULL in unit tests. 214 // |profile| can be NULL in unit tests.
212 if (profile) { 215 if (profile) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 312
310 string16 ExtensionInstallPrompt::Prompt::GetPermissionsHeading() const { 313 string16 ExtensionInstallPrompt::Prompt::GetPermissionsHeading() const {
311 return l10n_util::GetStringUTF16(kPermissionsHeaderIds[type_]); 314 return l10n_util::GetStringUTF16(kPermissionsHeaderIds[type_]);
312 } 315 }
313 316
314 string16 ExtensionInstallPrompt::Prompt::GetOAuthHeading() const { 317 string16 ExtensionInstallPrompt::Prompt::GetOAuthHeading() const {
315 return l10n_util::GetStringFUTF16(kOAuthHeaderIds[type_], oauth_user_name_); 318 return l10n_util::GetStringFUTF16(kOAuthHeaderIds[type_], oauth_user_name_);
316 } 319 }
317 320
318 string16 ExtensionInstallPrompt::Prompt::GetRetainedFilesHeading() const { 321 string16 ExtensionInstallPrompt::Prompt::GetRetainedFilesHeading() const {
322 // TODO(finnur): Remove this once all platforms are using
323 // GetRetainedFilesHeadingWithCount().
319 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_RETAINED_FILES); 324 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_RETAINED_FILES);
320 } 325 }
321 326
327 string16
328 ExtensionInstallPrompt::Prompt::GetRetainedFilesHeadingWithCount() const {
329 return l10n_util::GetStringFUTF16(
330 IDS_EXTENSION_PROMPT_RETAINED_FILES_WITH_COUNT,
331 base::IntToString16(GetRetainedFileCount()));
332 }
333
322 bool ExtensionInstallPrompt::Prompt::ShouldShowPermissions() const { 334 bool ExtensionInstallPrompt::Prompt::ShouldShowPermissions() const {
323 return GetPermissionCount() > 0 || type_ == POST_INSTALL_PERMISSIONS_PROMPT; 335 return GetPermissionCount(false) > 0 ||
336 type_ == POST_INSTALL_PERMISSIONS_PROMPT;
324 } 337 }
325 338
326 void ExtensionInstallPrompt::Prompt::AppendRatingStars( 339 void ExtensionInstallPrompt::Prompt::AppendRatingStars(
327 StarAppender appender, void* data) const { 340 StarAppender appender, void* data) const {
328 CHECK(appender); 341 CHECK(appender);
329 CHECK_EQ(INLINE_INSTALL_PROMPT, type_); 342 CHECK_EQ(INLINE_INSTALL_PROMPT, type_);
330 int rating_integer = floor(average_rating_); 343 int rating_integer = floor(average_rating_);
331 double rating_fractional = average_rating_ - rating_integer; 344 double rating_fractional = average_rating_ - rating_integer;
332 345
333 if (rating_fractional > 0.66) { 346 if (rating_fractional > 0.66) {
(...skipping 25 matching lines...) Expand all
359 UTF8ToUTF16(base::IntToString(rating_count_))); 372 UTF8ToUTF16(base::IntToString(rating_count_)));
360 } 373 }
361 374
362 string16 ExtensionInstallPrompt::Prompt::GetUserCount() const { 375 string16 ExtensionInstallPrompt::Prompt::GetUserCount() const {
363 CHECK_EQ(INLINE_INSTALL_PROMPT, type_); 376 CHECK_EQ(INLINE_INSTALL_PROMPT, type_);
364 return l10n_util::GetStringFUTF16( 377 return l10n_util::GetStringFUTF16(
365 IDS_EXTENSION_USER_COUNT, 378 IDS_EXTENSION_USER_COUNT,
366 UTF8ToUTF16(localized_user_count_)); 379 UTF8ToUTF16(localized_user_count_));
367 } 380 }
368 381
369 size_t ExtensionInstallPrompt::Prompt::GetPermissionCount() const { 382 size_t ExtensionInstallPrompt::Prompt::GetPermissionCount(bool verbose) const {
370 return permissions_.size(); 383 if (verbose)
384 return permissions_verbose_.size();
385 else
386 return permissions_.size();
371 } 387 }
372 388
373 string16 ExtensionInstallPrompt::Prompt::GetPermission(size_t index) const { 389 string16 ExtensionInstallPrompt::Prompt::GetPermission(
374 CHECK_LT(index, permissions_.size()); 390 size_t index, bool verbose) const {
375 return permissions_[index]; 391 if (verbose) {
392 CHECK_LT(index, permissions_verbose_.size());
393 return permissions_verbose_[index];
394 } else {
395 CHECK_LT(index, permissions_.size());
396 return permissions_[index];
397 }
376 } 398 }
377 399
378 size_t ExtensionInstallPrompt::Prompt::GetOAuthIssueCount() const { 400 size_t ExtensionInstallPrompt::Prompt::GetOAuthIssueCount() const {
379 return oauth_issue_advice_.size(); 401 return oauth_issue_advice_.size();
380 } 402 }
381 403
382 const IssueAdviceInfoEntry& ExtensionInstallPrompt::Prompt::GetOAuthIssue( 404 const IssueAdviceInfoEntry& ExtensionInstallPrompt::Prompt::GetOAuthIssue(
383 size_t index) const { 405 size_t index) const {
384 CHECK_LT(index, oauth_issue_advice_.size()); 406 CHECK_LT(index, oauth_issue_advice_.size());
385 return oauth_issue_advice_[index]; 407 return oauth_issue_advice_[index];
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 ShowConfirmation(); 734 ShowConfirmation();
713 } 735 }
714 736
715 void ExtensionInstallPrompt::ShowConfirmation() { 737 void ExtensionInstallPrompt::ShowConfirmation() {
716 if (permissions_.get() && 738 if (permissions_.get() &&
717 (!extension_ || 739 (!extension_ ||
718 !extensions::PermissionsData::ShouldSkipPermissionWarnings( 740 !extensions::PermissionsData::ShouldSkipPermissionWarnings(
719 extension_))) { 741 extension_))) {
720 Manifest::Type extension_type = extension_ ? 742 Manifest::Type extension_type = extension_ ?
721 extension_->GetType() : Manifest::TYPE_UNKNOWN; 743 extension_->GetType() : Manifest::TYPE_UNKNOWN;
722 prompt_.SetPermissions(permissions_->GetWarningMessages(extension_type)); 744 prompt_.SetPermissions(
745 permissions_->GetWarningMessages(extension_type, true), true);
746 prompt_.SetPermissions(
747 permissions_->GetWarningMessages(extension_type, false), false);
723 } 748 }
724 749
725 switch (prompt_.type()) { 750 switch (prompt_.type()) {
726 case PERMISSIONS_PROMPT: 751 case PERMISSIONS_PROMPT:
727 case RE_ENABLE_PROMPT: 752 case RE_ENABLE_PROMPT:
728 case INLINE_INSTALL_PROMPT: 753 case INLINE_INSTALL_PROMPT:
729 case EXTERNAL_INSTALL_PROMPT: 754 case EXTERNAL_INSTALL_PROMPT:
730 case INSTALL_PROMPT: 755 case INSTALL_PROMPT:
731 case POST_INSTALL_PERMISSIONS_PROMPT: { 756 case POST_INSTALL_PERMISSIONS_PROMPT: {
732 prompt_.set_extension(extension_); 757 prompt_.set_extension(extension_);
(...skipping 10 matching lines...) Expand all
743 } 768 }
744 769
745 if (AutoConfirmPrompt(delegate_)) 770 if (AutoConfirmPrompt(delegate_))
746 return; 771 return;
747 772
748 if (show_dialog_callback_.is_null()) 773 if (show_dialog_callback_.is_null())
749 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); 774 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_);
750 else 775 else
751 show_dialog_callback_.Run(show_params_, delegate_, prompt_); 776 show_dialog_callback_.Run(show_params_, delegate_, prompt_);
752 } 777 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698