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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm

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 #import "chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller. h" 5 #import "chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller. h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h" 11 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h"
12 #include "chrome/browser/extensions/extension_install_prompt_show_params.h"
13 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_finder.h" 13 #include "chrome/browser/ui/browser_finder.h"
15 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h" 14 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h"
16 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_w indow.h" 15 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_w indow.h"
17 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h" 16 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h"
18 #import "chrome/browser/ui/cocoa/extensions/windowed_install_dialog_controller.h " 17 #import "chrome/browser/ui/cocoa/extensions/windowed_install_dialog_controller.h "
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
21 20
22 using extensions::ExperienceSamplingEvent; 21 using extensions::ExperienceSamplingEvent;
23 22
24 namespace { 23 namespace {
25 24
26 void ShowExtensionInstallDialogImpl( 25 void ShowExtensionInstallDialogImpl(
27 ExtensionInstallPromptShowParams* show_params, 26 const ExtensionInstallPrompt::ShowParams& show_params,
28 ExtensionInstallPrompt::Delegate* delegate, 27 ExtensionInstallPrompt::Delegate* delegate,
29 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) { 28 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) {
30 // These objects will delete themselves when the dialog closes. 29 // These objects will delete themselves when the dialog closes.
31 if (!show_params->GetParentWebContents()) { 30 if (!show_params.parent_web_contents) {
32 new WindowedInstallDialogController(show_params, delegate, prompt); 31 new WindowedInstallDialogController(show_params, delegate, prompt);
33 return; 32 return;
34 } 33 }
35 34
36 new ExtensionInstallDialogController(show_params, delegate, prompt); 35 new ExtensionInstallDialogController(show_params, delegate, prompt);
37 } 36 }
38 37
39 } // namespace 38 } // namespace
40 39
41 ExtensionInstallDialogController::ExtensionInstallDialogController( 40 ExtensionInstallDialogController::ExtensionInstallDialogController(
42 ExtensionInstallPromptShowParams* show_params, 41 const ExtensionInstallPrompt::ShowParams& show_params,
43 ExtensionInstallPrompt::Delegate* delegate, 42 ExtensionInstallPrompt::Delegate* delegate,
44 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) 43 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt)
45 : delegate_(delegate) { 44 : delegate_(delegate) {
46 view_controller_.reset([[ExtensionInstallViewController alloc] 45 view_controller_.reset([[ExtensionInstallViewController alloc]
47 initWithProfile:show_params->profile() 46 initWithProfile:show_params.profile
48 navigator:show_params->GetParentWebContents() 47 navigator:show_params.parent_web_contents
49 delegate:this 48 delegate:this
50 prompt:prompt]); 49 prompt:prompt]);
51 50
52 base::scoped_nsobject<NSWindow> window([[ConstrainedWindowCustomWindow alloc] 51 base::scoped_nsobject<NSWindow> window([[ConstrainedWindowCustomWindow alloc]
53 initWithContentRect:[[view_controller_ view] bounds]]); 52 initWithContentRect:[[view_controller_ view] bounds]]);
54 [[window contentView] addSubview:[view_controller_ view]]; 53 [[window contentView] addSubview:[view_controller_ view]];
55 54
56 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( 55 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
57 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window]); 56 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window]);
58 constrained_window_.reset(new ConstrainedWindowMac( 57 constrained_window_.reset(new ConstrainedWindowMac(
59 this, show_params->GetParentWebContents(), sheet)); 58 this, show_params.parent_web_contents, sheet));
60 59
61 std::string event_name = ExperienceSamplingEvent::kExtensionInstallDialog; 60 std::string event_name = ExperienceSamplingEvent::kExtensionInstallDialog;
62 event_name.append(ExtensionInstallPrompt::PromptTypeToString(prompt->type())); 61 event_name.append(ExtensionInstallPrompt::PromptTypeToString(prompt->type()));
63 sampling_event_ = ExperienceSamplingEvent::Create(event_name); 62 sampling_event_ = ExperienceSamplingEvent::Create(event_name);
64 } 63 }
65 64
66 ExtensionInstallDialogController::~ExtensionInstallDialogController() { 65 ExtensionInstallDialogController::~ExtensionInstallDialogController() {
67 } 66 }
68 67
69 void ExtensionInstallDialogController::InstallUIProceed() { 68 void ExtensionInstallDialogController::InstallUIProceed() {
(...skipping 17 matching lines...) Expand all
87 if (delegate_) 86 if (delegate_)
88 delegate_->InstallUIAbort(false); 87 delegate_->InstallUIAbort(false);
89 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 88 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
90 } 89 }
91 90
92 // static 91 // static
93 ExtensionInstallPrompt::ShowDialogCallback 92 ExtensionInstallPrompt::ShowDialogCallback
94 ExtensionInstallPrompt::GetDefaultShowDialogCallback() { 93 ExtensionInstallPrompt::GetDefaultShowDialogCallback() {
95 return base::Bind(&ShowExtensionInstallDialogImpl); 94 return base::Bind(&ShowExtensionInstallDialogImpl);
96 } 95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698