| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/windowed_install_dialog_controller.h
" | 5 #import "chrome/browser/ui/cocoa/extensions/windowed_install_dialog_controller.h
" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #import "base/callback_helpers.h" | 9 #import "base/callback_helpers.h" |
| 8 #import "base/mac/sdk_forward_declarations.h" | 10 #import "base/mac/sdk_forward_declarations.h" |
| 9 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
| 11 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" | 13 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 13 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h" | 15 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h" |
| 14 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 15 #include "ui/base/cocoa/window_size_constants.h" | 17 #include "ui/base/cocoa/window_size_constants.h" |
| 16 | 18 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 32 | 34 |
| 33 WindowedInstallDialogController::WindowedInstallDialogController( | 35 WindowedInstallDialogController::WindowedInstallDialogController( |
| 34 ExtensionInstallPromptShowParams* show_params, | 36 ExtensionInstallPromptShowParams* show_params, |
| 35 const ExtensionInstallPrompt::DoneCallback& done_callback, | 37 const ExtensionInstallPrompt::DoneCallback& done_callback, |
| 36 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt) | 38 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt) |
| 37 : done_callback_(done_callback) { | 39 : done_callback_(done_callback) { |
| 38 install_controller_.reset([[WindowedInstallController alloc] | 40 install_controller_.reset([[WindowedInstallController alloc] |
| 39 initWithProfile:show_params->profile() | 41 initWithProfile:show_params->profile() |
| 40 navigator:show_params->GetParentWebContents() | 42 navigator:show_params->GetParentWebContents() |
| 41 delegate:this | 43 delegate:this |
| 42 prompt:prompt.Pass()]); | 44 prompt:std::move(prompt)]); |
| 43 [[install_controller_ window] makeKeyAndOrderFront:nil]; | 45 [[install_controller_ window] makeKeyAndOrderFront:nil]; |
| 44 } | 46 } |
| 45 | 47 |
| 46 WindowedInstallDialogController::~WindowedInstallDialogController() { | 48 WindowedInstallDialogController::~WindowedInstallDialogController() { |
| 47 DCHECK(!install_controller_); | 49 DCHECK(!install_controller_); |
| 48 DCHECK(done_callback_.is_null()); | 50 DCHECK(done_callback_.is_null()); |
| 49 } | 51 } |
| 50 | 52 |
| 51 void WindowedInstallDialogController::OnWindowClosing() { | 53 void WindowedInstallDialogController::OnWindowClosing() { |
| 52 install_controller_.reset(); | 54 install_controller_.reset(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 styleMask:NSTitledWindowMask | 93 styleMask:NSTitledWindowMask |
| 92 backing:NSBackingStoreBuffered | 94 backing:NSBackingStoreBuffered |
| 93 defer:NO]); | 95 defer:NO]); |
| 94 if ((self = [super initWithWindow:controlledPanel])) { | 96 if ((self = [super initWithWindow:controlledPanel])) { |
| 95 dialogController_ = delegate; | 97 dialogController_ = delegate; |
| 96 ExtensionInstallPrompt::Prompt* weakPrompt = prompt.get(); | 98 ExtensionInstallPrompt::Prompt* weakPrompt = prompt.get(); |
| 97 installViewController_.reset([[ExtensionInstallViewController alloc] | 99 installViewController_.reset([[ExtensionInstallViewController alloc] |
| 98 initWithProfile:profile | 100 initWithProfile:profile |
| 99 navigator:navigator | 101 navigator:navigator |
| 100 delegate:delegate | 102 delegate:delegate |
| 101 prompt:prompt.Pass()]); | 103 prompt:std::move(prompt)]); |
| 102 NSWindow* window = [self window]; | 104 NSWindow* window = [self window]; |
| 103 | 105 |
| 104 // Ensure the window does not display behind the app launcher window, and is | 106 // Ensure the window does not display behind the app launcher window, and is |
| 105 // otherwise hard to lose behind other windows (since it is not modal). | 107 // otherwise hard to lose behind other windows (since it is not modal). |
| 106 [window setLevel:NSDockWindowLevel]; | 108 [window setLevel:NSDockWindowLevel]; |
| 107 | 109 |
| 108 // Animate the window when ordered in, the same way as an NSAlert. | 110 // Animate the window when ordered in, the same way as an NSAlert. |
| 109 if ([window respondsToSelector:@selector(setAnimationBehavior:)]) | 111 if ([window respondsToSelector:@selector(setAnimationBehavior:)]) |
| 110 [window setAnimationBehavior:NSWindowAnimationBehaviorAlertPanel]; | 112 [window setAnimationBehavior:NSWindowAnimationBehaviorAlertPanel]; |
| 111 | 113 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 123 - (ExtensionInstallViewController*)viewController { | 125 - (ExtensionInstallViewController*)viewController { |
| 124 return installViewController_; | 126 return installViewController_; |
| 125 } | 127 } |
| 126 | 128 |
| 127 - (void)windowWillClose:(NSNotification*)notification { | 129 - (void)windowWillClose:(NSNotification*)notification { |
| 128 [[self window] setDelegate:nil]; | 130 [[self window] setDelegate:nil]; |
| 129 dialogController_->OnWindowClosing(); | 131 dialogController_->OnWindowClosing(); |
| 130 } | 132 } |
| 131 | 133 |
| 132 @end | 134 @end |
| OLD | NEW |