| 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_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 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| 11 #import "base/mac/scoped_nsobject.h" | 11 #import "base/mac/scoped_nsobject.h" |
| 12 #include "base/mac/sdk_forward_declarations.h" | 12 #include "base/mac/sdk_forward_declarations.h" |
| 13 #include "base/metrics/user_metrics.h" |
| 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 14 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 14 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" | 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" |
| 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view_cocoa.h" | 16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view_cocoa.h" |
| 16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" | 17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" |
| 17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" | 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" |
| 18 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 19 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 19 #import "chrome/browser/ui/cocoa/view_id_util.h" | 20 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| 20 #include "components/bookmarks/browser/bookmark_model.h" | 21 #include "components/bookmarks/browser/bookmark_model.h" |
| 21 #include "content/public/browser/user_metrics.h" | |
| 22 #include "ui/base/clipboard/clipboard_util_mac.h" | 22 #include "ui/base/clipboard/clipboard_util_mac.h" |
| 23 #include "ui/base/cocoa/cocoa_base_utils.h" | 23 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 24 #import "ui/base/cocoa/nsview_additions.h" | 24 #import "ui/base/cocoa/nsview_additions.h" |
| 25 #include "ui/base/material_design/material_design_controller.h" | 25 #include "ui/base/material_design/material_design_controller.h" |
| 26 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 26 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 27 | 27 |
| 28 using base::UserMetricsAction; | 28 using base::UserMetricsAction; |
| 29 using bookmarks::BookmarkNode; | 29 using bookmarks::BookmarkNode; |
| 30 | 30 |
| 31 // The opacity of the bookmark button drag image. | 31 // The opacity of the bookmark button drag image. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 if ([[self delegate] dragShouldLockBarVisibility]) { | 195 if ([[self delegate] dragShouldLockBarVisibility]) { |
| 196 DCHECK(!visibilityDelegate_); | 196 DCHECK(!visibilityDelegate_); |
| 197 NSWindow* window = [[self delegate] browserWindow]; | 197 NSWindow* window = [[self delegate] browserWindow]; |
| 198 visibilityDelegate_ = | 198 visibilityDelegate_ = |
| 199 [BrowserWindowController browserWindowControllerForWindow:window]; | 199 [BrowserWindowController browserWindowControllerForWindow:window]; |
| 200 [visibilityDelegate_ lockToolbarVisibilityForOwner:self withAnimation:NO]; | 200 [visibilityDelegate_ lockToolbarVisibilityForOwner:self withAnimation:NO]; |
| 201 } | 201 } |
| 202 const BookmarkNode* node = [self bookmarkNode]; | 202 const BookmarkNode* node = [self bookmarkNode]; |
| 203 const BookmarkNode* parent = node->parent(); | 203 const BookmarkNode* parent = node->parent(); |
| 204 if (parent && parent->type() == BookmarkNode::FOLDER) { | 204 if (parent && parent->type() == BookmarkNode::FOLDER) { |
| 205 content::RecordAction(UserMetricsAction("BookmarkBarFolder_DragStart")); | 205 base::RecordAction(UserMetricsAction("BookmarkBarFolder_DragStart")); |
| 206 } else { | 206 } else { |
| 207 content::RecordAction(UserMetricsAction("BookmarkBar_DragStart")); | 207 base::RecordAction(UserMetricsAction("BookmarkBar_DragStart")); |
| 208 } | 208 } |
| 209 | 209 |
| 210 dragMouseOffset_ = [self convertPoint:[event locationInWindow] fromView:nil]; | 210 dragMouseOffset_ = [self convertPoint:[event locationInWindow] fromView:nil]; |
| 211 dragPending_ = YES; | 211 dragPending_ = YES; |
| 212 gDraggedButton = self; | 212 gDraggedButton = self; |
| 213 | 213 |
| 214 NSImage* image = [self dragImage]; | 214 NSImage* image = [self dragImage]; |
| 215 [self setHidden:YES]; | 215 [self setHidden:YES]; |
| 216 | 216 |
| 217 NSPasteboardItem* item = [[self delegate] pasteboardItemForDragOfButton:self]; | 217 NSPasteboardItem* item = [[self delegate] pasteboardItemForDragOfButton:self]; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 [[cell clipPathForFrame:bounds inView:self] setClip]; | 524 [[cell clipPathForFrame:bounds inView:self] setClip]; |
| 525 [cell drawWithFrame:bounds inView:self]; | 525 [cell drawWithFrame:bounds inView:self]; |
| 526 | 526 |
| 527 CGContextEndTransparencyLayer(cgContext); | 527 CGContextEndTransparencyLayer(cgContext); |
| 528 [image unlockFocus]; | 528 [image unlockFocus]; |
| 529 | 529 |
| 530 return image.autorelease(); | 530 return image.autorelease(); |
| 531 } | 531 } |
| 532 | 532 |
| 533 @end | 533 @end |
| OLD | NEW |