OLD | NEW |
---|---|
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/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_finder.h" | 13 #include "chrome/browser/ui/browser_finder.h" |
13 #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" |
14 #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" |
15 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h" | 16 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h" |
16 #import "chrome/browser/ui/cocoa/extensions/windowed_install_dialog_controller.h " | 17 #import "chrome/browser/ui/cocoa/extensions/windowed_install_dialog_controller.h " |
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
19 | 20 |
21 using extensions::ExperienceSamplingEvent; | |
22 | |
20 namespace { | 23 namespace { |
21 | 24 |
22 void ShowExtensionInstallDialogImpl( | 25 void ShowExtensionInstallDialogImpl( |
23 const ExtensionInstallPrompt::ShowParams& show_params, | 26 const ExtensionInstallPrompt::ShowParams& show_params, |
24 ExtensionInstallPrompt::Delegate* delegate, | 27 ExtensionInstallPrompt::Delegate* delegate, |
25 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) { | 28 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) { |
26 // These objects will delete themselves when the dialog closes. | 29 // These objects will delete themselves when the dialog closes. |
27 if (!show_params.parent_web_contents) { | 30 if (!show_params.parent_web_contents) { |
28 new WindowedInstallDialogController(show_params, delegate, prompt); | 31 new WindowedInstallDialogController(show_params, delegate, prompt); |
29 return; | 32 return; |
(...skipping 15 matching lines...) Expand all Loading... | |
45 prompt:prompt]); | 48 prompt:prompt]); |
46 | 49 |
47 base::scoped_nsobject<NSWindow> window([[ConstrainedWindowCustomWindow alloc] | 50 base::scoped_nsobject<NSWindow> window([[ConstrainedWindowCustomWindow alloc] |
48 initWithContentRect:[[view_controller_ view] bounds]]); | 51 initWithContentRect:[[view_controller_ view] bounds]]); |
49 [[window contentView] addSubview:[view_controller_ view]]; | 52 [[window contentView] addSubview:[view_controller_ view]]; |
50 | 53 |
51 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( | 54 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( |
52 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window]); | 55 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window]); |
53 constrained_window_.reset(new ConstrainedWindowMac( | 56 constrained_window_.reset(new ConstrainedWindowMac( |
54 this, show_params.parent_web_contents, sheet)); | 57 this, show_params.parent_web_contents, sheet)); |
58 | |
59 std::string event_name = "extension_install_dialog_"; | |
60 event_name.append(ExtensionInstallPrompt::PromptTypeToString(prompt->type()); | |
groby-ooo-7-16
2014/08/14 18:00:05
Is this a constant shared with other platforms? In
Chris Thompson
2014/08/14 18:06:21
Done. I've moved it out to the main ExperienceSamp
| |
61 sampling_event_ = ExperienceSamplingEvent::Create(event_name); | |
55 } | 62 } |
56 | 63 |
57 ExtensionInstallDialogController::~ExtensionInstallDialogController() { | 64 ExtensionInstallDialogController::~ExtensionInstallDialogController() { |
58 } | 65 } |
59 | 66 |
60 void ExtensionInstallDialogController::InstallUIProceed() { | 67 void ExtensionInstallDialogController::InstallUIProceed() { |
68 if (sampling_event_.get()) | |
groby-ooo-7-16
2014/08/14 18:00:05
No need to check - it's set in the ctor.
Chris Thompson
2014/08/14 18:06:20
The Create(event_name) call can return an empty sc
groby-ooo-7-16
2014/08/14 18:34:05
In that case, mind leaving a quick comment at the
Chris Thompson
2014/08/14 19:51:47
Done (on upstream CL).
| |
69 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed); | |
61 delegate_->InstallUIProceed(); | 70 delegate_->InstallUIProceed(); |
groby-ooo-7-16
2014/08/14 18:00:05
Shouldn't the delegate handle this, so you can be
Chris Thompson
2014/08/14 18:06:21
I looked into the delegate classes for extension i
| |
62 delegate_ = NULL; | 71 delegate_ = NULL; |
63 constrained_window_->CloseWebContentsModalDialog(); | 72 constrained_window_->CloseWebContentsModalDialog(); |
64 } | 73 } |
65 | 74 |
66 void ExtensionInstallDialogController::InstallUIAbort(bool user_initiated) { | 75 void ExtensionInstallDialogController::InstallUIAbort(bool user_initiated) { |
76 if (sampling_event_.get()) | |
groby-ooo-7-16
2014/08/14 18:00:05
see above
Chris Thompson
2014/08/14 18:06:21
Acknowledged.
| |
77 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kDeny); | |
67 delegate_->InstallUIAbort(user_initiated); | 78 delegate_->InstallUIAbort(user_initiated); |
68 delegate_ = NULL; | 79 delegate_ = NULL; |
69 constrained_window_->CloseWebContentsModalDialog(); | 80 constrained_window_->CloseWebContentsModalDialog(); |
70 } | 81 } |
71 | 82 |
72 void ExtensionInstallDialogController::OnConstrainedWindowClosed( | 83 void ExtensionInstallDialogController::OnConstrainedWindowClosed( |
73 ConstrainedWindowMac* window) { | 84 ConstrainedWindowMac* window) { |
74 if (delegate_) | 85 if (delegate_) |
75 delegate_->InstallUIAbort(false); | 86 delegate_->InstallUIAbort(false); |
76 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 87 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
77 } | 88 } |
78 | 89 |
79 // static | 90 // static |
80 ExtensionInstallPrompt::ShowDialogCallback | 91 ExtensionInstallPrompt::ShowDialogCallback |
81 ExtensionInstallPrompt::GetDefaultShowDialogCallback() { | 92 ExtensionInstallPrompt::GetDefaultShowDialogCallback() { |
82 return base::Bind(&ShowExtensionInstallDialogImpl); | 93 return base::Bind(&ShowExtensionInstallDialogImpl); |
83 } | 94 } |
OLD | NEW |