OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_bar_controller.h" | 5 #import "chrome/browser/cocoa/bookmark_bar_controller.h" |
6 #include "app/l10n_util_mac.h" | 6 #include "app/l10n_util_mac.h" |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/mac_util.h" | 8 #include "base/mac_util.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #include "chrome/browser/bookmarks/bookmark_editor.h" | 10 #include "chrome/browser/bookmarks/bookmark_editor.h" |
11 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
(...skipping 14 matching lines...) Expand all Loading... |
26 #import "chrome/browser/cocoa/bookmark_folder_target.h" | 26 #import "chrome/browser/cocoa/bookmark_folder_target.h" |
27 #import "chrome/browser/cocoa/bookmark_menu.h" | 27 #import "chrome/browser/cocoa/bookmark_menu.h" |
28 #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h" | 28 #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h" |
29 #import "chrome/browser/cocoa/bookmark_name_folder_controller.h" | 29 #import "chrome/browser/cocoa/bookmark_name_folder_controller.h" |
30 #import "chrome/browser/cocoa/browser_window_controller.h" | 30 #import "chrome/browser/cocoa/browser_window_controller.h" |
31 #import "chrome/browser/cocoa/event_utils.h" | 31 #import "chrome/browser/cocoa/event_utils.h" |
32 #import "chrome/browser/cocoa/import_settings_dialog.h" | 32 #import "chrome/browser/cocoa/import_settings_dialog.h" |
33 #import "chrome/browser/cocoa/menu_button.h" | 33 #import "chrome/browser/cocoa/menu_button.h" |
34 #import "chrome/browser/cocoa/themed_window.h" | 34 #import "chrome/browser/cocoa/themed_window.h" |
35 #import "chrome/browser/cocoa/toolbar_controller.h" | 35 #import "chrome/browser/cocoa/toolbar_controller.h" |
| 36 #import "chrome/browser/cocoa/view_id_util.h" |
36 #import "chrome/browser/cocoa/view_resizer.h" | 37 #import "chrome/browser/cocoa/view_resizer.h" |
37 #include "chrome/browser/metrics/user_metrics.h" | 38 #include "chrome/browser/metrics/user_metrics.h" |
38 #include "chrome/browser/pref_service.h" | 39 #include "chrome/browser/pref_service.h" |
39 #include "chrome/browser/profile.h" | 40 #include "chrome/browser/profile.h" |
40 #include "chrome/browser/tab_contents/tab_contents.h" | 41 #include "chrome/browser/tab_contents/tab_contents.h" |
41 #include "chrome/browser/tab_contents/tab_contents_view.h" | 42 #include "chrome/browser/tab_contents/tab_contents_view.h" |
42 #include "chrome/common/pref_names.h" | 43 #include "chrome/common/pref_names.h" |
43 #include "grit/app_resources.h" | 44 #include "grit/app_resources.h" |
44 #include "grit/generated_resources.h" | 45 #include "grit/generated_resources.h" |
45 #include "grit/theme_resources.h" | 46 #include "grit/theme_resources.h" |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 } | 991 } |
991 | 992 |
992 - (BookmarkButton*)buttonForNode:(const BookmarkNode*)node | 993 - (BookmarkButton*)buttonForNode:(const BookmarkNode*)node |
993 xOffset:(int*)xOffset { | 994 xOffset:(int*)xOffset { |
994 NSCell* cell = [self cellForBookmarkNode:node]; | 995 NSCell* cell = [self cellForBookmarkNode:node]; |
995 NSRect frame = [self frameForBookmarkButtonFromCell:cell xOffset:xOffset]; | 996 NSRect frame = [self frameForBookmarkButtonFromCell:cell xOffset:xOffset]; |
996 | 997 |
997 scoped_nsobject<BookmarkButton> | 998 scoped_nsobject<BookmarkButton> |
998 button([[BookmarkButton alloc] initWithFrame:frame]); | 999 button([[BookmarkButton alloc] initWithFrame:frame]); |
999 DCHECK(button.get()); | 1000 DCHECK(button.get()); |
| 1001 [button setViewID:VIEW_ID_BOOKMARK_BAR_ELEMENT]; |
1000 | 1002 |
1001 // [NSButton setCell:] warns to NOT use setCell: other than in the | 1003 // [NSButton setCell:] warns to NOT use setCell: other than in the |
1002 // initializer of a control. However, we are using a basic | 1004 // initializer of a control. However, we are using a basic |
1003 // NSButton whose initializer does not take an NSCell as an | 1005 // NSButton whose initializer does not take an NSCell as an |
1004 // object. To honor the assumed semantics, we do nothing with | 1006 // object. To honor the assumed semantics, we do nothing with |
1005 // NSButton between alloc/init and setCell:. | 1007 // NSButton between alloc/init and setCell:. |
1006 [button setCell:cell]; | 1008 [button setCell:cell]; |
1007 [button setDelegate:self]; | 1009 [button setDelegate:self]; |
1008 | 1010 |
1009 if (node->is_folder()) { | 1011 if (node->is_folder()) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 | 1067 |
1066 // TODO(jrg): remove duplicate code | 1068 // TODO(jrg): remove duplicate code |
1067 NSCell* cell = [self cellForBookmarkNode:bookmarkModel_->other_node()]; | 1069 NSCell* cell = [self cellForBookmarkNode:bookmarkModel_->other_node()]; |
1068 int ignored = 0; | 1070 int ignored = 0; |
1069 NSRect frame = [self frameForBookmarkButtonFromCell:cell xOffset:&ignored]; | 1071 NSRect frame = [self frameForBookmarkButtonFromCell:cell xOffset:&ignored]; |
1070 frame.origin.x = [[self buttonView] bounds].size.width - frame.size.width; | 1072 frame.origin.x = [[self buttonView] bounds].size.width - frame.size.width; |
1071 frame.origin.x -= bookmarks::kBookmarkHorizontalPadding; | 1073 frame.origin.x -= bookmarks::kBookmarkHorizontalPadding; |
1072 BookmarkButton* button = [[BookmarkButton alloc] initWithFrame:frame]; | 1074 BookmarkButton* button = [[BookmarkButton alloc] initWithFrame:frame]; |
1073 [button setDraggable:NO]; | 1075 [button setDraggable:NO]; |
1074 otherBookmarksButton_.reset(button); | 1076 otherBookmarksButton_.reset(button); |
| 1077 [button setViewID:VIEW_ID_OTHER_BOOKMARKS]; |
1075 | 1078 |
1076 // Make sure this button, like all other BookmarkButtons, lives | 1079 // Make sure this button, like all other BookmarkButtons, lives |
1077 // until the end of the current event loop. | 1080 // until the end of the current event loop. |
1078 [[button retain] autorelease]; | 1081 [[button retain] autorelease]; |
1079 | 1082 |
1080 // Peg at right; keep same height as bar. | 1083 // Peg at right; keep same height as bar. |
1081 [button setAutoresizingMask:(NSViewMinXMargin)]; | 1084 [button setAutoresizingMask:(NSViewMinXMargin)]; |
1082 [button setCell:cell]; | 1085 [button setCell:cell]; |
1083 [button setDelegate:self]; | 1086 [button setDelegate:self]; |
1084 [button setTarget:self]; | 1087 [button setTarget:self]; |
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2340 // to minimize touching the object passed in (likely a mock). | 2343 // to minimize touching the object passed in (likely a mock). |
2341 - (void)setButtonContextMenu:(id)menu { | 2344 - (void)setButtonContextMenu:(id)menu { |
2342 buttonContextMenu_ = menu; | 2345 buttonContextMenu_ = menu; |
2343 } | 2346 } |
2344 | 2347 |
2345 - (void)setIgnoreAnimations:(BOOL)ignore { | 2348 - (void)setIgnoreAnimations:(BOOL)ignore { |
2346 ignoreAnimations_ = ignore; | 2349 ignoreAnimations_ = ignore; |
2347 } | 2350 } |
2348 | 2351 |
2349 @end | 2352 @end |
OLD | NEW |