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

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

Issue 12094034: Add a link (to view Permissions) to the Extension details on chrome://extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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/file_util.h" 10 #include "base/file_util.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 namespace { 48 namespace {
49 49
50 static const int kTitleIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { 50 static const int kTitleIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
51 0, // The regular install prompt depends on what's being installed. 51 0, // The regular install prompt depends on what's being installed.
52 IDS_EXTENSION_INLINE_INSTALL_PROMPT_TITLE, 52 IDS_EXTENSION_INLINE_INSTALL_PROMPT_TITLE,
53 IDS_EXTENSION_INSTALL_PROMPT_TITLE, 53 IDS_EXTENSION_INSTALL_PROMPT_TITLE,
54 IDS_EXTENSION_RE_ENABLE_PROMPT_TITLE, 54 IDS_EXTENSION_RE_ENABLE_PROMPT_TITLE,
55 IDS_EXTENSION_PERMISSIONS_PROMPT_TITLE, 55 IDS_EXTENSION_PERMISSIONS_PROMPT_TITLE,
56 IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_TITLE, 56 IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_TITLE,
57 IDS_EXTENSION_POST_INSTALL_PERMISSIONS_PROMPT_TITLE,
57 }; 58 };
58 static const int kHeadingIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { 59 static const int kHeadingIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
59 IDS_EXTENSION_INSTALL_PROMPT_HEADING, 60 IDS_EXTENSION_INSTALL_PROMPT_HEADING,
60 0, // Inline installs use the extension name. 61 0, // Inline installs use the extension name.
61 0, // Heading for bundle installs depends on the bundle contents. 62 0, // Heading for bundle installs depends on the bundle contents.
62 IDS_EXTENSION_RE_ENABLE_PROMPT_HEADING, 63 IDS_EXTENSION_RE_ENABLE_PROMPT_HEADING,
63 IDS_EXTENSION_PERMISSIONS_PROMPT_HEADING, 64 IDS_EXTENSION_PERMISSIONS_PROMPT_HEADING,
64 0, // External installs use different strings for extensions/apps. 65 0, // External installs use different strings for extensions/apps.
66 IDS_EXTENSION_POST_INSTALL_PERMISSIONS_PROMPT_HEADING,
67 };
68 static const int kButtons[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
69 ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL,
70 ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL,
71 ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL,
72 ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL,
73 ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL,
74 ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL,
75 ui::DIALOG_BUTTON_CANCEL,
65 }; 76 };
66 static const int kAcceptButtonIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { 77 static const int kAcceptButtonIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
67 IDS_EXTENSION_PROMPT_INSTALL_BUTTON, 78 IDS_EXTENSION_PROMPT_INSTALL_BUTTON,
68 IDS_EXTENSION_PROMPT_INSTALL_BUTTON, 79 IDS_EXTENSION_PROMPT_INSTALL_BUTTON,
69 IDS_EXTENSION_PROMPT_INSTALL_BUTTON, 80 IDS_EXTENSION_PROMPT_INSTALL_BUTTON,
70 IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON, 81 IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON,
71 IDS_EXTENSION_PROMPT_PERMISSIONS_BUTTON, 82 IDS_EXTENSION_PROMPT_PERMISSIONS_BUTTON,
72 0, // External installs use different strings for extensions/apps. 83 0, // External installs use different strings for extensions/apps.
84 0,
73 }; 85 };
74 static const int kAbortButtonIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { 86 static const int kAbortButtonIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
75 0, // These all use the platform's default cancel label. 87 0, // These all use the platform's default cancel label.
76 0, 88 0,
77 0, 89 0,
78 0, 90 0,
79 IDS_EXTENSION_PROMPT_PERMISSIONS_ABORT_BUTTON, 91 IDS_EXTENSION_PROMPT_PERMISSIONS_ABORT_BUTTON,
80 IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ABORT_BUTTON, 92 IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ABORT_BUTTON,
93 IDS_CLOSE,
81 }; 94 };
82 static const int kPermissionsHeaderIds[ 95 static const int kPermissionsHeaderIds[
83 ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { 96 ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
84 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, 97 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
85 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, 98 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
86 IDS_EXTENSION_PROMPT_THESE_WILL_HAVE_ACCESS_TO, 99 IDS_EXTENSION_PROMPT_THESE_WILL_HAVE_ACCESS_TO,
87 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO, 100 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO,
88 IDS_EXTENSION_PROMPT_WANTS_ACCESS_TO, 101 IDS_EXTENSION_PROMPT_WANTS_ACCESS_TO,
89 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, 102 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
103 IDS_EXTENSION_PROMPT_CAN_ACCESS,
90 }; 104 };
91 static const int kOAuthHeaderIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { 105 static const int kOAuthHeaderIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
92 IDS_EXTENSION_PROMPT_OAUTH_HEADER, 106 IDS_EXTENSION_PROMPT_OAUTH_HEADER,
93 0, // Inline installs don't show OAuth permissions. 107 0, // Inline installs don't show OAuth permissions.
94 0, // Bundle installs don't show OAuth permissions. 108 0, // Bundle installs don't show OAuth permissions.
95 IDS_EXTENSION_PROMPT_OAUTH_REENABLE_HEADER, 109 IDS_EXTENSION_PROMPT_OAUTH_REENABLE_HEADER,
96 IDS_EXTENSION_PROMPT_OAUTH_PERMISSIONS_HEADER, 110 IDS_EXTENSION_PROMPT_OAUTH_PERMISSIONS_HEADER,
97 // TODO(mpcomplete): Do we need this for external install UI? If we do, 111 // TODO(mpcomplete): Do we need this for external install UI? If we do,
98 // we need to update FetchOAuthIssueAdviceIfNeeded. 112 // we need to update FetchOAuthIssueAdviceIfNeeded.
99 0, 113 0,
114 0,
100 }; 115 };
101 116
102 // Size of extension icon in top left of dialog. 117 // Size of extension icon in top left of dialog.
103 const int kIconSize = 69; 118 const int kIconSize = 69;
104 119
105 // Returns pixel size under maximal scale factor for the icon whose device 120 // Returns pixel size under maximal scale factor for the icon whose device
106 // independent size is |size_in_dip| 121 // independent size is |size_in_dip|
107 int GetSizeForMaxScaleFactor(int size_in_dip) { 122 int GetSizeForMaxScaleFactor(int size_in_dip) {
108 float max_scale_factor_scale = 123 float max_scale_factor_scale =
109 ui::GetScaleFactorScale(ui::GetMaxScaleFactor()); 124 ui::GetScaleFactorScale(ui::GetMaxScaleFactor());
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 resource_id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_HEADING_THEME; 252 resource_id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_HEADING_THEME;
238 else 253 else
239 resource_id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_HEADING_EXTENSION; 254 resource_id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_HEADING_EXTENSION;
240 return l10n_util::GetStringUTF16(resource_id); 255 return l10n_util::GetStringUTF16(resource_id);
241 } else { 256 } else {
242 return l10n_util::GetStringFUTF16( 257 return l10n_util::GetStringFUTF16(
243 kHeadingIds[type_], UTF8ToUTF16(extension_->name())); 258 kHeadingIds[type_], UTF8ToUTF16(extension_->name()));
244 } 259 }
245 } 260 }
246 261
262 int ExtensionInstallPrompt::Prompt::GetDialogButtons() const {
263 return kButtons[type_];
264 }
265
247 string16 ExtensionInstallPrompt::Prompt::GetAcceptButtonLabel() const { 266 string16 ExtensionInstallPrompt::Prompt::GetAcceptButtonLabel() const {
248 if (type_ == EXTERNAL_INSTALL_PROMPT) { 267 if (type_ == EXTERNAL_INSTALL_PROMPT) {
249 int id = -1; 268 int id = -1;
250 if (extension_->is_app()) 269 if (extension_->is_app())
251 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_APP; 270 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_APP;
252 else if (extension_->is_theme()) 271 else if (extension_->is_theme())
253 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_THEME; 272 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_THEME;
254 else 273 else
255 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_EXTENSION; 274 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_EXTENSION;
256 return l10n_util::GetStringUTF16(id); 275 return l10n_util::GetStringUTF16(id);
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 extension_ = extension; 541 extension_ = extension;
523 delegate_ = delegate; 542 delegate_ = delegate;
524 prompt_.set_type(PERMISSIONS_PROMPT); 543 prompt_.set_type(PERMISSIONS_PROMPT);
525 544
526 record_oauth2_grant_ = true; 545 record_oauth2_grant_ = true;
527 prompt_.SetOAuthIssueAdvice(issue_advice); 546 prompt_.SetOAuthIssueAdvice(issue_advice);
528 547
529 LoadImageIfNeeded(); 548 LoadImageIfNeeded();
530 } 549 }
531 550
551 void ExtensionInstallPrompt::ReviewPermissions(Delegate* delegate,
552 const Extension* extension) {
553 DCHECK(ui_loop_ == MessageLoop::current());
554 extension_ = extension;
555 permissions_ = extension->GetActivePermissions();
556 delegate_ = delegate;
557 prompt_.set_type(POST_INSTALL_PERMISSIONS_PROMPT);
558
559 LoadImageIfNeeded();
560 }
561
532 void ExtensionInstallPrompt::OnInstallSuccess(const Extension* extension, 562 void ExtensionInstallPrompt::OnInstallSuccess(const Extension* extension,
533 SkBitmap* icon) { 563 SkBitmap* icon) {
534 extension_ = extension; 564 extension_ = extension;
535 SetIcon(icon); 565 SetIcon(icon);
536 566
537 install_ui_->OnInstallSuccess(extension, &icon_); 567 install_ui_->OnInstallSuccess(extension, &icon_);
538 } 568 }
539 569
540 void ExtensionInstallPrompt::OnInstallFailure( 570 void ExtensionInstallPrompt::OnInstallFailure(
541 const extensions::CrxInstallerError& error) { 571 const extensions::CrxInstallerError& error) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 Extension::Type extension_type = extension_ ? extension_->GetType() : 663 Extension::Type extension_type = extension_ ? extension_->GetType() :
634 Extension::TYPE_UNKNOWN; 664 Extension::TYPE_UNKNOWN;
635 prompt_.SetPermissions(permissions_->GetWarningMessages(extension_type)); 665 prompt_.SetPermissions(permissions_->GetWarningMessages(extension_type));
636 } 666 }
637 667
638 switch (prompt_.type()) { 668 switch (prompt_.type()) {
639 case PERMISSIONS_PROMPT: 669 case PERMISSIONS_PROMPT:
640 case RE_ENABLE_PROMPT: 670 case RE_ENABLE_PROMPT:
641 case INLINE_INSTALL_PROMPT: 671 case INLINE_INSTALL_PROMPT:
642 case EXTERNAL_INSTALL_PROMPT: 672 case EXTERNAL_INSTALL_PROMPT:
643 case INSTALL_PROMPT: { 673 case INSTALL_PROMPT:
674 case POST_INSTALL_PERMISSIONS_PROMPT: {
644 prompt_.set_extension(extension_); 675 prompt_.set_extension(extension_);
645 prompt_.set_icon(gfx::Image::CreateFrom1xBitmap(icon_)); 676 prompt_.set_icon(gfx::Image::CreateFrom1xBitmap(icon_));
646 break; 677 break;
647 } 678 }
648 case BUNDLE_INSTALL_PROMPT: { 679 case BUNDLE_INSTALL_PROMPT: {
649 prompt_.set_bundle(bundle_); 680 prompt_.set_bundle(bundle_);
650 break; 681 break;
651 } 682 }
652 default: 683 default:
653 NOTREACHED() << "Unknown message"; 684 NOTREACHED() << "Unknown message";
654 return; 685 return;
655 } 686 }
656 687
657 if (AutoConfirmPrompt(delegate_)) 688 if (AutoConfirmPrompt(delegate_))
658 return; 689 return;
659 690
660 if (show_dialog_callback_.is_null()) 691 if (show_dialog_callback_.is_null())
661 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); 692 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_);
662 else 693 else
663 show_dialog_callback_.Run(show_params_, delegate_, prompt_); 694 show_dialog_callback_.Run(show_params_, delegate_, prompt_);
664 } 695 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_prompt.h ('k') | chrome/browser/resources/extensions/extension_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698