| OLD | NEW |
| 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" | 12 #include "chrome/browser/extensions/api/commands/command_service.h" |
| 13 #include "chrome/browser/extensions/api/commands/command_service_factory.h" | 13 #include "chrome/browser/extensions/api/commands/command_service_factory.h" |
| 14 #include "chrome/browser/extensions/bundle_installer.h" | 14 #include "chrome/browser/extensions/bundle_installer.h" |
| 15 #include "chrome/browser/extensions/extension_action.h" | 15 #include "chrome/browser/extensions/extension_action.h" |
| 16 #include "chrome/browser/extensions/extension_action_manager.h" | 16 #include "chrome/browser/extensions/extension_action_manager.h" |
| 17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_navigator.h" | 18 #include "chrome/browser/ui/browser_navigator.h" |
| 19 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
| 20 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 20 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| 21 #include "chrome/browser/ui/cocoa/browser_window_controller.h" | 21 #include "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 22 #include "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" | 22 #include "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
| 23 #include "chrome/browser/ui/cocoa/hover_close_button.h" | 23 #include "chrome/browser/ui/cocoa/hover_close_button.h" |
| 24 #include "chrome/browser/ui/cocoa/info_bubble_view.h" | 24 #include "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 25 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 25 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 26 #include "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 26 #include "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 27 #include "chrome/browser/ui/singleton_tabs.h" | 27 #include "chrome/browser/ui/singleton_tabs.h" |
| 28 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
| 29 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" |
| 29 #include "chrome/common/extensions/extension.h" | 30 #include "chrome/common/extensions/extension.h" |
| 30 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
| 31 #include "content/public/browser/notification_details.h" | 32 #include "content/public/browser/notification_details.h" |
| 32 #include "content/public/browser/notification_registrar.h" | 33 #include "content/public/browser/notification_registrar.h" |
| 33 #include "content/public/browser/notification_source.h" | 34 #include "content/public/browser/notification_source.h" |
| 34 #include "grit/chromium_strings.h" | 35 #include "grit/chromium_strings.h" |
| 35 #include "grit/generated_resources.h" | 36 #include "grit/generated_resources.h" |
| 36 #import "skia/ext/skia_utils_mac.h" | 37 #import "skia/ext/skia_utils_mac.h" |
| 37 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" | 38 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" |
| 38 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 DCHECK(browser); | 110 DCHECK(browser); |
| 110 browser_ = browser; | 111 browser_ = browser; |
| 111 icon_.reset([gfx::SkBitmapToNSImage(icon) retain]); | 112 icon_.reset([gfx::SkBitmapToNSImage(icon) retain]); |
| 112 pageActionPreviewShowing_ = NO; | 113 pageActionPreviewShowing_ = NO; |
| 113 | 114 |
| 114 extensions::ExtensionActionManager* extension_action_manager = | 115 extensions::ExtensionActionManager* extension_action_manager = |
| 115 extensions::ExtensionActionManager::Get(browser_->profile()); | 116 extensions::ExtensionActionManager::Get(browser_->profile()); |
| 116 | 117 |
| 117 if (bundle_) { | 118 if (bundle_) { |
| 118 type_ = extension_installed_bubble::kBundle; | 119 type_ = extension_installed_bubble::kBundle; |
| 119 } else if (!extension->omnibox_keyword().empty()) { | 120 } else if (!extensions::OmniboxInfo::GetKeyword(extension).empty()) { |
| 120 type_ = extension_installed_bubble::kOmniboxKeyword; | 121 type_ = extension_installed_bubble::kOmniboxKeyword; |
| 121 } else if (extension_action_manager->GetBrowserAction(*extension)) { | 122 } else if (extension_action_manager->GetBrowserAction(*extension)) { |
| 122 type_ = extension_installed_bubble::kBrowserAction; | 123 type_ = extension_installed_bubble::kBrowserAction; |
| 123 } else if (extension_action_manager->GetPageAction(*extension) && | 124 } else if (extension_action_manager->GetPageAction(*extension) && |
| 124 extension->is_verbose_install_message()) { | 125 extensions::OmniboxInfo::IsVerboseInstallMessage(extension)) { |
| 125 type_ = extension_installed_bubble::kPageAction; | 126 type_ = extension_installed_bubble::kPageAction; |
| 126 } else { | 127 } else { |
| 127 type_ = extension_installed_bubble::kGeneric; | 128 type_ = extension_installed_bubble::kGeneric; |
| 128 } | 129 } |
| 129 | 130 |
| 130 if (type_ == extension_installed_bubble::kBundle) { | 131 if (type_ == extension_installed_bubble::kBundle) { |
| 131 [self showWindow:self]; | 132 [self showWindow:self]; |
| 132 } else { | 133 } else { |
| 133 // Start showing window only after extension has fully loaded. | 134 // Start showing window only after extension has fully loaded. |
| 134 extensionObserver_.reset(new ExtensionLoadedNotificationObserver( | 135 extensionObserver_.reset(new ExtensionLoadedNotificationObserver( |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 [GTMUILocalizerAndLayoutTweaker | 384 [GTMUILocalizerAndLayoutTweaker |
| 384 sizeToFitFixedWidthTextField:extraInfoMsg_]; | 385 sizeToFitFixedWidthTextField:extraInfoMsg_]; |
| 385 newWindowHeight += [extraInfoMsg_ frame].size.height + | 386 newWindowHeight += [extraInfoMsg_ frame].size.height + |
| 386 extension_installed_bubble::kInnerVerticalMargin; | 387 extension_installed_bubble::kInnerVerticalMargin; |
| 387 } | 388 } |
| 388 | 389 |
| 389 // If type is omnibox keyword, include a special message about the keyword. | 390 // If type is omnibox keyword, include a special message about the keyword. |
| 390 if (type_ == extension_installed_bubble::kOmniboxKeyword) { | 391 if (type_ == extension_installed_bubble::kOmniboxKeyword) { |
| 391 [extraInfoMsg_ setStringValue:l10n_util::GetNSStringF( | 392 [extraInfoMsg_ setStringValue:l10n_util::GetNSStringF( |
| 392 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO, | 393 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO, |
| 393 UTF8ToUTF16(extension_->omnibox_keyword()))]; | 394 UTF8ToUTF16(extensions::OmniboxInfo::GetKeyword(extension_)))]; |
| 394 [extraInfoMsg_ setHidden:NO]; | 395 [extraInfoMsg_ setHidden:NO]; |
| 395 [[extraInfoMsg_ cell] | 396 [[extraInfoMsg_ cell] |
| 396 setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; | 397 setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; |
| 397 [GTMUILocalizerAndLayoutTweaker | 398 [GTMUILocalizerAndLayoutTweaker |
| 398 sizeToFitFixedWidthTextField:extraInfoMsg_]; | 399 sizeToFitFixedWidthTextField:extraInfoMsg_]; |
| 399 newWindowHeight += [extraInfoMsg_ frame].size.height + | 400 newWindowHeight += [extraInfoMsg_ frame].size.height + |
| 400 extension_installed_bubble::kInnerVerticalMargin; | 401 extension_installed_bubble::kInnerVerticalMargin; |
| 401 } | 402 } |
| 402 | 403 |
| 403 // If type is bundle, list the extensions that were installed and those that | 404 // If type is bundle, list the extensions that were installed and those that |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 return; | 507 return; |
| 507 } | 508 } |
| 508 | 509 |
| 509 NSRect extensionMessageFrame1 = [extensionInstalledMsg_ frame]; | 510 NSRect extensionMessageFrame1 = [extensionInstalledMsg_ frame]; |
| 510 NSRect extensionMessageFrame2 = [extensionInstalledInfoMsg_ frame]; | 511 NSRect extensionMessageFrame2 = [extensionInstalledInfoMsg_ frame]; |
| 511 | 512 |
| 512 extensionMessageFrame1.origin.y = newWindowHeight - ( | 513 extensionMessageFrame1.origin.y = newWindowHeight - ( |
| 513 extensionMessageFrame1.size.height + | 514 extensionMessageFrame1.size.height + |
| 514 extension_installed_bubble::kOuterVerticalMargin); | 515 extension_installed_bubble::kOuterVerticalMargin); |
| 515 [extensionInstalledMsg_ setFrame:extensionMessageFrame1]; | 516 [extensionInstalledMsg_ setFrame:extensionMessageFrame1]; |
| 516 if (extension_->is_verbose_install_message()) { | 517 if (extensions::OmniboxInfo::IsVerboseInstallMessage(extension_)) { |
| 517 // The extra message is only shown when appropriate. | 518 // The extra message is only shown when appropriate. |
| 518 NSRect extraMessageFrame = [extraInfoMsg_ frame]; | 519 NSRect extraMessageFrame = [extraInfoMsg_ frame]; |
| 519 extraMessageFrame.origin.y = extensionMessageFrame1.origin.y - ( | 520 extraMessageFrame.origin.y = extensionMessageFrame1.origin.y - ( |
| 520 extraMessageFrame.size.height + | 521 extraMessageFrame.size.height + |
| 521 extension_installed_bubble::kInnerVerticalMargin); | 522 extension_installed_bubble::kInnerVerticalMargin); |
| 522 [extraInfoMsg_ setFrame:extraMessageFrame]; | 523 [extraInfoMsg_ setFrame:extraMessageFrame]; |
| 523 extensionMessageFrame2.origin.y = extraMessageFrame.origin.y - ( | 524 extensionMessageFrame2.origin.y = extraMessageFrame.origin.y - ( |
| 524 extensionMessageFrame2.size.height + | 525 extensionMessageFrame2.size.height + |
| 525 extension_installed_bubble::kInnerVerticalMargin); | 526 extension_installed_bubble::kInnerVerticalMargin); |
| 526 } else { | 527 } else { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 - (IBAction)onManageShortcutClicked:(id)sender { | 564 - (IBAction)onManageShortcutClicked:(id)sender { |
| 564 [self close]; | 565 [self close]; |
| 565 std::string configure_url = chrome::kChromeUIExtensionsURL; | 566 std::string configure_url = chrome::kChromeUIExtensionsURL; |
| 566 configure_url += chrome::kExtensionConfigureCommandsSubPage; | 567 configure_url += chrome::kExtensionConfigureCommandsSubPage; |
| 567 chrome::NavigateParams params(chrome::GetSingletonTabNavigateParams( | 568 chrome::NavigateParams params(chrome::GetSingletonTabNavigateParams( |
| 568 browser_, GURL(configure_url))); | 569 browser_, GURL(configure_url))); |
| 569 chrome::Navigate(¶ms); | 570 chrome::Navigate(¶ms); |
| 570 } | 571 } |
| 571 | 572 |
| 572 @end | 573 @end |
| OLD | NEW |