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

Side by Side Diff: chrome/browser/cocoa/bookmark_bubble_controller.mm

Issue 1540009: [Mac] Move star button into page-actions area of omnibox. (Closed)
Patch Set: Why did the trybot fail? I can't see anything. Created 10 years, 8 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/cocoa/bookmark_bubble_controller.h" 5 #import "chrome/browser/cocoa/bookmark_bubble_controller.h"
6 #include "app/l10n_util_mac.h" 6 #include "app/l10n_util_mac.h"
7 #include "base/mac_util.h" 7 #include "base/mac_util.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #include "chrome/browser/bookmarks/bookmark_model.h" 9 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #import "chrome/browser/cocoa/info_bubble_view.h"
10 #include "chrome/browser/metrics/user_metrics.h" 11 #include "chrome/browser/metrics/user_metrics.h"
11 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
12 13
13 // An object to represent the ChooseAnotherFolder item in the pop up. 14 // An object to represent the ChooseAnotherFolder item in the pop up.
14 @interface ChooseAnotherFolder : NSObject 15 @interface ChooseAnotherFolder : NSObject
15 @end 16 @end
16 17
17 @implementation ChooseAnotherFolder 18 @implementation ChooseAnotherFolder
18 @end 19 @end
19 20
(...skipping 11 matching lines...) Expand all
31 // Singleton object to act as a representedObject for the "choose another 32 // Singleton object to act as a representedObject for the "choose another
32 // folder" item in the pop up. 33 // folder" item in the pop up.
33 static ChooseAnotherFolder* object = nil; 34 static ChooseAnotherFolder* object = nil;
34 if (!object) { 35 if (!object) {
35 object = [[ChooseAnotherFolder alloc] init]; 36 object = [[ChooseAnotherFolder alloc] init];
36 } 37 }
37 return object; 38 return object;
38 } 39 }
39 40
40 - (id)initWithParentWindow:(NSWindow*)parentWindow 41 - (id)initWithParentWindow:(NSWindow*)parentWindow
41 topLeftForBubble:(NSPoint)topLeftForBubble 42 topRightForBubble:(NSPoint)topRightForBubble
42 model:(BookmarkModel*)model 43 model:(BookmarkModel*)model
43 node:(const BookmarkNode*)node 44 node:(const BookmarkNode*)node
44 alreadyBookmarked:(BOOL)alreadyBookmarked { 45 alreadyBookmarked:(BOOL)alreadyBookmarked {
45 NSString* nibPath = 46 NSString* nibPath =
46 [mac_util::MainAppBundle() pathForResource:@"BookmarkBubble" 47 [mac_util::MainAppBundle() pathForResource:@"BookmarkBubble"
47 ofType:@"nib"]; 48 ofType:@"nib"];
48 if ((self = [super initWithWindowNibPath:nibPath owner:self])) { 49 if ((self = [super initWithWindowNibPath:nibPath owner:self])) {
49 parentWindow_ = parentWindow; 50 parentWindow_ = parentWindow;
50 topLeftForBubble_ = topLeftForBubble; 51 topRightForBubble_ = topRightForBubble;
51 model_ = model; 52 model_ = model;
52 node_ = node; 53 node_ = node;
53 alreadyBookmarked_ = alreadyBookmarked; 54 alreadyBookmarked_ = alreadyBookmarked;
54 55
55 // Watch to see if the parent window closes, and if so, close this one. 56 // Watch to see if the parent window closes, and if so, close this one.
56 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 57 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
57 [center addObserver:self 58 [center addObserver:self
58 selector:@selector(parentWindowWillClose:) 59 selector:@selector(parentWindowWillClose:)
59 name:NSWindowWillCloseNotification 60 name:NSWindowWillCloseNotification
60 object:parentWindow_]; 61 object:parentWindow_];
(...skipping 27 matching lines...) Expand all
88 } 89 }
89 90
90 // We want this to be a child of a browser window. addChildWindow: 91 // We want this to be a child of a browser window. addChildWindow:
91 // (called from this function) will bring the window on-screen; 92 // (called from this function) will bring the window on-screen;
92 // unfortunately, [NSWindowController showWindow:] will also bring it 93 // unfortunately, [NSWindowController showWindow:] will also bring it
93 // on-screen (but will cause unexpected changes to the window's 94 // on-screen (but will cause unexpected changes to the window's
94 // position). We cannot have an addChildWindow: and a subsequent 95 // position). We cannot have an addChildWindow: and a subsequent
95 // showWindow:. Thus, we have our own version. 96 // showWindow:. Thus, we have our own version.
96 - (void)showWindow:(id)sender { 97 - (void)showWindow:(id)sender {
97 NSWindow* window = [self window]; // completes nib load 98 NSWindow* window = [self window]; // completes nib load
98 NSPoint origin = [parentWindow_ convertBaseToScreen:topLeftForBubble_]; 99 NSPoint origin = [parentWindow_ convertBaseToScreen:topRightForBubble_];
99 origin.y -= NSHeight([window frame]); 100 origin.y -= NSHeight([window frame]);
101 origin.x -= NSWidth([window frame]);
100 [window setFrameOrigin:origin]; 102 [window setFrameOrigin:origin];
103 [bubble_ setArrowLocation:kTopRight];
101 [parentWindow_ addChildWindow:window ordered:NSWindowAbove]; 104 [parentWindow_ addChildWindow:window ordered:NSWindowAbove];
102 // Default is IDS_BOOMARK_BUBBLE_PAGE_BOOKMARK; "Bookmark". 105 // Default is IDS_BOOMARK_BUBBLE_PAGE_BOOKMARK; "Bookmark".
103 // If adding for the 1st time the string becomes "Bookmark Added!" 106 // If adding for the 1st time the string becomes "Bookmark Added!"
104 if (!alreadyBookmarked_) { 107 if (!alreadyBookmarked_) {
105 NSString* title = 108 NSString* title =
106 l10n_util::GetNSString(IDS_BOOMARK_BUBBLE_PAGE_BOOKMARKED); 109 l10n_util::GetNSString(IDS_BOOMARK_BUBBLE_PAGE_BOOKMARKED);
107 [bigTitle_ setStringValue:title]; 110 [bigTitle_ setStringValue:title];
108 } 111 }
109 112
110 [self fillInFolderList]; 113 [self fillInFolderList];
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; 308 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue];
306 DCHECK(idx != -1); 309 DCHECK(idx != -1);
307 [folderPopUpButton_ selectItemAtIndex:idx]; 310 [folderPopUpButton_ selectItemAtIndex:idx];
308 } 311 }
309 312
310 - (NSPopUpButton*)folderPopUpButton { 313 - (NSPopUpButton*)folderPopUpButton {
311 return folderPopUpButton_; 314 return folderPopUpButton_;
312 } 315 }
313 316
314 @end // implementation BookmarkBubbleController(ExposedForUnitTesting) 317 @end // implementation BookmarkBubbleController(ExposedForUnitTesting)
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_bubble_controller.h ('k') | chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698