summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-16 00:26:46 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-16 00:26:46 +0000
commit27747a0cdfaab401f78ef85a92260e6870003554 (patch)
treed7567ccadc3bf13fe4e064398706e828dae334e1 /chrome/browser/cocoa
parenta198033ef997c648246c1ec3bf665a060d595748 (diff)
downloadchromium_src-27747a0cdfaab401f78ef85a92260e6870003554.zip
chromium_src-27747a0cdfaab401f78ef85a92260e6870003554.tar.gz
chromium_src-27747a0cdfaab401f78ef85a92260e6870003554.tar.bz2
Add a help bubble pointing to the omnibox when installing an extension with
an omnibox keyword. BUG=54353 TEST=Install chrome_search from the extension examples folder. You should see a help bubble pointing to the omnibox explaining how to use the omnibox keyword. Review URL: http://codereview.chromium.org/4724005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66197 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/extension_installed_bubble_controller.h10
-rw-r--r--chrome/browser/cocoa/extension_installed_bubble_controller.mm61
-rw-r--r--chrome/browser/cocoa/extension_installed_bubble_controller_unittest.mm4
3 files changed, 53 insertions, 22 deletions
diff --git a/chrome/browser/cocoa/extension_installed_bubble_controller.h b/chrome/browser/cocoa/extension_installed_bubble_controller.h
index e5f50a3..7d0417f 100644
--- a/chrome/browser/cocoa/extension_installed_bubble_controller.h
+++ b/chrome/browser/cocoa/extension_installed_bubble_controller.h
@@ -33,8 +33,9 @@ const int kInnerVerticalMargin = 10;
// We use a different kind of notification for each of these extension types.
typedef enum {
kBrowserAction,
- kPageAction,
- kGeneric
+ kGeneric,
+ kOmniboxKeyword,
+ kPageAction
} ExtensionType;
}
@@ -68,7 +69,8 @@ typedef enum {
IBOutlet HoverCloseButton* closeButton_;
IBOutlet NSImageView* iconImage_;
IBOutlet NSTextField* extensionInstalledMsg_;
- IBOutlet NSTextField* pageActionInfoMsg_; // Only shown for page actions.
+ // Only shown for page actions and omnibox keywords.
+ IBOutlet NSTextField* extraInfoMsg_;
IBOutlet NSTextField* extensionInstalledInfoMsg_;
}
@@ -102,7 +104,7 @@ typedef enum {
- (int)calculateWindowHeight;
- (void)setMessageFrames:(int)newWindowHeight;
- (NSRect)getExtensionInstalledMsgFrame;
-- (NSRect)getPageActionInfoMsgFrame;
+- (NSRect)getExtraInfoMsgFrame;
- (NSRect)getExtensionInstalledInfoMsgFrame;
@end // ExtensionInstalledBubbleController(ExposedForTesting)
diff --git a/chrome/browser/cocoa/extension_installed_bubble_controller.mm b/chrome/browser/cocoa/extension_installed_bubble_controller.mm
index b1263fd..d45ba74 100644
--- a/chrome/browser/cocoa/extension_installed_bubble_controller.mm
+++ b/chrome/browser/cocoa/extension_installed_bubble_controller.mm
@@ -90,7 +90,9 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
icon_.reset([gfx::SkBitmapToNSImage(icon) retain]);
pageActionRemoved_ = NO;
- if (extension->browser_action()) {
+ if (!extension->omnibox_keyword().empty()) {
+ type_ = extension_installed_bubble::kOmniboxKeyword;
+ } else if (extension->browser_action()) {
type_ = extension_installed_bubble::kBrowserAction;
} else if (extension->page_action() &&
!extension->page_action()->default_icon_path().empty()) {
@@ -174,6 +176,12 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
NSPoint arrowPoint = NSZeroPoint;
switch(type_) {
+ case extension_installed_bubble::kOmniboxKeyword: {
+ LocationBarViewMac* locationBarView =
+ [window->cocoa_controller() locationBarBridge];
+ arrowPoint = locationBarView->GetPageInfoBubblePoint();
+ break;
+ }
case extension_installed_bubble::kBrowserAction: {
BrowserActionsController* controller =
[[window->cocoa_controller() toolbarController]
@@ -235,7 +243,8 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
NSSize offsets = NSMakeSize(info_bubble::kBubbleArrowXOffset +
info_bubble::kBubbleArrowWidth / 2.0, 0);
offsets = [[window contentView] convertSize:offsets toView:nil];
- origin.x -= NSWidth([window frame]) - offsets.width;
+ if ([infoBubbleView_ arrowLocation] == info_bubble::kTopRight)
+ origin.x -= NSWidth([window frame]) - offsets.width;
origin.y -= NSHeight([window frame]);
[window setFrameOrigin:origin];
@@ -248,7 +257,12 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
// function is exposed for unit testing.
- (NSWindow*)initializeWindow {
NSWindow* window = [self window]; // completes nib load
- [infoBubbleView_ setArrowLocation:info_bubble::kTopRight];
+
+ if (type_ == extension_installed_bubble::kOmniboxKeyword) {
+ [infoBubbleView_ setArrowLocation:info_bubble::kTopLeft];
+ } else {
+ [infoBubbleView_ setArrowLocation:info_bubble::kTopRight];
+ }
// Set appropriate icon, resizing if necessary.
if ([icon_ size].width > extension_installed_bubble::kIconSize) {
@@ -278,12 +292,26 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
// If type is page action, include a special message about page actions.
if (type_ == extension_installed_bubble::kPageAction) {
- [pageActionInfoMsg_ setHidden:NO];
- [[pageActionInfoMsg_ cell]
+ [extraInfoMsg_ setHidden:NO];
+ [[extraInfoMsg_ cell]
setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
[GTMUILocalizerAndLayoutTweaker
- sizeToFitFixedWidthTextField:pageActionInfoMsg_];
- newWindowHeight += [pageActionInfoMsg_ frame].size.height +
+ sizeToFitFixedWidthTextField:extraInfoMsg_];
+ newWindowHeight += [extraInfoMsg_ frame].size.height +
+ extension_installed_bubble::kInnerVerticalMargin;
+ }
+
+ // If type is omnibox keyword, include a special message about the keyword.
+ if (type_ == extension_installed_bubble::kOmniboxKeyword) {
+ [extraInfoMsg_ setStringValue:l10n_util::GetNSStringF(
+ IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO,
+ UTF8ToUTF16(extension_->omnibox_keyword()))];
+ [extraInfoMsg_ setHidden:NO];
+ [[extraInfoMsg_ cell]
+ setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
+ [GTMUILocalizerAndLayoutTweaker
+ sizeToFitFixedWidthTextField:extraInfoMsg_];
+ newWindowHeight += [extraInfoMsg_ frame].size.height +
extension_installed_bubble::kInnerVerticalMargin;
}
@@ -307,14 +335,15 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
extensionMessageFrame1.size.height +
extension_installed_bubble::kOuterVerticalMargin);
[extensionInstalledMsg_ setFrame:extensionMessageFrame1];
- if (type_ == extension_installed_bubble::kPageAction) {
- // The page action message is only shown when appropriate.
- NSRect pageActionMessageFrame = [pageActionInfoMsg_ frame];
- pageActionMessageFrame.origin.y = extensionMessageFrame1.origin.y - (
- pageActionMessageFrame.size.height +
+ if (type_ == extension_installed_bubble::kPageAction ||
+ type_ == extension_installed_bubble::kOmniboxKeyword) {
+ // The extra message is only shown when appropriate.
+ NSRect extraMessageFrame = [extraInfoMsg_ frame];
+ extraMessageFrame.origin.y = extensionMessageFrame1.origin.y - (
+ extraMessageFrame.size.height +
extension_installed_bubble::kInnerVerticalMargin);
- [pageActionInfoMsg_ setFrame:pageActionMessageFrame];
- extensionMessageFrame2.origin.y = pageActionMessageFrame.origin.y - (
+ [extraInfoMsg_ setFrame:extraMessageFrame];
+ extensionMessageFrame2.origin.y = extraMessageFrame.origin.y - (
extensionMessageFrame2.size.height +
extension_installed_bubble::kInnerVerticalMargin);
} else {
@@ -330,8 +359,8 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
return [extensionInstalledMsg_ frame];
}
-- (NSRect)getPageActionInfoMsgFrame {
- return [pageActionInfoMsg_ frame];
+- (NSRect)getExtraInfoMsgFrame {
+ return [extraInfoMsg_ frame];
}
- (NSRect)getExtensionInstalledInfoMsgFrame {
diff --git a/chrome/browser/cocoa/extension_installed_bubble_controller_unittest.mm b/chrome/browser/cocoa/extension_installed_bubble_controller_unittest.mm
index ad68c85..9113960 100644
--- a/chrome/browser/cocoa/extension_installed_bubble_controller_unittest.mm
+++ b/chrome/browser/cocoa/extension_installed_bubble_controller_unittest.mm
@@ -141,7 +141,7 @@ TEST_F(ExtensionInstalledBubbleControllerTest, PageActionTest) {
2 * extension_installed_bubble::kInnerVerticalMargin +
[controller getExtensionInstalledMsgFrame].size.height +
[controller getExtensionInstalledInfoMsgFrame].size.height +
- [controller getPageActionInfoMsgFrame].size.height;
+ [controller getExtraInfoMsgFrame].size.height;
EXPECT_EQ(height, correctHeight);
[controller setMessageFrames:height];
@@ -149,7 +149,7 @@ TEST_F(ExtensionInstalledBubbleControllerTest, PageActionTest) {
// Bottom message should be kOuterVerticalMargin pixels above window edge.
EXPECT_EQ(msg3Frame.origin.y,
extension_installed_bubble::kOuterVerticalMargin);
- NSRect msg2Frame = [controller getPageActionInfoMsgFrame];
+ NSRect msg2Frame = [controller getExtraInfoMsgFrame];
// Pageaction message should be kInnerVerticalMargin pixels above bottom msg.
EXPECT_EQ(msg2Frame.origin.y,
msg3Frame.origin.y + msg3Frame.size.height +