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

Side by Side Diff: chrome/browser/ui/cocoa/web_intent_bubble_controller.mm

Issue 8351008: [Mac] Added tooltip support for web intent picker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use iterator instead of indexing vector<> Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/web_intent_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/web_intent_bubble_controller.h"
6 6
7 #include "base/memory/scoped_nsobject.h" 7 #include "base/memory/scoped_nsobject.h"
8 #include "chrome/browser/ui/browser_list.h" 8 #include "chrome/browser/ui/browser_list.h"
9 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 9 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
10 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 10 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 [[self bubble] setArrowLocation:info_bubble::kTopLeft]; 75 [[self bubble] setArrowLocation:info_bubble::kTopLeft];
76 [self performLayout]; 76 [self performLayout];
77 [self showWindow:nil]; 77 [self showWindow:nil];
78 picker_->set_controller(self); 78 picker_->set_controller(self);
79 } 79 }
80 80
81 return self; 81 return self;
82 } 82 }
83 83
84 - (void)setServiceURLs:(NSArray*)urls {
85 serviceURLs_.reset([urls retain]);
86
87 if ([iconImages_ count] < [serviceURLs_ count])
88 [iconImages_ setCount:[serviceURLs_ count]];
89
90 [self performLayout];
91 }
92
84 - (void)replaceImageAtIndex:(size_t)index withImage:(NSImage*)image { 93 - (void)replaceImageAtIndex:(size_t)index withImage:(NSImage*)image {
85 if ([iconImages_ count] <= index) 94 if ([iconImages_ count] <= index)
86 [iconImages_ setCount:index + 1]; 95 [iconImages_ setCount:index + 1];
87 96
88 [iconImages_ replacePointerAtIndex:index withPointer:image]; 97 [iconImages_ replacePointerAtIndex:index withPointer:image];
89 [self performLayout]; 98 [self performLayout];
90 } 99 }
91 100
92 // We need to watch for window closing so we can notify up via |picker_|. 101 // We need to watch for window closing so we can notify up via |picker_|.
93 - (void)windowWillClose:(NSNotification*)notification { 102 - (void)windowWillClose:(NSNotification*)notification {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 [cell setBordered:NO]; 234 [cell setBordered:NO];
226 [cell setImage:image]; 235 [cell setImage:image];
227 [cell setImagePosition:NSImageOnly]; 236 [cell setImagePosition:NSImageOnly];
228 [cell setButtonType:NSMomentaryChangeButton]; 237 [cell setButtonType:NSMomentaryChangeButton];
229 [cell setTarget:self]; 238 [cell setTarget:self];
230 [cell setAction:@selector(invokeService:)]; 239 [cell setAction:@selector(invokeService:)];
231 [cell setTag:i]; 240 [cell setTag:i];
232 [cell setEnabled:YES]; 241 [cell setEnabled:YES];
233 242
234 [matrix putCell:cell atRow:(i / iconsPerRow) column:(i % iconsPerRow)]; 243 [matrix putCell:cell atRow:(i / iconsPerRow) column:(i % iconsPerRow)];
244 if (serviceURLs_ && [serviceURLs_ count] >= i)
245 [matrix setToolTip:[serviceURLs_ objectAtIndex:i] forCell:cell];
235 } 246 }
236 247
237 [subviews addObject:matrix]; 248 [subviews addObject:matrix];
238 return NSHeight([matrix frame]); 249 return NSHeight([matrix frame]);
239 } 250 }
240 251
241 // Layout the contents of the picker bubble. 252 // Layout the contents of the picker bubble.
242 - (void)performLayout { 253 - (void)performLayout {
243 // |offset| is the Y position that should be drawn at next. 254 // |offset| is the Y position that should be drawn at next.
244 CGFloat offset = kFramePadding + info_bubble::kBubbleArrowHeight; 255 CGFloat offset = kFramePadding + info_bubble::kBubbleArrowHeight;
(...skipping 12 matching lines...) Expand all
257 NSRect frame = [[self window] frame]; 268 NSRect frame = [[self window] frame];
258 frame.size.height = offset; 269 frame.size.height = offset;
259 frame.size.width = kWindowWidth; 270 frame.size.width = kWindowWidth;
260 [[self window] setFrame:frame display:YES]; 271 [[self window] setFrame:frame display:YES];
261 272
262 // Replace the window's content. 273 // Replace the window's content.
263 [[[self window] contentView] setSubviews:subviews]; 274 [[[self window] contentView] setSubviews:subviews];
264 } 275 }
265 276
266 @end // WebIntentBubbleController 277 @end // WebIntentBubbleController
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/web_intent_bubble_controller.h ('k') | chrome/browser/ui/cocoa/web_intent_picker_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698