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

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

Issue 9148032: [Web Intents] Refactor picker to use WebIntentPickerModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: groby's fix Created 8 years, 10 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/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/hyperlink_button_cell.h" 9 #import "chrome/browser/ui/cocoa/hyperlink_button_cell.h"
10 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 10 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 backing:NSBackingStoreBuffered 68 backing:NSBackingStoreBuffered
69 defer:NO]); 69 defer:NO]);
70 if ((self = [super initWithWindow:window.get() 70 if ((self = [super initWithWindow:window.get()
71 parentWindow:parent 71 parentWindow:parent
72 anchoredAt:point])) { 72 anchoredAt:point])) {
73 picker_ = picker; 73 picker_ = picker;
74 iconImages_.reset([[NSPointerArray alloc] initWithOptions: 74 iconImages_.reset([[NSPointerArray alloc] initWithOptions:
75 NSPointerFunctionsStrongMemory | 75 NSPointerFunctionsStrongMemory |
76 NSPointerFunctionsObjectPersonality]); 76 NSPointerFunctionsObjectPersonality]);
77 77
78 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
79 defaultIcon_.reset([rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON) retain]);
80
81 [[self bubble] setArrowLocation:info_bubble::kTopLeft]; 78 [[self bubble] setArrowLocation:info_bubble::kTopLeft];
82 [self performLayout]; 79 [self performLayout];
83 [self showWindow:nil]; 80 [self showWindow:nil];
84 picker_->set_controller(self); 81 picker_->set_controller(self);
85 } 82 }
86 83
87 return self; 84 return self;
88 } 85 }
89 86
90 - (void)setServiceURLs:(NSArray*)urls { 87 - (void)setServiceURLs:(NSArray*)urls {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 numberOfRows:numRows 231 numberOfRows:numRows
235 numberOfColumns:iconsPerRow]); 232 numberOfColumns:iconsPerRow]);
236 233
237 [matrix setCellSize:NSMakeSize(kImageSize,kImageSize)]; 234 [matrix setCellSize:NSMakeSize(kImageSize,kImageSize)];
238 [matrix setIntercellSpacing:NSMakeSize(kImagePadding,kImagePadding)]; 235 [matrix setIntercellSpacing:NSMakeSize(kImagePadding,kImagePadding)];
239 236
240 for (NSUInteger i = 0; i < [iconImages_ count]; ++i) { 237 for (NSUInteger i = 0; i < [iconImages_ count]; ++i) {
241 scoped_nsobject<NSButtonCell> cell([[NSButtonCell alloc] init]); 238 scoped_nsobject<NSButtonCell> cell([[NSButtonCell alloc] init]);
242 NSImage* image = static_cast<NSImage*>([iconImages_ pointerAtIndex:i]); 239 NSImage* image = static_cast<NSImage*>([iconImages_ pointerAtIndex:i]);
243 if (!image) 240 if (!image)
244 image = defaultIcon_; 241 continue;
245 242
246 // Set cell styles so it acts as image button. 243 // Set cell styles so it acts as image button.
247 [cell setBordered:NO]; 244 [cell setBordered:NO];
248 [cell setImage:image]; 245 [cell setImage:image];
249 [cell setImagePosition:NSImageOnly]; 246 [cell setImagePosition:NSImageOnly];
250 [cell setButtonType:NSMomentaryChangeButton]; 247 [cell setButtonType:NSMomentaryChangeButton];
251 [cell setTarget:self]; 248 [cell setTarget:self];
252 [cell setAction:@selector(invokeService:)]; 249 [cell setAction:@selector(invokeService:)];
253 [cell setTag:i]; 250 [cell setTag:i];
254 [cell setEnabled:YES]; 251 [cell setEnabled:YES];
255 252
256 [matrix putCell:cell atRow:(i / iconsPerRow) column:(i % iconsPerRow)]; 253 [matrix putCell:cell atRow:(i / iconsPerRow) column:(i % iconsPerRow)];
257 if (serviceURLs_ && [serviceURLs_ count] >= i) 254 if (serviceURLs_ && i < [serviceURLs_ count])
258 [matrix setToolTip:[serviceURLs_ objectAtIndex:i] forCell:cell]; 255 [matrix setToolTip:[serviceURLs_ objectAtIndex:i] forCell:cell];
259 } 256 }
260 257
261 [subviews addObject:matrix]; 258 [subviews addObject:matrix];
262 return NSHeight([matrix frame]); 259 return NSHeight([matrix frame]);
263 } 260 }
264 261
265 - (CGFloat)addInlineHtmlToSubviews:(NSMutableArray*)subviews 262 - (CGFloat)addInlineHtmlToSubviews:(NSMutableArray*)subviews
266 atOffset:(CGFloat)offset { 263 atOffset:(CGFloat)offset {
267 if (!contents_) 264 if (!contents_)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 windowFrame.origin.y -= NSHeight(windowFrame) - 304 windowFrame.origin.y -= NSHeight(windowFrame) -
308 NSHeight([[self window] frame]); 305 NSHeight([[self window] frame]);
309 306
310 [[self window] setFrame:windowFrame display:YES animate:YES]; 307 [[self window] setFrame:windowFrame display:YES animate:YES];
311 308
312 // Replace the window's content. 309 // Replace the window's content.
313 [[[self window] contentView] setSubviews:subviews]; 310 [[[self window] contentView] setSubviews:subviews];
314 } 311 }
315 312
316 @end // WebIntentBubbleController 313 @end // WebIntentBubbleController
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698