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