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

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

Issue 660643002: [Refactor] Move creating a browser if necessary to ExtensionInstallDialogView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
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 #import "base/mac/sdk_forward_declarations.h" 7 #import "base/mac/sdk_forward_declarations.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "chrome/browser/profiles/profile.h"
10 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h" 11 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h"
12 #include "content/public/browser/web_contents.h"
11 #include "ui/base/cocoa/window_size_constants.h" 13 #include "ui/base/cocoa/window_size_constants.h"
12 14
13 @interface WindowedInstallController 15 @interface WindowedInstallController
14 : NSWindowController<NSWindowDelegate> { 16 : NSWindowController<NSWindowDelegate> {
15 @private 17 @private
16 base::scoped_nsobject<ExtensionInstallViewController> installViewController_; 18 base::scoped_nsobject<ExtensionInstallViewController> installViewController_;
17 WindowedInstallDialogController* dialogController_; // Weak. Owns us. 19 WindowedInstallDialogController* dialogController_; // Weak. Owns us.
18 } 20 }
19 21
20 @property(readonly, nonatomic) ExtensionInstallViewController* viewController; 22 @property(readonly, nonatomic) ExtensionInstallViewController* viewController;
21 23
22 - (id)initWithNavigator:(content::PageNavigator*)navigator 24 - (id)initWithProfile:(Profile*)profile
23 delegate:(WindowedInstallDialogController*)delegate 25 navigator:(content::PageNavigator*)navigator
24 prompt:(scoped_refptr<ExtensionInstallPrompt::Prompt>)prompt; 26 delegate:(WindowedInstallDialogController*)delegate
27 prompt:(scoped_refptr<ExtensionInstallPrompt::Prompt>)prompt;
25 28
26 @end 29 @end
27 30
28 WindowedInstallDialogController::WindowedInstallDialogController( 31 WindowedInstallDialogController::WindowedInstallDialogController(
29 const ExtensionInstallPrompt::ShowParams& show_params, 32 const ExtensionInstallPrompt::ShowParams& show_params,
30 ExtensionInstallPrompt::Delegate* delegate, 33 ExtensionInstallPrompt::Delegate* delegate,
31 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) 34 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt)
32 : delegate_(delegate) { 35 : delegate_(delegate) {
33 install_controller_.reset([[WindowedInstallController alloc] 36 install_controller_.reset([[WindowedInstallController alloc]
34 initWithNavigator:show_params.navigator 37 initWithProfile:show_params.profile
35 delegate:this 38 navigator:show_params.parent_web_contents
36 prompt:prompt]); 39 delegate:this
40 prompt:prompt]);
37 [[install_controller_ window] makeKeyAndOrderFront:nil]; 41 [[install_controller_ window] makeKeyAndOrderFront:nil];
38 } 42 }
39 43
40 WindowedInstallDialogController::~WindowedInstallDialogController() { 44 WindowedInstallDialogController::~WindowedInstallDialogController() {
41 DCHECK(!install_controller_); 45 DCHECK(!install_controller_);
42 DCHECK(!delegate_); 46 DCHECK(!delegate_);
43 } 47 }
44 48
45 void WindowedInstallDialogController::OnWindowClosing() { 49 void WindowedInstallDialogController::OnWindowClosing() {
46 install_controller_.reset(); 50 install_controller_.reset();
(...skipping 16 matching lines...) Expand all
63 } 67 }
64 68
65 void WindowedInstallDialogController::InstallUIAbort(bool user_initiated) { 69 void WindowedInstallDialogController::InstallUIAbort(bool user_initiated) {
66 delegate_->InstallUIAbort(user_initiated); 70 delegate_->InstallUIAbort(user_initiated);
67 delegate_ = NULL; 71 delegate_ = NULL;
68 [[install_controller_ window] close]; 72 [[install_controller_ window] close];
69 } 73 }
70 74
71 @implementation WindowedInstallController 75 @implementation WindowedInstallController
72 76
73 - (id)initWithNavigator:(content::PageNavigator*)navigator 77 - (id)initWithProfile:(Profile*)profile
74 delegate:(WindowedInstallDialogController*)delegate 78 navigator:(content::PageNavigator*)navigator
75 prompt:(scoped_refptr<ExtensionInstallPrompt::Prompt>)prompt { 79 delegate:(WindowedInstallDialogController*)delegate
80 prompt:(scoped_refptr<ExtensionInstallPrompt::Prompt>)prompt {
76 base::scoped_nsobject<NSWindow> controlledPanel( 81 base::scoped_nsobject<NSWindow> controlledPanel(
77 [[NSPanel alloc] initWithContentRect:ui::kWindowSizeDeterminedLater 82 [[NSPanel alloc] initWithContentRect:ui::kWindowSizeDeterminedLater
78 styleMask:NSTitledWindowMask 83 styleMask:NSTitledWindowMask
79 backing:NSBackingStoreBuffered 84 backing:NSBackingStoreBuffered
80 defer:NO]); 85 defer:NO]);
81 if ((self = [super initWithWindow:controlledPanel])) { 86 if ((self = [super initWithWindow:controlledPanel])) {
82 dialogController_ = delegate; 87 dialogController_ = delegate;
83 installViewController_.reset([[ExtensionInstallViewController alloc] 88 installViewController_.reset([[ExtensionInstallViewController alloc]
84 initWithNavigator:navigator 89 initWithProfile:profile
85 delegate:delegate 90 navigator:navigator
86 prompt:prompt]); 91 delegate:delegate
92 prompt:prompt]);
87 NSWindow* window = [self window]; 93 NSWindow* window = [self window];
88 94
89 // Ensure the window does not display behind the app launcher window, and is 95 // Ensure the window does not display behind the app launcher window, and is
90 // otherwise hard to lose behind other windows (since it is not modal). 96 // otherwise hard to lose behind other windows (since it is not modal).
91 [window setLevel:NSDockWindowLevel]; 97 [window setLevel:NSDockWindowLevel];
92 98
93 // Animate the window when ordered in, the same way as an NSAlert. 99 // Animate the window when ordered in, the same way as an NSAlert.
94 if ([window respondsToSelector:@selector(setAnimationBehavior:)]) 100 if ([window respondsToSelector:@selector(setAnimationBehavior:)])
95 [window setAnimationBehavior:NSWindowAnimationBehaviorAlertPanel]; 101 [window setAnimationBehavior:NSWindowAnimationBehaviorAlertPanel];
96 102
(...skipping 11 matching lines...) Expand all
108 - (ExtensionInstallViewController*)viewController { 114 - (ExtensionInstallViewController*)viewController {
109 return installViewController_; 115 return installViewController_;
110 } 116 }
111 117
112 - (void)windowWillClose:(NSNotification*)notification { 118 - (void)windowWillClose:(NSNotification*)notification {
113 [[self window] setDelegate:nil]; 119 [[self window] setDelegate:nil];
114 dialogController_->OnWindowClosing(); 120 dialogController_->OnWindowClosing();
115 } 121 }
116 122
117 @end 123 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698