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

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

Issue 683993002: Revert of Fix crash when user closes window prior to the "Confirm Install" prompt showing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/install_prompt_navigator
Patch Set: Created 6 years, 1 month 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_prompt_show_params.h"
18 #include "chrome/browser/extensions/extension_util.h" 17 #include "chrome/browser/extensions/extension_util.h"
19 #include "chrome/browser/extensions/permissions_updater.h" 18 #include "chrome/browser/extensions/permissions_updater.h"
20 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/ui/extensions/extension_install_ui_factory.h" 20 #include "chrome/browser/ui/extensions/extension_install_ui_factory.h"
22 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
23 #include "chrome/grit/chromium_strings.h" 22 #include "chrome/grit/chromium_strings.h"
24 #include "chrome/grit/generated_resources.h" 23 #include "chrome/grit/generated_resources.h"
25 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
26 #include "extensions/browser/extension_prefs.h" 25 #include "extensions/browser/extension_prefs.h"
27 #include "extensions/browser/extension_util.h" 26 #include "extensions/browser/extension_util.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 NOTREACHED(); 168 NOTREACHED();
170 return false; 169 return false;
171 } 170 }
172 171
173 Profile* ProfileForWebContents(content::WebContents* web_contents) { 172 Profile* ProfileForWebContents(content::WebContents* web_contents) {
174 if (!web_contents) 173 if (!web_contents)
175 return NULL; 174 return NULL;
176 return Profile::FromBrowserContext(web_contents->GetBrowserContext()); 175 return Profile::FromBrowserContext(web_contents->GetBrowserContext());
177 } 176 }
178 177
178 gfx::NativeWindow NativeWindowForWebContents(content::WebContents* contents) {
179 if (!contents)
180 return NULL;
181
182 return contents->GetTopLevelNativeWindow();
183 }
184
179 } // namespace 185 } // namespace
180 186
181 ExtensionInstallPrompt::Prompt::InstallPromptPermissions:: 187 ExtensionInstallPrompt::Prompt::InstallPromptPermissions::
182 InstallPromptPermissions() { 188 InstallPromptPermissions() {
183 } 189 }
184 ExtensionInstallPrompt::Prompt::InstallPromptPermissions:: 190 ExtensionInstallPrompt::Prompt::InstallPromptPermissions::
185 ~InstallPromptPermissions() { 191 ~InstallPromptPermissions() {
186 } 192 }
187 193
188 // static 194 // static
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 PermissionsType permissions_type) const { 605 PermissionsType permissions_type) const {
600 DCHECK_NE(ALL_PERMISSIONS, permissions_type); 606 DCHECK_NE(ALL_PERMISSIONS, permissions_type);
601 return permissions_type == REGULAR_PERMISSIONS ? prompt_permissions_ 607 return permissions_type == REGULAR_PERMISSIONS ? prompt_permissions_
602 : withheld_prompt_permissions_; 608 : withheld_prompt_permissions_;
603 } 609 }
604 610
605 bool ExtensionInstallPrompt::Prompt::ShouldDisplayRevokeFilesButton() const { 611 bool ExtensionInstallPrompt::Prompt::ShouldDisplayRevokeFilesButton() const {
606 return !retained_files_.empty(); 612 return !retained_files_.empty();
607 } 613 }
608 614
615 ExtensionInstallPrompt::ShowParams::ShowParams(content::WebContents* contents)
616 : profile(ProfileForWebContents(contents)),
617 parent_web_contents(contents),
618 parent_window(NativeWindowForWebContents(contents)) {
619 }
620
621 ExtensionInstallPrompt::ShowParams::ShowParams(Profile* profile,
622 gfx::NativeWindow window)
623 : profile(profile),
624 parent_web_contents(NULL),
625 parent_window(window) {
626 }
627
609 // static 628 // static
610 scoped_refptr<Extension> 629 scoped_refptr<Extension>
611 ExtensionInstallPrompt::GetLocalizedExtensionForDisplay( 630 ExtensionInstallPrompt::GetLocalizedExtensionForDisplay(
612 const base::DictionaryValue* manifest, 631 const base::DictionaryValue* manifest,
613 int flags, 632 int flags,
614 const std::string& id, 633 const std::string& id,
615 const std::string& localized_name, 634 const std::string& localized_name,
616 const std::string& localized_description, 635 const std::string& localized_description,
617 std::string* error) { 636 std::string* error) {
618 scoped_ptr<base::DictionaryValue> localized_manifest; 637 scoped_ptr<base::DictionaryValue> localized_manifest;
(...skipping 18 matching lines...) Expand all
637 error); 656 error);
638 } 657 }
639 658
640 ExtensionInstallPrompt::ExtensionInstallPrompt(content::WebContents* contents) 659 ExtensionInstallPrompt::ExtensionInstallPrompt(content::WebContents* contents)
641 : profile_(ProfileForWebContents(contents)), 660 : profile_(ProfileForWebContents(contents)),
642 ui_loop_(base::MessageLoop::current()), 661 ui_loop_(base::MessageLoop::current()),
643 extension_(NULL), 662 extension_(NULL),
644 bundle_(NULL), 663 bundle_(NULL),
645 install_ui_(extensions::CreateExtensionInstallUI( 664 install_ui_(extensions::CreateExtensionInstallUI(
646 ProfileForWebContents(contents))), 665 ProfileForWebContents(contents))),
647 show_params_(new ExtensionInstallPromptShowParams(contents)), 666 show_params_(contents),
648 delegate_(NULL) { 667 delegate_(NULL) {
649 } 668 }
650 669
651 ExtensionInstallPrompt::ExtensionInstallPrompt(Profile* profile, 670 ExtensionInstallPrompt::ExtensionInstallPrompt(Profile* profile,
652 gfx::NativeWindow native_window) 671 gfx::NativeWindow native_window)
653 : profile_(profile), 672 : profile_(profile),
654 ui_loop_(base::MessageLoop::current()), 673 ui_loop_(base::MessageLoop::current()),
655 extension_(NULL), 674 extension_(NULL),
656 bundle_(NULL), 675 bundle_(NULL),
657 install_ui_(extensions::CreateExtensionInstallUI(profile)), 676 install_ui_(extensions::CreateExtensionInstallUI(profile)),
658 show_params_( 677 show_params_(profile, native_window),
659 new ExtensionInstallPromptShowParams(profile, native_window)),
660 delegate_(NULL) { 678 delegate_(NULL) {
661 } 679 }
662 680
663 ExtensionInstallPrompt::~ExtensionInstallPrompt() { 681 ExtensionInstallPrompt::~ExtensionInstallPrompt() {
664 } 682 }
665 683
666 void ExtensionInstallPrompt::ConfirmBundleInstall( 684 void ExtensionInstallPrompt::ConfirmBundleInstall(
667 extensions::BundleInstaller* bundle, 685 extensions::BundleInstaller* bundle,
668 const PermissionSet* permissions) { 686 const PermissionSet* permissions) {
669 DCHECK(ui_loop_ == base::MessageLoop::current()); 687 DCHECK(ui_loop_ == base::MessageLoop::current());
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 break; 937 break;
920 } 938 }
921 default: 939 default:
922 NOTREACHED() << "Unknown message"; 940 NOTREACHED() << "Unknown message";
923 return; 941 return;
924 } 942 }
925 943
926 if (AutoConfirmPrompt(delegate_)) 944 if (AutoConfirmPrompt(delegate_))
927 return; 945 return;
928 946
929 if (show_params_->WasParentDestroyed()) {
930 delegate_->InstallUIAbort(false);
931 return;
932 }
933
934 if (show_dialog_callback_.is_null()) 947 if (show_dialog_callback_.is_null())
935 GetDefaultShowDialogCallback().Run(show_params_.get(), delegate_, prompt_); 948 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_);
936 else 949 else
937 show_dialog_callback_.Run(show_params_.get(), delegate_, prompt_); 950 show_dialog_callback_.Run(show_params_, delegate_, prompt_);
938 } 951 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698