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

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

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

Powered by Google App Engine
This is Rietveld 408576698