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

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

Issue 462853002: Cocoa extension install dialog instrumentation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sampling-extensions
Patch Set: Fix syntax error Created 6 years, 4 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
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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 = ExperienceSamplingEvent::kExtensionInstallDialog;
60 event_name.append(ExtensionInstallPrompt::PromptTypeToString(prompt->type()));
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())
69 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed);
61 delegate_->InstallUIProceed(); 70 delegate_->InstallUIProceed();
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())
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698