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

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

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