Commit 374b33fb authored by groby@chromium.org's avatar groby@chromium.org

[Mac] Added tooltip support for web intent picker

BUG=none
TEST=none


Review URL: http://codereview.chromium.org/8351008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107840 0039d316-1c4b-4281-b951-d872f2087c98
parent 3fd04007
...@@ -25,6 +25,9 @@ class WebIntentPickerCocoa; ...@@ -25,6 +25,9 @@ class WebIntentPickerCocoa;
// Images for all icons shown in bubble. // Images for all icons shown in bubble.
scoped_nsobject<NSPointerArray> iconImages_; scoped_nsobject<NSPointerArray> iconImages_;
// URLs associated with the individual services.
scoped_nsobject<NSArray> serviceURLs_;
// Default icon to use if no icon is specified. // Default icon to use if no icon is specified.
scoped_nsobject<NSImage> defaultIcon_; scoped_nsobject<NSImage> defaultIcon_;
...@@ -40,6 +43,9 @@ class WebIntentPickerCocoa; ...@@ -40,6 +43,9 @@ class WebIntentPickerCocoa;
// Replaces the |image| for service at |index|. // Replaces the |image| for service at |index|.
- (void)replaceImageAtIndex:(size_t)index withImage:(NSImage*)image; - (void)replaceImageAtIndex:(size_t)index withImage:(NSImage*)image;
// Set the service |urls| for all services.
- (void)setServiceURLs:(NSArray*)urls;
@end // WebIntentBubbleController @end // WebIntentBubbleController
#endif // CHROME_BROWSER_UI_COCOA_WEB_INTENT_BUBBLE_CONTROLLER_H_ #endif // CHROME_BROWSER_UI_COCOA_WEB_INTENT_BUBBLE_CONTROLLER_H_
...@@ -81,6 +81,15 @@ const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing + ...@@ -81,6 +81,15 @@ const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing +
return self; return self;
} }
- (void)setServiceURLs:(NSArray*)urls {
serviceURLs_.reset([urls retain]);
if ([iconImages_ count] < [serviceURLs_ count])
[iconImages_ setCount:[serviceURLs_ count]];
[self performLayout];
}
- (void)replaceImageAtIndex:(size_t)index withImage:(NSImage*)image { - (void)replaceImageAtIndex:(size_t)index withImage:(NSImage*)image {
if ([iconImages_ count] <= index) if ([iconImages_ count] <= index)
[iconImages_ setCount:index + 1]; [iconImages_ setCount:index + 1];
...@@ -232,6 +241,8 @@ const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing + ...@@ -232,6 +241,8 @@ const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing +
[cell setEnabled:YES]; [cell setEnabled:YES];
[matrix putCell:cell atRow:(i / iconsPerRow) column:(i % iconsPerRow)]; [matrix putCell:cell atRow:(i / iconsPerRow) column:(i % iconsPerRow)];
if (serviceURLs_ && [serviceURLs_ count] >= i)
[matrix setToolTip:[serviceURLs_ objectAtIndex:i] forCell:cell];
} }
[subviews addObject:matrix]; [subviews addObject:matrix];
......
...@@ -46,6 +46,17 @@ WebIntentPickerCocoa::WebIntentPickerCocoa(Browser* browser, ...@@ -46,6 +46,17 @@ WebIntentPickerCocoa::WebIntentPickerCocoa(Browser* browser,
} }
void WebIntentPickerCocoa::SetServiceURLs(const std::vector<GURL>& urls) { void WebIntentPickerCocoa::SetServiceURLs(const std::vector<GURL>& urls) {
DCHECK(controller_);
scoped_nsobject<NSMutableArray> urlArray(
[[NSMutableArray alloc] initWithCapacity:urls.size()]);
for (std::vector<GURL>::const_iterator iter(urls.begin());
iter != urls.end(); ++iter) {
[urlArray addObject:
[NSString stringWithUTF8String:iter->spec().c_str()]];
}
[controller_ setServiceURLs:urlArray];
} }
void WebIntentPickerCocoa::SetServiceIcon(size_t index, const SkBitmap& icon) { void WebIntentPickerCocoa::SetServiceIcon(size_t index, const SkBitmap& icon) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment