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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm

Issue 1233673002: Fix componentization of chrome/browser/bookmarks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments by tfarina and fix compilation Created 5 years, 5 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
OLDNEW
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_folder_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h"
6 6
7 #include "base/mac/bundle_locations.h" 7 #include "base/mac/bundle_locations.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #import "chrome/browser/bookmarks/bookmark_model_factory.h" 9 #import "chrome/browser/bookmarks/bookmark_model_factory.h"
10 #import "chrome/browser/bookmarks/chrome_bookmark_client.h" 10 #import "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
11 #import "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
12 #import "chrome/browser/profiles/profile.h" 11 #import "chrome/browser/profiles/profile.h"
13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h"
14 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h" 14 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h"
16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state.h" 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state.h"
17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view.h" 16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view.h"
18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" 17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h"
19 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h"
20 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h" 19 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h"
21 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 20 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
22 #include "components/bookmarks/browser/bookmark_model.h" 21 #include "components/bookmarks/browser/bookmark_model.h"
23 #include "components/bookmarks/browser/bookmark_node_data.h" 22 #include "components/bookmarks/browser/bookmark_node_data.h"
23 #import "components/bookmarks/managed/managed_bookmark_service.h"
24 #include "ui/base/theme_provider.h" 24 #include "ui/base/theme_provider.h"
25 25
26 using bookmarks::BookmarkModel; 26 using bookmarks::BookmarkModel;
27 using bookmarks::BookmarkNode; 27 using bookmarks::BookmarkNode;
28 using bookmarks::BookmarkNodeData; 28 using bookmarks::BookmarkNodeData;
29 using bookmarks::kBookmarkBarMenuCornerRadius; 29 using bookmarks::kBookmarkBarMenuCornerRadius;
30 30
31 namespace { 31 namespace {
32 32
33 // Frequency of the scrolling timer in seconds. 33 // Frequency of the scrolling timer in seconds.
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 // Drop it at the end. 1273 // Drop it at the end.
1274 destIndex = [button bookmarkNode]->child_count(); 1274 destIndex = [button bookmarkNode]->child_count();
1275 } else { 1275 } else {
1276 // Else we're dropping somewhere in the folder, so find the right spot. 1276 // Else we're dropping somewhere in the folder, so find the right spot.
1277 destParent = [parentButton_ bookmarkNode]; 1277 destParent = [parentButton_ bookmarkNode];
1278 destIndex = [self indexForDragToPoint:point]; 1278 destIndex = [self indexForDragToPoint:point];
1279 // Be careful if the number of buttons != number of nodes. 1279 // Be careful if the number of buttons != number of nodes.
1280 destIndex += [[parentButton_ cell] startingChildIndex]; 1280 destIndex += [[parentButton_ cell] startingChildIndex];
1281 } 1281 }
1282 1282
1283 ChromeBookmarkClient* client = 1283 bookmarks::ManagedBookmarkService* managed =
1284 ChromeBookmarkClientFactory::GetForProfile(profile_); 1284 ManagedBookmarkServiceFactory::GetForProfile(profile_);
1285 if (!client->CanBeEditedByUser(destParent)) 1285 if (!managed->CanBeEditedByUser(destParent))
1286 return NO; 1286 return NO;
1287 if (!client->CanBeEditedByUser(sourceNode)) 1287 if (!managed->CanBeEditedByUser(sourceNode))
1288 copy = YES; 1288 copy = YES;
1289 1289
1290 // Prevent cycles. 1290 // Prevent cycles.
1291 BOOL wasCopiedOrMoved = NO; 1291 BOOL wasCopiedOrMoved = NO;
1292 if (!destParent->HasAncestor(sourceNode)) { 1292 if (!destParent->HasAncestor(sourceNode)) {
1293 if (copy) 1293 if (copy)
1294 [self bookmarkModel]->Copy(sourceNode, destParent, destIndex); 1294 [self bookmarkModel]->Copy(sourceNode, destParent, destIndex);
1295 else 1295 else
1296 [self bookmarkModel]->Move(sourceNode, destParent, destIndex); 1296 [self bookmarkModel]->Move(sourceNode, destParent, destIndex);
1297 wasCopiedOrMoved = YES; 1297 wasCopiedOrMoved = YES;
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 // Drop it at the end. 1845 // Drop it at the end.
1846 destIndex = [button bookmarkNode]->child_count(); 1846 destIndex = [button bookmarkNode]->child_count();
1847 } else { 1847 } else {
1848 // Else we're dropping somewhere in the folder, so find the right spot. 1848 // Else we're dropping somewhere in the folder, so find the right spot.
1849 destParent = [parentButton_ bookmarkNode]; 1849 destParent = [parentButton_ bookmarkNode];
1850 destIndex = [self indexForDragToPoint:point]; 1850 destIndex = [self indexForDragToPoint:point];
1851 // Be careful if the number of buttons != number of nodes. 1851 // Be careful if the number of buttons != number of nodes.
1852 destIndex += [[parentButton_ cell] startingChildIndex]; 1852 destIndex += [[parentButton_ cell] startingChildIndex];
1853 } 1853 }
1854 1854
1855 ChromeBookmarkClient* client = 1855 bookmarks::ManagedBookmarkService* managed =
1856 ChromeBookmarkClientFactory::GetForProfile(profile_); 1856 ManagedBookmarkServiceFactory::GetForProfile(profile_);
1857 if (!client->CanBeEditedByUser(destParent)) 1857 if (!managed->CanBeEditedByUser(destParent))
1858 return NO; 1858 return NO;
1859 1859
1860 // Create and add the new bookmark nodes. 1860 // Create and add the new bookmark nodes.
1861 size_t urlCount = [urls count]; 1861 size_t urlCount = [urls count];
1862 for (size_t i = 0; i < urlCount; ++i) { 1862 for (size_t i = 0; i < urlCount; ++i) {
1863 GURL gurl; 1863 GURL gurl;
1864 const char* string = [[urls objectAtIndex:i] UTF8String]; 1864 const char* string = [[urls objectAtIndex:i] UTF8String];
1865 if (string) 1865 if (string)
1866 gurl = GURL(string); 1866 gurl = GURL(string);
1867 // We only expect to receive valid URLs. 1867 // We only expect to receive valid URLs.
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
2029 2029
2030 - (void)setIgnoreAnimations:(BOOL)ignore { 2030 - (void)setIgnoreAnimations:(BOOL)ignore {
2031 ignoreAnimations_ = ignore; 2031 ignoreAnimations_ = ignore;
2032 } 2032 }
2033 2033
2034 - (BookmarkButton*)buttonThatMouseIsIn { 2034 - (BookmarkButton*)buttonThatMouseIsIn {
2035 return buttonThatMouseIsIn_; 2035 return buttonThatMouseIsIn_;
2036 } 2036 }
2037 2037
2038 @end // BookmarkBarFolderController 2038 @end // BookmarkBarFolderController
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698