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

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

Issue 10699057: Move application creation and extension install prompt showing off Browser and onto ExtensionTabHel… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/mac/bundle_locations.h" 8 #include "base/mac/bundle_locations.h"
9 #include "base/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
10 #include "base/memory/scoped_nsobject.h" 10 #include "base/memory/scoped_nsobject.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/sys_string_conversions.h" 12 #include "base/sys_string_conversions.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/extensions/bundle_installer.h" 14 #include "chrome/browser/extensions/bundle_installer.h"
15 #include "chrome/browser/extensions/extension_install_dialog.h" 15 #include "chrome/browser/extensions/extension_install_dialog.h"
16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_finder.h"
18 #include "chrome/browser/ui/browser_window.h"
19 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "content/public/browser/page_navigator.h"
20 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
21 #include "skia/ext/skia_utils_mac.h" 19 #include "skia/ext/skia_utils_mac.h"
22 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" 20 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
23 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/l10n/l10n_util_mac.h" 22 #include "ui/base/l10n/l10n_util_mac.h"
25 23
26 using content::OpenURLParams; 24 using content::OpenURLParams;
27 using content::Referrer; 25 using content::Referrer;
28 using extensions::BundleInstaller; 26 using extensions::BundleInstaller;
29 27
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 @synthesize subtitleField = subtitleField_; 80 @synthesize subtitleField = subtitleField_;
83 @synthesize warningsField = warningsField_; 81 @synthesize warningsField = warningsField_;
84 @synthesize cancelButton = cancelButton_; 82 @synthesize cancelButton = cancelButton_;
85 @synthesize okButton = okButton_; 83 @synthesize okButton = okButton_;
86 @synthesize warningsSeparator = warningsSeparator_; 84 @synthesize warningsSeparator = warningsSeparator_;
87 @synthesize ratingStars = ratingStars_; 85 @synthesize ratingStars = ratingStars_;
88 @synthesize ratingCountField = ratingCountField_; 86 @synthesize ratingCountField = ratingCountField_;
89 @synthesize userCountField = userCountField_; 87 @synthesize userCountField = userCountField_;
90 88
91 - (id)initWithParentWindow:(NSWindow*)window 89 - (id)initWithParentWindow:(NSWindow*)window
92 browser:(Browser*)browser 90 navigator:(content::PageNavigator*)navigator
93 delegate:(ExtensionInstallPrompt::Delegate*)delegate 91 delegate:(ExtensionInstallPrompt::Delegate*)delegate
94 prompt:(const ExtensionInstallPrompt::Prompt&)prompt { 92 prompt:(const ExtensionInstallPrompt::Prompt&)prompt {
95 NSString* nibpath = nil; 93 NSString* nibpath = nil;
96 94
97 // We use a different XIB in the case of bundle installs, inline installs or 95 // We use a different XIB in the case of bundle installs, inline installs or
98 // no permission warnings. These are laid out nicely for the data they 96 // no permission warnings. These are laid out nicely for the data they
99 // display. 97 // display.
100 if (prompt.type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT) { 98 if (prompt.type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT) {
101 nibpath = [base::mac::FrameworkBundle() 99 nibpath = [base::mac::FrameworkBundle()
102 pathForResource:@"ExtensionInstallPromptBundle" 100 pathForResource:@"ExtensionInstallPromptBundle"
103 ofType:@"nib"]; 101 ofType:@"nib"];
104 } else if (prompt.type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT) { 102 } else if (prompt.type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT) {
105 nibpath = [base::mac::FrameworkBundle() 103 nibpath = [base::mac::FrameworkBundle()
106 pathForResource:@"ExtensionInstallPromptInline" 104 pathForResource:@"ExtensionInstallPromptInline"
107 ofType:@"nib"]; 105 ofType:@"nib"];
108 } else if (prompt.GetPermissionCount() == 0) { 106 } else if (prompt.GetPermissionCount() == 0) {
109 nibpath = [base::mac::FrameworkBundle() 107 nibpath = [base::mac::FrameworkBundle()
110 pathForResource:@"ExtensionInstallPromptNoWarnings" 108 pathForResource:@"ExtensionInstallPromptNoWarnings"
111 ofType:@"nib"]; 109 ofType:@"nib"];
112 } else { 110 } else {
113 nibpath = [base::mac::FrameworkBundle() 111 nibpath = [base::mac::FrameworkBundle()
114 pathForResource:@"ExtensionInstallPrompt" 112 pathForResource:@"ExtensionInstallPrompt"
115 ofType:@"nib"]; 113 ofType:@"nib"];
116 } 114 }
117 115
118 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { 116 if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
119 parentWindow_ = window; 117 parentWindow_ = window;
120 browser_ = browser; 118 navigator_ = navigator;
121 delegate_ = delegate; 119 delegate_ = delegate;
122 prompt_.reset(new ExtensionInstallPrompt::Prompt(prompt)); 120 prompt_.reset(new ExtensionInstallPrompt::Prompt(prompt));
123 } 121 }
124 return self; 122 return self;
125 } 123 }
126 124
127 - (void)runAsModalSheet { 125 - (void)runAsModalSheet {
128 [NSApp beginSheet:[self window] 126 [NSApp beginSheet:[self window]
129 modalForWindow:parentWindow_ 127 modalForWindow:parentWindow_
130 modalDelegate:self 128 modalDelegate:self
131 didEndSelector:@selector(didEndSheet:returnCode:contextInfo:) 129 didEndSelector:@selector(didEndSheet:returnCode:contextInfo:)
132 contextInfo:nil]; 130 contextInfo:nil];
133 } 131 }
134 132
135 - (IBAction)storeLinkClicked:(id)sender { 133 - (IBAction)storeLinkClicked:(id)sender {
136 GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() + 134 GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() +
137 prompt_->extension()->id()); 135 prompt_->extension()->id());
138 browser_->OpenURL(OpenURLParams( 136 navigator_->OpenURL(OpenURLParams(
139 store_url, Referrer(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, 137 store_url, Referrer(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK,
140 false)); 138 false));
141 139
142 delegate_->InstallUIAbort(/*user_initiated=*/true); 140 delegate_->InstallUIAbort(/*user_initiated=*/true);
143 [NSApp endSheet:[self window]]; 141 [NSApp endSheet:[self window]];
144 } 142 }
145 143
146 - (IBAction)cancel:(id)sender { 144 - (IBAction)cancel:(id)sender {
147 delegate_->InstallUIAbort(/*user_initiated=*/true); 145 delegate_->InstallUIAbort(/*user_initiated=*/true);
148 [NSApp endSheet:[self window]]; 146 [NSApp endSheet:[self window]];
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 309 }
312 NSRect starBounds = NSMakeRect(maxStarRight, 0, 310 NSRect starBounds = NSMakeRect(maxStarRight, 0,
313 skiaImage->width(), skiaImage->height()); 311 skiaImage->width(), skiaImage->height());
314 [view setFrame:starBounds]; 312 [view setFrame:starBounds];
315 [ratingStars_ addSubview:view]; 313 [ratingStars_ addSubview:view];
316 } 314 }
317 315
318 @end // ExtensionInstallDialogController 316 @end // ExtensionInstallDialogController
319 317
320 void ShowExtensionInstallDialogImpl( 318 void ShowExtensionInstallDialogImpl(
321 Browser* browser, 319 gfx::NativeWindow parent,
320 content::PageNavigator* navigator,
322 ExtensionInstallPrompt::Delegate* delegate, 321 ExtensionInstallPrompt::Delegate* delegate,
323 const ExtensionInstallPrompt::Prompt& prompt) { 322 const ExtensionInstallPrompt::Prompt& prompt) {
324 BrowserWindow* window = browser->window();
325 if (!window) {
326 delegate->InstallUIAbort(false);
327 return;
328 }
329
330 gfx::NativeWindow native_window = window->GetNativeWindow();
331
332 ExtensionInstallDialogController* controller = 323 ExtensionInstallDialogController* controller =
333 [[ExtensionInstallDialogController alloc] 324 [[ExtensionInstallDialogController alloc]
334 initWithParentWindow:native_window 325 initWithParentWindow:parent
335 browser:browser 326 navigator:navigator
336 delegate:delegate 327 delegate:delegate
337 prompt:prompt]; 328 prompt:prompt];
338 329
339 // TODO(mihaip): Switch this to be tab-modal (http://crbug.com/95455) 330 // TODO(mihaip): Switch this to be tab-modal (http://crbug.com/95455)
340 [controller runAsModalSheet]; 331 [controller runAsModalSheet];
341 } 332 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698