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

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

Issue 171016: Bookmark STAR bubble (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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) 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 #include <Carbon/Carbon.h> 5 #include <Carbon/Carbon.h>
6 6
7 #include "base/mac_util.h" 7 #include "base/mac_util.h"
8 #include "base/scoped_nsdisable_screen_updates.h" 8 #include "base/scoped_nsdisable_screen_updates.h"
9 #import "base/scoped_nsobject.h" 9 #import "base/scoped_nsobject.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
11 #include "chrome/app/chrome_dll_resource.h" // IDC_* 11 #include "chrome/app/chrome_dll_resource.h" // IDC_*
12 #include "chrome/browser/bookmarks/bookmark_editor.h"
12 #include "chrome/browser/browser.h" 13 #include "chrome/browser/browser.h"
13 #include "chrome/browser/browser_list.h" 14 #include "chrome/browser/browser_list.h"
14 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/encoding_menu_controller.h" 16 #include "chrome/browser/encoding_menu_controller.h"
16 #include "chrome/browser/location_bar.h" 17 #include "chrome/browser/location_bar.h"
17 #include "chrome/browser/profile.h" 18 #include "chrome/browser/profile.h"
18 #include "chrome/browser/renderer_host/render_widget_host_view.h" 19 #include "chrome/browser/renderer_host/render_widget_host_view.h"
19 #include "chrome/browser/tab_contents/tab_contents.h" 20 #include "chrome/browser/tab_contents/tab_contents.h"
20 #include "chrome/browser/tab_contents/tab_contents_view.h" 21 #include "chrome/browser/tab_contents/tab_contents_view.h"
21 #include "chrome/browser/tabs/tab_strip_model.h" 22 #include "chrome/browser/tabs/tab_strip_model.h"
22 #import "chrome/browser/cocoa/bookmark_bar_controller.h" 23 #import "chrome/browser/cocoa/bookmark_bar_controller.h"
24 #import "chrome/browser/cocoa/bookmark_editor_controller.h"
23 #import "chrome/browser/cocoa/browser_window_cocoa.h" 25 #import "chrome/browser/cocoa/browser_window_cocoa.h"
24 #import "chrome/browser/cocoa/browser_window_controller.h" 26 #import "chrome/browser/cocoa/browser_window_controller.h"
25 #import "chrome/browser/cocoa/download_shelf_controller.h" 27 #import "chrome/browser/cocoa/download_shelf_controller.h"
26 #import "chrome/browser/cocoa/find_bar_cocoa_controller.h" 28 #import "chrome/browser/cocoa/find_bar_cocoa_controller.h"
27 #include "chrome/browser/cocoa/find_bar_bridge.h" 29 #include "chrome/browser/cocoa/find_bar_bridge.h"
28 #import "chrome/browser/cocoa/fullscreen_window.h" 30 #import "chrome/browser/cocoa/fullscreen_window.h"
29 #import "chrome/browser/cocoa/infobar_container_controller.h" 31 #import "chrome/browser/cocoa/infobar_container_controller.h"
30 #import "chrome/browser/cocoa/status_bubble_mac.h" 32 #import "chrome/browser/cocoa/status_bubble_mac.h"
31 #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" 33 #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h"
32 #import "chrome/browser/cocoa/tab_strip_view.h" 34 #import "chrome/browser/cocoa/tab_strip_view.h"
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 [self setTheme]; 931 [self setTheme];
930 [self applyTheme]; 932 [self applyTheme];
931 933
932 [tabStripController_ userChangedTheme]; 934 [tabStripController_ userChangedTheme];
933 } 935 }
934 936
935 - (GTMTheme *)gtm_themeForWindow:(NSWindow*)window { 937 - (GTMTheme *)gtm_themeForWindow:(NSWindow*)window {
936 return theme_ ? theme_ : [GTMTheme defaultTheme]; 938 return theme_ ? theme_ : [GTMTheme defaultTheme];
937 } 939 }
938 940
941 - (NSPoint)topLeftForBubble {
942 NSRect rect = [toolbarController_ starButtonInWindowCoordinates];
943 NSPoint p = NSMakePoint(NSMinX(rect), NSMinY(rect)); // bottom left
944 return p;
945 }
946
947 // Show the bookmark bubble (e.g. user just clicked on the STAR).
948 - (void)showBookmarkBubbleForURL:(const GURL&)url
949 alreadyBookmarked:(BOOL)alreadyBookmarked {
950 BookmarkModel* model = browser_->profile()->GetBookmarkModel();
951 const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url);
952
953 // Bring up the bubble. But clicking on STAR while the bubble is
954 // open should make it go away.
955 if (bookmarkBubbleController_.get()) {
956 [self doneWithBubbleController:bookmarkBubbleController_.get()];
957 } else {
958 bookmarkBubbleController_.reset([[BookmarkBubbleController alloc]
959 initWithDelegate:self
960 parentWindow:[self window]
961 topLeftForBubble:[self topLeftForBubble]
962 model:model
963 node:node
964 alreadyBookmarked:alreadyBookmarked]);
965 [bookmarkBubbleController_ showWindow];
966 }
967 }
968
969 // Implement BookmarkBubbleControllerDelegate
970 - (void)editBookmarkNode:(const BookmarkNode*)node {
971 // A BookmarkEditorController is a sheet that owns itself, and
972 // deallocates itself when closed.
973 [[[BookmarkEditorController alloc]
974 initWithParentWindow:[self window]
975 profile:browser_->profile()
976 parent:node->GetParent()
977 node:node
978 configuration:BookmarkEditor::SHOW_TREE
979 handler:NULL]
980 runAsModalSheet];
981 }
982
983 // Implement BookmarkBubbleControllerDelegate
984 - (void)doneWithBubbleController:(BookmarkBubbleController*)controller {
985 bookmarkBubbleController_.reset(nil);
986 }
987
939 @end 988 @end
940 989
941 @implementation BrowserWindowController (Private) 990 @implementation BrowserWindowController (Private)
942 991
943 // If the browser is in incognito mode, install the image view to decorate 992 // If the browser is in incognito mode, install the image view to decorate
944 // the window at the upper right. Use the same base y coordinate as the 993 // the window at the upper right. Use the same base y coordinate as the
945 // tab strip. 994 // tab strip.
946 - (void)installIncognitoBadge { 995 - (void)installIncognitoBadge {
947 if (!browser_->profile()->IsOffTheRecord()) 996 if (!browser_->profile()->IsOffTheRecord())
948 return; 997 return;
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 NSColor* toolbarButtonBorderColor = toolbarButtonIconColor; 1283 NSColor* toolbarButtonBorderColor = toolbarButtonIconColor;
1235 [theme setValue:toolbarButtonBorderColor 1284 [theme setValue:toolbarButtonBorderColor
1236 forAttribute:@"borderColor" 1285 forAttribute:@"borderColor"
1237 style:GTMThemeStyleToolBar 1286 style:GTMThemeStyleToolBar
1238 state:YES]; 1287 state:YES];
1239 1288
1240 return theme; 1289 return theme;
1241 } 1290 }
1242 @end 1291 @end
1243 1292
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.h ('k') | chrome/browser/cocoa/browser_window_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698