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

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

Issue 501273002: Update extension install prompt to reflect withheld permissions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added init calls for other types of installs Created 6 years, 3 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 <map> 7 #include <map>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/extensions/bundle_installer.h" 16 #include "chrome/browser/extensions/bundle_installer.h"
17 #include "chrome/browser/extensions/extension_install_ui.h" 17 #include "chrome/browser/extensions/extension_install_ui.h"
18 #include "chrome/browser/extensions/extension_util.h" 18 #include "chrome/browser/extensions/extension_util.h"
19 #include "chrome/browser/extensions/permissions_updater.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_window.h" 22 #include "chrome/browser/ui/browser_window.h"
22 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
24 #include "chrome/grit/chromium_strings.h" 25 #include "chrome/grit/chromium_strings.h"
25 #include "chrome/grit/generated_resources.h" 26 #include "chrome/grit/generated_resources.h"
26 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
27 #include "extensions/browser/extension_prefs.h" 28 #include "extensions/browser/extension_prefs.h"
28 #include "extensions/browser/extension_util.h" 29 #include "extensions/browser/extension_util.h"
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 537 }
537 538
538 ExtensionInstallPrompt::~ExtensionInstallPrompt() { 539 ExtensionInstallPrompt::~ExtensionInstallPrompt() {
539 } 540 }
540 541
541 void ExtensionInstallPrompt::ConfirmBundleInstall( 542 void ExtensionInstallPrompt::ConfirmBundleInstall(
542 extensions::BundleInstaller* bundle, 543 extensions::BundleInstaller* bundle,
543 const PermissionSet* permissions) { 544 const PermissionSet* permissions) {
544 DCHECK(ui_loop_ == base::MessageLoop::current()); 545 DCHECK(ui_loop_ == base::MessageLoop::current());
545 bundle_ = bundle; 546 bundle_ = bundle;
547 // |bundle|'s extensions have already had their permissions initialized at
548 // this point, so withheld permissions will not show up in the prompt.
546 permissions_ = permissions; 549 permissions_ = permissions;
547 delegate_ = bundle; 550 delegate_ = bundle;
548 prompt_ = new Prompt(BUNDLE_INSTALL_PROMPT); 551 prompt_ = new Prompt(BUNDLE_INSTALL_PROMPT);
549 552
550 ShowConfirmation(); 553 ShowConfirmation();
551 } 554 }
552 555
553 void ExtensionInstallPrompt::ConfirmStandaloneInstall( 556 void ExtensionInstallPrompt::ConfirmStandaloneInstall(
554 Delegate* delegate, 557 Delegate* delegate,
555 const Extension* extension, 558 const Extension* extension,
556 SkBitmap* icon, 559 SkBitmap* icon,
557 scoped_refptr<Prompt> prompt) { 560 scoped_refptr<Prompt> prompt) {
558 DCHECK(ui_loop_ == base::MessageLoop::current()); 561 DCHECK(ui_loop_ == base::MessageLoop::current());
559 extension_ = extension; 562 extension_ = extension;
563 // Initialize permissions so that withheld permissions don't end up in the
564 // install prompt.
565 extensions::PermissionsUpdater(install_ui_->profile()).InitializePermissions(
566 extension_);
not at google - send to devlin 2014/08/28 03:17:32 A weirdness here is that even though this is a dum
gpdavis 2014/08/28 17:41:48 Ping :) What if we just add a flag to InitializeP
not at google - send to devlin 2014/08/28 18:28:02 Yes! That's the best solution I came up with as we
560 permissions_ = extension->permissions_data()->active_permissions(); 567 permissions_ = extension->permissions_data()->active_permissions();
561 delegate_ = delegate; 568 delegate_ = delegate;
562 prompt_ = prompt; 569 prompt_ = prompt;
563 570
564 SetIcon(icon); 571 SetIcon(icon);
565 ShowConfirmation(); 572 ShowConfirmation();
566 } 573 }
567 574
568 void ExtensionInstallPrompt::ConfirmWebstoreInstall( 575 void ExtensionInstallPrompt::ConfirmWebstoreInstall(
569 Delegate* delegate, 576 Delegate* delegate,
570 const Extension* extension, 577 const Extension* extension,
571 const SkBitmap* icon, 578 const SkBitmap* icon,
572 const ShowDialogCallback& show_dialog_callback) { 579 const ShowDialogCallback& show_dialog_callback) {
573 // SetIcon requires |extension_| to be set. ConfirmInstall will setup the 580 // SetIcon requires |extension_| to be set. ConfirmInstall will setup the
574 // remaining fields. 581 // remaining fields.
575 extension_ = extension; 582 extension_ = extension;
576 SetIcon(icon); 583 SetIcon(icon);
577 ConfirmInstall(delegate, extension, show_dialog_callback); 584 ConfirmInstall(delegate, extension, show_dialog_callback);
578 } 585 }
579 586
580 void ExtensionInstallPrompt::ConfirmInstall( 587 void ExtensionInstallPrompt::ConfirmInstall(
581 Delegate* delegate, 588 Delegate* delegate,
582 const Extension* extension, 589 const Extension* extension,
583 const ShowDialogCallback& show_dialog_callback) { 590 const ShowDialogCallback& show_dialog_callback) {
584 DCHECK(ui_loop_ == base::MessageLoop::current()); 591 DCHECK(ui_loop_ == base::MessageLoop::current());
585 extension_ = extension; 592 extension_ = extension;
593 // Initialize permissions so that withheld permissions don't end up in the
594 // install prompt.
595 extensions::PermissionsUpdater(install_ui_->profile()).InitializePermissions(
596 extension_);
586 permissions_ = extension->permissions_data()->active_permissions(); 597 permissions_ = extension->permissions_data()->active_permissions();
587 delegate_ = delegate; 598 delegate_ = delegate;
588 prompt_ = new Prompt(INSTALL_PROMPT); 599 prompt_ = new Prompt(INSTALL_PROMPT);
589 show_dialog_callback_ = show_dialog_callback; 600 show_dialog_callback_ = show_dialog_callback;
590 601
591 // We special-case themes to not show any confirm UI. Instead they are 602 // We special-case themes to not show any confirm UI. Instead they are
592 // immediately installed, and then we show an infobar (see OnInstallSuccess) 603 // immediately installed, and then we show an infobar (see OnInstallSuccess)
593 // to allow the user to revert if they don't like it. 604 // to allow the user to revert if they don't like it.
594 // 605 //
595 // We don't do this in the case where off-store extension installs are 606 // We don't do this in the case where off-store extension installs are
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 (!extension_ || 754 (!extension_ ||
744 !extensions::PermissionsData::ShouldSkipPermissionWarnings( 755 !extensions::PermissionsData::ShouldSkipPermissionWarnings(
745 extension_->id()))) { 756 extension_->id()))) {
746 Manifest::Type type = 757 Manifest::Type type =
747 extension_ ? extension_->GetType() : Manifest::TYPE_UNKNOWN; 758 extension_ ? extension_->GetType() : Manifest::TYPE_UNKNOWN;
748 const extensions::PermissionMessageProvider* message_provider = 759 const extensions::PermissionMessageProvider* message_provider =
749 extensions::PermissionMessageProvider::Get(); 760 extensions::PermissionMessageProvider::Get();
750 prompt_->SetPermissions( 761 prompt_->SetPermissions(
751 message_provider->GetWarningMessages(permissions_.get(), type)); 762 message_provider->GetWarningMessages(permissions_.get(), type));
752 prompt_->SetPermissionsDetails( 763 prompt_->SetPermissionsDetails(
753 message_provider->GetWarningMessagesDetails(permissions_.get(), type)); 764 message_provider->GetWarningMessagesDetails(permissions_.get(), type));
not at google - send to devlin 2014/08/28 03:17:32 Around here should be the place that you pull out
gpdavis 2014/08/28 17:41:48 For some reason I felt like I needed to initialize
754 } 765 }
755 766
756 switch (prompt_->type()) { 767 switch (prompt_->type()) {
757 case PERMISSIONS_PROMPT: 768 case PERMISSIONS_PROMPT:
758 case RE_ENABLE_PROMPT: 769 case RE_ENABLE_PROMPT:
759 case INLINE_INSTALL_PROMPT: 770 case INLINE_INSTALL_PROMPT:
760 case EXTERNAL_INSTALL_PROMPT: 771 case EXTERNAL_INSTALL_PROMPT:
761 case INSTALL_PROMPT: 772 case INSTALL_PROMPT:
762 case LAUNCH_PROMPT: 773 case LAUNCH_PROMPT:
763 case POST_INSTALL_PERMISSIONS_PROMPT: 774 case POST_INSTALL_PERMISSIONS_PROMPT:
(...skipping 12 matching lines...) Expand all
776 } 787 }
777 788
778 if (AutoConfirmPrompt(delegate_)) 789 if (AutoConfirmPrompt(delegate_))
779 return; 790 return;
780 791
781 if (show_dialog_callback_.is_null()) 792 if (show_dialog_callback_.is_null())
782 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); 793 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_);
783 else 794 else
784 show_dialog_callback_.Run(show_params_, delegate_, prompt_); 795 show_dialog_callback_.Run(show_params_, delegate_, prompt_);
785 } 796 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698