| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_button.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #import "base/memory/scoped_nsobject.h" | 10 #import "base/memory/scoped_nsobject.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" |
| 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" | 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" |
| 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" | |
| 14 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 14 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 15 #import "chrome/browser/ui/cocoa/view_id_util.h" | 15 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| 16 #include "content/browser/user_metrics.h" | 16 #include "content/public/browser/user_metrics.h" |
| 17 |
| 18 using content::UserMetricsAction; |
| 17 | 19 |
| 18 // The opacity of the bookmark button drag image. | 20 // The opacity of the bookmark button drag image. |
| 19 static const CGFloat kDragImageOpacity = 0.7; | 21 static const CGFloat kDragImageOpacity = 0.7; |
| 20 | 22 |
| 21 | 23 |
| 22 namespace bookmark_button { | 24 namespace bookmark_button { |
| 23 | 25 |
| 24 NSString* const kPulseBookmarkButtonNotification = | 26 NSString* const kPulseBookmarkButtonNotification = |
| 25 @"PulseBookmarkButtonNotification"; | 27 @"PulseBookmarkButtonNotification"; |
| 26 NSString* const kBookmarkKey = @"BookmarkKey"; | 28 NSString* const kBookmarkKey = @"BookmarkKey"; |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 NSWindow* window = [[self delegate] browserWindow]; | 191 NSWindow* window = [[self delegate] browserWindow]; |
| 190 visibilityDelegate_ = | 192 visibilityDelegate_ = |
| 191 [BrowserWindowController browserWindowControllerForWindow:window]; | 193 [BrowserWindowController browserWindowControllerForWindow:window]; |
| 192 [visibilityDelegate_ lockBarVisibilityForOwner:self | 194 [visibilityDelegate_ lockBarVisibilityForOwner:self |
| 193 withAnimation:NO | 195 withAnimation:NO |
| 194 delay:NO]; | 196 delay:NO]; |
| 195 } | 197 } |
| 196 const BookmarkNode* node = [self bookmarkNode]; | 198 const BookmarkNode* node = [self bookmarkNode]; |
| 197 const BookmarkNode* parent = node ? node->parent() : NULL; | 199 const BookmarkNode* parent = node ? node->parent() : NULL; |
| 198 if (parent && parent->type() == BookmarkNode::FOLDER) { | 200 if (parent && parent->type() == BookmarkNode::FOLDER) { |
| 199 UserMetrics::RecordAction(UserMetricsAction("BookmarkBarFolder_DragStart")); | 201 content::RecordAction(UserMetricsAction("BookmarkBarFolder_DragStart")); |
| 200 } else { | 202 } else { |
| 201 UserMetrics::RecordAction(UserMetricsAction("BookmarkBar_DragStart")); | 203 content::RecordAction(UserMetricsAction("BookmarkBar_DragStart")); |
| 202 } | 204 } |
| 203 | 205 |
| 204 dragMouseOffset_ = [self convertPointFromBase:[event locationInWindow]]; | 206 dragMouseOffset_ = [self convertPointFromBase:[event locationInWindow]]; |
| 205 dragPending_ = YES; | 207 dragPending_ = YES; |
| 206 gDraggedButton = self; | 208 gDraggedButton = self; |
| 207 | 209 |
| 208 CGFloat yAt = [self bounds].size.height; | 210 CGFloat yAt = [self bounds].size.height; |
| 209 NSSize dragOffset = NSMakeSize(0.0, 0.0); | 211 NSSize dragOffset = NSMakeSize(0.0, 0.0); |
| 210 NSImage* image = [self dragImage]; | 212 NSImage* image = [self dragImage]; |
| 211 [self setHidden:YES]; | 213 [self setHidden:YES]; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 [image drawAtPoint:NSMakePoint(0, 0) | 431 [image drawAtPoint:NSMakePoint(0, 0) |
| 430 fromRect:NSMakeRect(0, 0, NSWidth(bounds), NSHeight(bounds)) | 432 fromRect:NSMakeRect(0, 0, NSWidth(bounds), NSHeight(bounds)) |
| 431 operation:NSCompositeSourceOver | 433 operation:NSCompositeSourceOver |
| 432 fraction:kDragImageOpacity]; | 434 fraction:kDragImageOpacity]; |
| 433 | 435 |
| 434 [dragImage unlockFocus]; | 436 [dragImage unlockFocus]; |
| 435 return dragImage; | 437 return dragImage; |
| 436 } | 438 } |
| 437 | 439 |
| 438 @end // @implementation BookmarkButton(Private) | 440 @end // @implementation BookmarkButton(Private) |
| OLD | NEW |