| OLD | NEW |
| 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/bookmarks/bookmark_bar_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/bundle_locations.h" | 7 #include "base/mac/bundle_locations.h" |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 DCHECK([sender respondsToSelector:@selector(bookmarkNode)]); | 675 DCHECK([sender respondsToSelector:@selector(bookmarkNode)]); |
| 676 const BookmarkNode* node = [sender bookmarkNode]; | 676 const BookmarkNode* node = [sender bookmarkNode]; |
| 677 DCHECK(node); | 677 DCHECK(node); |
| 678 WindowOpenDisposition disposition = | 678 WindowOpenDisposition disposition = |
| 679 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); | 679 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); |
| 680 RecordAppLaunch(browser_->profile(), node->url()); | 680 RecordAppLaunch(browser_->profile(), node->url()); |
| 681 [self openURL:node->url() disposition:disposition]; | 681 [self openURL:node->url() disposition:disposition]; |
| 682 | 682 |
| 683 if (!animate) | 683 if (!animate) |
| 684 [self closeFolderAndStopTrackingMenus]; | 684 [self closeFolderAndStopTrackingMenus]; |
| 685 RecordBookmarkLaunch(node, [self bookmarkLaunchLocation]); | 685 RecordBookmarkLaunch(bookmarkModel_, node, [self bookmarkLaunchLocation]); |
| 686 } | 686 } |
| 687 | 687 |
| 688 // Common function to open a bookmark folder of any type. | 688 // Common function to open a bookmark folder of any type. |
| 689 - (void)openBookmarkFolder:(id)sender { | 689 - (void)openBookmarkFolder:(id)sender { |
| 690 DCHECK([sender isKindOfClass:[BookmarkButton class]]); | 690 DCHECK([sender isKindOfClass:[BookmarkButton class]]); |
| 691 DCHECK([[sender cell] isKindOfClass:[BookmarkButtonCell class]]); | 691 DCHECK([[sender cell] isKindOfClass:[BookmarkButtonCell class]]); |
| 692 | 692 |
| 693 // Only record the action if it's the initial folder being opened. | 693 // Only record the action if it's the initial folder being opened. |
| 694 if (!showFolderMenus_) | 694 if (!showFolderMenus_) |
| 695 RecordBookmarkFolderOpen([self bookmarkLaunchLocation]); | 695 RecordBookmarkFolderOpen(bookmarkModel_, [self bookmarkLaunchLocation]); |
| 696 showFolderMenus_ = !showFolderMenus_; | 696 showFolderMenus_ = !showFolderMenus_; |
| 697 | 697 |
| 698 if (sender == offTheSideButton_) | 698 if (sender == offTheSideButton_) |
| 699 [[sender cell] setStartingChildIndex:displayedButtonCount_]; | 699 [[sender cell] setStartingChildIndex:displayedButtonCount_]; |
| 700 | 700 |
| 701 // Toggle presentation of bar folder menus. | 701 // Toggle presentation of bar folder menus. |
| 702 [folderTarget_ openBookmarkFolderFromButton:sender]; | 702 [folderTarget_ openBookmarkFolderFromButton:sender]; |
| 703 } | 703 } |
| 704 | 704 |
| 705 // Click on a bookmark folder button. | 705 // Click on a bookmark folder button. |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 [appsPageShortcutButton_ setToolTip:tooltip]; | 1222 [appsPageShortcutButton_ setToolTip:tooltip]; |
| 1223 [buttonView_ addSubview:appsPageShortcutButton_.get()]; | 1223 [buttonView_ addSubview:appsPageShortcutButton_.get()]; |
| 1224 | 1224 |
| 1225 [self setAppsPageShortcutButtonVisibility]; | 1225 [self setAppsPageShortcutButtonVisibility]; |
| 1226 } | 1226 } |
| 1227 | 1227 |
| 1228 - (void)openAppsPage:(id)sender { | 1228 - (void)openAppsPage:(id)sender { |
| 1229 WindowOpenDisposition disposition = | 1229 WindowOpenDisposition disposition = |
| 1230 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); | 1230 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); |
| 1231 [self openURL:GURL(chrome::kChromeUIAppsURL) disposition:disposition]; | 1231 [self openURL:GURL(chrome::kChromeUIAppsURL) disposition:disposition]; |
| 1232 RecordBookmarkAppsPageOpen([self bookmarkLaunchLocation]); | 1232 RecordBookmarkAppsPageOpen(bookmarkModel_, [self bookmarkLaunchLocation]); |
| 1233 } | 1233 } |
| 1234 | 1234 |
| 1235 // To avoid problems with sync, changes that may impact the current | 1235 // To avoid problems with sync, changes that may impact the current |
| 1236 // bookmark (e.g. deletion) make sure context menus are closed. This | 1236 // bookmark (e.g. deletion) make sure context menus are closed. This |
| 1237 // prevents deleting a node which no longer exists. | 1237 // prevents deleting a node which no longer exists. |
| 1238 - (void)cancelMenuTracking { | 1238 - (void)cancelMenuTracking { |
| 1239 [contextMenuController_ cancelTracking]; | 1239 [contextMenuController_ cancelTracking]; |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 - (void)moveToState:(BookmarkBar::State)nextState | 1242 - (void)moveToState:(BookmarkBar::State)nextState |
| (...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2680 - (id<BookmarkButtonControllerProtocol>)controllerForNode: | 2680 - (id<BookmarkButtonControllerProtocol>)controllerForNode: |
| 2681 (const BookmarkNode*)node { | 2681 (const BookmarkNode*)node { |
| 2682 // See if it's in the bar, then if it is in the hierarchy of visible | 2682 // See if it's in the bar, then if it is in the hierarchy of visible |
| 2683 // folder menus. | 2683 // folder menus. |
| 2684 if (bookmarkModel_->bookmark_bar_node() == node) | 2684 if (bookmarkModel_->bookmark_bar_node() == node) |
| 2685 return self; | 2685 return self; |
| 2686 return [folderController_ controllerForNode:node]; | 2686 return [folderController_ controllerForNode:node]; |
| 2687 } | 2687 } |
| 2688 | 2688 |
| 2689 @end | 2689 @end |
| OLD | NEW |