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

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

Issue 10883008: Port the Extension Install Bubble changes to Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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_installed_bubble_controlle r.h" 5 #import "chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controlle r.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/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/extensions/api/commands/command_service.h"
13 #include "chrome/browser/extensions/api/commands/command_service_factory.h"
12 #include "chrome/browser/extensions/bundle_installer.h" 14 #include "chrome/browser/extensions/bundle_installer.h"
13 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" 17 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h"
16 #include "chrome/browser/ui/cocoa/browser_window_controller.h" 18 #include "chrome/browser/ui/cocoa/browser_window_controller.h"
17 #include "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" 19 #include "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h"
18 #include "chrome/browser/ui/cocoa/hover_close_button.h" 20 #include "chrome/browser/ui/cocoa/hover_close_button.h"
19 #include "chrome/browser/ui/cocoa/info_bubble_view.h" 21 #include "chrome/browser/ui/cocoa/info_bubble_view.h"
20 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 22 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
21 #include "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 23 #include "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 icon_.reset([gfx::SkBitmapToNSImage(icon) retain]); 105 icon_.reset([gfx::SkBitmapToNSImage(icon) retain]);
104 pageActionRemoved_ = NO; 106 pageActionRemoved_ = NO;
105 107
106 if (bundle_) { 108 if (bundle_) {
107 type_ = extension_installed_bubble::kBundle; 109 type_ = extension_installed_bubble::kBundle;
108 } else if (!extension->omnibox_keyword().empty()) { 110 } else if (!extension->omnibox_keyword().empty()) {
109 type_ = extension_installed_bubble::kOmniboxKeyword; 111 type_ = extension_installed_bubble::kOmniboxKeyword;
110 } else if (extension->browser_action()) { 112 } else if (extension->browser_action()) {
111 type_ = extension_installed_bubble::kBrowserAction; 113 type_ = extension_installed_bubble::kBrowserAction;
112 } else if (extension->page_action() && 114 } else if (extension->page_action() &&
113 !extension->page_action()->default_icon_path().empty()) { 115 (!extension->page_action()->default_icon_path().empty() ||
116 extension->page_action_command())) {
114 type_ = extension_installed_bubble::kPageAction; 117 type_ = extension_installed_bubble::kPageAction;
115 } else { 118 } else {
116 NOTREACHED(); // kGeneric installs handled in extension_install_prompt. 119 NOTREACHED(); // kGeneric installs handled in extension_install_prompt.
117 } 120 }
Nico 2012/08/23 15:42:12 Same here: Is this if() the same in all UI impleme
118 121
119 if (type_ == extension_installed_bubble::kBundle) { 122 if (type_ == extension_installed_bubble::kBundle) {
120 [self showWindow:self]; 123 [self showWindow:self];
121 } else { 124 } else {
122 // Start showing window only after extension has fully loaded. 125 // Start showing window only after extension has fully loaded.
123 extensionObserver_.reset(new ExtensionLoadedNotificationObserver( 126 extensionObserver_.reset(new ExtensionLoadedNotificationObserver(
124 self, browser->profile())); 127 self, browser->profile()));
125 } 128 }
126 } 129 }
127 return self; 130 return self;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 base::i18n::AdjustStringForLocaleDirection(&extension_name); 291 base::i18n::AdjustStringForLocaleDirection(&extension_name);
289 [extensionInstalledMsg_ setStringValue:l10n_util::GetNSStringF( 292 [extensionInstalledMsg_ setStringValue:l10n_util::GetNSStringF(
290 IDS_EXTENSION_INSTALLED_HEADING, extension_name)]; 293 IDS_EXTENSION_INSTALLED_HEADING, extension_name)];
291 [GTMUILocalizerAndLayoutTweaker 294 [GTMUILocalizerAndLayoutTweaker
292 sizeToFitFixedWidthTextField:extensionInstalledMsg_]; 295 sizeToFitFixedWidthTextField:extensionInstalledMsg_];
293 newWindowHeight += [extensionInstalledMsg_ frame].size.height + 296 newWindowHeight += [extensionInstalledMsg_ frame].size.height +
294 extension_installed_bubble::kInnerVerticalMargin; 297 extension_installed_bubble::kInnerVerticalMargin;
295 } 298 }
296 299
297 // If type is page action, include a special message about page actions. 300 // If type is page action, include a special message about page actions.
298 if (type_ == extension_installed_bubble::kPageAction) { 301 if (type_ == extension_installed_bubble::kBrowserAction ||
302 type_ == extension_installed_bubble::kPageAction) {
303 extensions::CommandService* command_service =
304 extensions::CommandServiceFactory::GetForProfile(browser_->profile());
305 if (type_ == extension_installed_bubble::kPageAction) {
306 extensions::Command page_action_command;
307 if (extension_->page_action_command() &&
308 command_service->GetPageActionCommand(
309 extension_->id(),
310 extensions::CommandService::ACTIVE_ONLY,
311 &page_action_command,
312 NULL)) {
313 [extraInfoMsg_ setStringValue:l10n_util::GetNSStringF(
314 IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO_WITH_SHORTCUT,
315 page_action_command.accelerator().GetShortcutText())];
316 }
317 } else {
318 extensions::Command browser_action_command;
319 if (extension_->browser_action_command() &&
320 command_service->GetBrowserActionCommand(
321 extension_->id(),
322 extensions::CommandService::ACTIVE_ONLY,
323 &browser_action_command,
324 NULL)) {
325 [extraInfoMsg_ setStringValue:l10n_util::GetNSStringF(
326 IDS_EXTENSION_INSTALLED_BROWSER_ACTION_INFO_WITH_SHORTCUT,
327 browser_action_command.accelerator().GetShortcutText())];
328 } else {
329 [extraInfoMsg_ setStringValue:l10n_util::GetNSString(
330 IDS_EXTENSION_INSTALLED_BROWSER_ACTION_INFO)];
331 }
332 }
299 [extraInfoMsg_ setHidden:NO]; 333 [extraInfoMsg_ setHidden:NO];
300 [[extraInfoMsg_ cell] 334 [[extraInfoMsg_ cell]
301 setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; 335 setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
302 [GTMUILocalizerAndLayoutTweaker 336 [GTMUILocalizerAndLayoutTweaker
303 sizeToFitFixedWidthTextField:extraInfoMsg_]; 337 sizeToFitFixedWidthTextField:extraInfoMsg_];
304 newWindowHeight += [extraInfoMsg_ frame].size.height + 338 newWindowHeight += [extraInfoMsg_ frame].size.height +
305 extension_installed_bubble::kInnerVerticalMargin; 339 extension_installed_bubble::kInnerVerticalMargin;
306 } 340 }
Nico 2012/08/23 15:42:12 This block is now long and nested. Please extract
Finnur 2012/08/24 12:55:26 Done. On 2012/08/23 15:42:12, Nico wrote:
307 341
308 // If type is omnibox keyword, include a special message about the keyword. 342 // If type is omnibox keyword, include a special message about the keyword.
309 if (type_ == extension_installed_bubble::kOmniboxKeyword) { 343 if (type_ == extension_installed_bubble::kOmniboxKeyword) {
310 [extraInfoMsg_ setStringValue:l10n_util::GetNSStringF( 344 [extraInfoMsg_ setStringValue:l10n_util::GetNSStringF(
311 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO, 345 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO,
312 UTF8ToUTF16(extension_->omnibox_keyword()))]; 346 UTF8ToUTF16(extension_->omnibox_keyword()))];
313 [extraInfoMsg_ setHidden:NO]; 347 [extraInfoMsg_ setHidden:NO];
314 [[extraInfoMsg_ cell] 348 [[extraInfoMsg_ cell]
315 setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; 349 setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
316 [GTMUILocalizerAndLayoutTweaker 350 [GTMUILocalizerAndLayoutTweaker
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 return; 447 return;
414 } 448 }
415 449
416 NSRect extensionMessageFrame1 = [extensionInstalledMsg_ frame]; 450 NSRect extensionMessageFrame1 = [extensionInstalledMsg_ frame];
417 NSRect extensionMessageFrame2 = [extensionInstalledInfoMsg_ frame]; 451 NSRect extensionMessageFrame2 = [extensionInstalledInfoMsg_ frame];
418 452
419 extensionMessageFrame1.origin.y = newWindowHeight - ( 453 extensionMessageFrame1.origin.y = newWindowHeight - (
420 extensionMessageFrame1.size.height + 454 extensionMessageFrame1.size.height +
421 extension_installed_bubble::kOuterVerticalMargin); 455 extension_installed_bubble::kOuterVerticalMargin);
422 [extensionInstalledMsg_ setFrame:extensionMessageFrame1]; 456 [extensionInstalledMsg_ setFrame:extensionMessageFrame1];
423 if (type_ == extension_installed_bubble::kPageAction || 457 if (type_ == extension_installed_bubble::kBrowserAction ||
458 type_ == extension_installed_bubble::kPageAction ||
424 type_ == extension_installed_bubble::kOmniboxKeyword) { 459 type_ == extension_installed_bubble::kOmniboxKeyword) {
Nico 2012/08/23 15:42:12 This again looks like something that should be sha
425 // The extra message is only shown when appropriate. 460 // The extra message is only shown when appropriate.
426 NSRect extraMessageFrame = [extraInfoMsg_ frame]; 461 NSRect extraMessageFrame = [extraInfoMsg_ frame];
427 extraMessageFrame.origin.y = extensionMessageFrame1.origin.y - ( 462 extraMessageFrame.origin.y = extensionMessageFrame1.origin.y - (
428 extraMessageFrame.size.height + 463 extraMessageFrame.size.height +
429 extension_installed_bubble::kInnerVerticalMargin); 464 extension_installed_bubble::kInnerVerticalMargin);
430 [extraInfoMsg_ setFrame:extraMessageFrame]; 465 [extraInfoMsg_ setFrame:extraMessageFrame];
431 extensionMessageFrame2.origin.y = extraMessageFrame.origin.y - ( 466 extensionMessageFrame2.origin.y = extraMessageFrame.origin.y - (
432 extensionMessageFrame2.size.height + 467 extensionMessageFrame2.size.height +
433 extension_installed_bubble::kInnerVerticalMargin); 468 extension_installed_bubble::kInnerVerticalMargin);
434 } else { 469 } else {
(...skipping 15 matching lines...) Expand all
450 485
451 - (NSRect)getExtensionInstalledInfoMsgFrame { 486 - (NSRect)getExtensionInstalledInfoMsgFrame {
452 return [extensionInstalledInfoMsg_ frame]; 487 return [extensionInstalledInfoMsg_ frame];
453 } 488 }
454 489
455 - (void)extensionUnloaded:(id)sender { 490 - (void)extensionUnloaded:(id)sender {
456 extension_ = NULL; 491 extension_ = NULL;
457 } 492 }
458 493
459 @end 494 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698