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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_install_view_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 (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_view_controller.h" 5 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/extensions/bundle_installer.h" 14 #include "chrome/browser/extensions/bundle_installer.h"
15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h"
15 #import "chrome/browser/ui/chrome_style.h" 17 #import "chrome/browser/ui/chrome_style.h"
18 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
16 #include "chrome/common/extensions/extension_constants.h" 19 #include "chrome/common/extensions/extension_constants.h"
17 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
18 #include "content/public/browser/page_navigator.h" 21 #include "content/public/browser/page_navigator.h"
19 #include "extensions/common/extension.h" 22 #include "extensions/common/extension.h"
20 #include "extensions/common/extension_urls.h" 23 #include "extensions/common/extension_urls.h"
21 #include "skia/ext/skia_utils_mac.h" 24 #include "skia/ext/skia_utils_mac.h"
22 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" 25 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h"
23 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" 26 #import "ui/base/cocoa/controls/hyperlink_button_cell.h"
24 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/base/l10n/l10n_util_mac.h" 28 #include "ui/base/l10n/l10n_util_mac.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 @synthesize itemsField = itemsField_; 182 @synthesize itemsField = itemsField_;
180 @synthesize cancelButton = cancelButton_; 183 @synthesize cancelButton = cancelButton_;
181 @synthesize okButton = okButton_; 184 @synthesize okButton = okButton_;
182 @synthesize outlineView = outlineView_; 185 @synthesize outlineView = outlineView_;
183 @synthesize warningsSeparator = warningsSeparator_; 186 @synthesize warningsSeparator = warningsSeparator_;
184 @synthesize ratingStars = ratingStars_; 187 @synthesize ratingStars = ratingStars_;
185 @synthesize ratingCountField = ratingCountField_; 188 @synthesize ratingCountField = ratingCountField_;
186 @synthesize userCountField = userCountField_; 189 @synthesize userCountField = userCountField_;
187 @synthesize storeLinkButton = storeLinkButton_; 190 @synthesize storeLinkButton = storeLinkButton_;
188 191
189 - (id)initWithNavigator:(content::PageNavigator*)navigator 192 - (id)initWithProfile:(Profile*)profile
190 delegate:(ExtensionInstallPrompt::Delegate*)delegate 193 navigator:(content::PageNavigator*)navigator
191 prompt:(scoped_refptr<ExtensionInstallPrompt::Prompt>)prompt { 194 delegate:(ExtensionInstallPrompt::Delegate*)delegate
195 prompt:(scoped_refptr<ExtensionInstallPrompt::Prompt>)prompt {
192 // We use a different XIB in the case of bundle installs, installs with 196 // We use a different XIB in the case of bundle installs, installs with
193 // webstore data, or no permission warnings. These are laid out nicely for 197 // webstore data, or no permission warnings. These are laid out nicely for
194 // the data they display. 198 // the data they display.
195 NSString* nibName = nil; 199 NSString* nibName = nil;
196 if (prompt->type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT) { 200 if (prompt->type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT) {
197 nibName = @"ExtensionInstallPromptBundle"; 201 nibName = @"ExtensionInstallPromptBundle";
198 } else if (prompt->has_webstore_data()) { 202 } else if (prompt->has_webstore_data()) {
199 nibName = @"ExtensionInstallPromptWebstoreData"; 203 nibName = @"ExtensionInstallPromptWebstoreData";
200 } else if (!prompt->ShouldShowPermissions() && 204 } else if (!prompt->ShouldShowPermissions() &&
201 prompt->GetRetainedFileCount() == 0 && 205 prompt->GetRetainedFileCount() == 0 &&
202 prompt->GetRetainedDeviceCount() == 0) { 206 prompt->GetRetainedDeviceCount() == 0) {
203 nibName = @"ExtensionInstallPromptNoWarnings"; 207 nibName = @"ExtensionInstallPromptNoWarnings";
204 } else { 208 } else {
205 nibName = @"ExtensionInstallPrompt"; 209 nibName = @"ExtensionInstallPrompt";
206 } 210 }
207 211
208 if ((self = [super initWithNibName:nibName 212 if ((self = [super initWithNibName:nibName
209 bundle:base::mac::FrameworkBundle()])) { 213 bundle:base::mac::FrameworkBundle()])) {
214 profile_ = profile;
210 navigator_ = navigator; 215 navigator_ = navigator;
211 delegate_ = delegate; 216 delegate_ = delegate;
212 prompt_ = prompt; 217 prompt_ = prompt;
213 warnings_.reset([[self buildWarnings:*prompt] retain]); 218 warnings_.reset([[self buildWarnings:*prompt] retain]);
214 } 219 }
215 return self; 220 return self;
216 } 221 }
217 222
218 - (IBAction)storeLinkClicked:(id)sender { 223 - (IBAction)storeLinkClicked:(id)sender {
219 GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() + 224 GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() +
220 prompt_->extension()->id()); 225 prompt_->extension()->id());
221 navigator_->OpenURL(OpenURLParams( 226 OpenURLParams params(store_url, Referrer(), NEW_FOREGROUND_TAB,
222 store_url, Referrer(), NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, 227 ui::PAGE_TRANSITION_LINK, false);
223 false)); 228 if (navigator_) {
229 navigator_->OpenURL(params);
230 } else {
231 chrome::ScopedTabbedBrowserDisplayer displayer(
232 profile_, chrome::GetActiveDesktop());
233 displayer.browser()->OpenURL(params);
234 }
224 235
225 delegate_->InstallUIAbort(/*user_initiated=*/true); 236 delegate_->InstallUIAbort(/*user_initiated=*/true);
226 } 237 }
227 238
228 - (IBAction)cancel:(id)sender { 239 - (IBAction)cancel:(id)sender {
229 delegate_->InstallUIAbort(/*user_initiated=*/true); 240 delegate_->InstallUIAbort(/*user_initiated=*/true);
230 } 241 }
231 242
232 - (IBAction)ok:(id)sender { 243 - (IBAction)ok:(id)sender {
233 delegate_->InstallUIProceed(); 244 delegate_->InstallUIProceed();
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 } 814 }
804 815
805 - (void)accessibilityPerformAction:(NSString*)action { 816 - (void)accessibilityPerformAction:(NSString*)action {
806 if ([action isEqualToString:NSAccessibilityPressAction]) 817 if ([action isEqualToString:NSAccessibilityPressAction])
807 [self handleLinkClicked]; 818 [self handleLinkClicked];
808 else 819 else
809 [super accessibilityPerformAction:action]; 820 [super accessibilityPerformAction:action];
810 } 821 }
811 822
812 @end 823 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698