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

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: . Created 8 years, 11 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 cellClass:[NSImageCell class] 230 cellClass:[NSImageCell class]
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 DCHECK(image != NULL);
244 image = defaultIcon_;
245 241
246 // Set cell styles so it acts as image button. 242 // Set cell styles so it acts as image button.
247 [cell setBordered:NO]; 243 [cell setBordered:NO];
248 [cell setImage:image]; 244 [cell setImage:image];
249 [cell setImagePosition:NSImageOnly]; 245 [cell setImagePosition:NSImageOnly];
250 [cell setButtonType:NSMomentaryChangeButton]; 246 [cell setButtonType:NSMomentaryChangeButton];
251 [cell setTarget:self]; 247 [cell setTarget:self];
252 [cell setAction:@selector(invokeService:)]; 248 [cell setAction:@selector(invokeService:)];
253 [cell setTag:i]; 249 [cell setTag:i];
254 [cell setEnabled:YES]; 250 [cell setEnabled:YES];
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 windowFrame.origin.y -= NSHeight(windowFrame) - 303 windowFrame.origin.y -= NSHeight(windowFrame) -
308 NSHeight([[self window] frame]); 304 NSHeight([[self window] frame]);
309 305
310 [[self window] setFrame:windowFrame display:YES animate:YES]; 306 [[self window] setFrame:windowFrame display:YES animate:YES];
311 307
312 // Replace the window's content. 308 // Replace the window's content.
313 [[[self window] contentView] setSubviews:subviews]; 309 [[[self window] contentView] setSubviews:subviews];
314 } 310 }
315 311
316 @end // WebIntentBubbleController 312 @end // WebIntentBubbleController
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698