| 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/applescript/bookmark_folder_applescript.h" | 5 #import "chrome/browser/ui/cocoa/applescript/bookmark_folder_applescript.h" |
| 6 | 6 |
| 7 #import "base/memory/scoped_nsobject.h" | 7 #import "base/mac/scoped_nsobject.h" |
| 8 #import "base/strings/string16.h" | 8 #import "base/strings/string16.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 11 #import "chrome/browser/ui/cocoa/applescript/bookmark_item_applescript.h" | 11 #import "chrome/browser/ui/cocoa/applescript/bookmark_item_applescript.h" |
| 12 #import "chrome/browser/ui/cocoa/applescript/constants_applescript.h" | 12 #import "chrome/browser/ui/cocoa/applescript/constants_applescript.h" |
| 13 #include "chrome/browser/ui/cocoa/applescript/error_applescript.h" | 13 #include "chrome/browser/ui/cocoa/applescript/error_applescript.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 | 15 |
| 16 @implementation BookmarkFolderAppleScript | 16 @implementation BookmarkFolderAppleScript |
| 17 | 17 |
| 18 - (NSArray*)bookmarkFolders { | 18 - (NSArray*)bookmarkFolders { |
| 19 NSMutableArray* bookmarkFolders = [NSMutableArray | 19 NSMutableArray* bookmarkFolders = [NSMutableArray |
| 20 arrayWithCapacity:bookmarkNode_->child_count()]; | 20 arrayWithCapacity:bookmarkNode_->child_count()]; |
| 21 | 21 |
| 22 for (int i = 0; i < bookmarkNode_->child_count(); ++i) { | 22 for (int i = 0; i < bookmarkNode_->child_count(); ++i) { |
| 23 const BookmarkNode* node = bookmarkNode_->GetChild(i); | 23 const BookmarkNode* node = bookmarkNode_->GetChild(i); |
| 24 | 24 |
| 25 if (!node->is_folder()) | 25 if (!node->is_folder()) |
| 26 continue; | 26 continue; |
| 27 scoped_nsobject<BookmarkFolderAppleScript> bookmarkFolder( | 27 base::scoped_nsobject<BookmarkFolderAppleScript> bookmarkFolder( |
| 28 [[BookmarkFolderAppleScript alloc] initWithBookmarkNode:node]); | 28 [[BookmarkFolderAppleScript alloc] initWithBookmarkNode:node]); |
| 29 [bookmarkFolder setContainer:self | 29 [bookmarkFolder setContainer:self |
| 30 property:AppleScript::kBookmarkFoldersProperty]; | 30 property:AppleScript::kBookmarkFoldersProperty]; |
| 31 [bookmarkFolders addObject:bookmarkFolder]; | 31 [bookmarkFolders addObject:bookmarkFolder]; |
| 32 } | 32 } |
| 33 | 33 |
| 34 return bookmarkFolders; | 34 return bookmarkFolders; |
| 35 } | 35 } |
| 36 | 36 |
| 37 - (void)insertInBookmarkFolders:(id)aBookmarkFolder { | 37 - (void)insertInBookmarkFolders:(id)aBookmarkFolder { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 - (NSArray*)bookmarkItems { | 89 - (NSArray*)bookmarkItems { |
| 90 NSMutableArray* bookmarkItems = [NSMutableArray | 90 NSMutableArray* bookmarkItems = [NSMutableArray |
| 91 arrayWithCapacity:bookmarkNode_->child_count()]; | 91 arrayWithCapacity:bookmarkNode_->child_count()]; |
| 92 | 92 |
| 93 for (int i = 0; i < bookmarkNode_->child_count(); ++i) { | 93 for (int i = 0; i < bookmarkNode_->child_count(); ++i) { |
| 94 const BookmarkNode* node = bookmarkNode_->GetChild(i); | 94 const BookmarkNode* node = bookmarkNode_->GetChild(i); |
| 95 | 95 |
| 96 if (!node->is_url()) | 96 if (!node->is_url()) |
| 97 continue; | 97 continue; |
| 98 scoped_nsobject<BookmarkItemAppleScript> bookmarkItem( | 98 base::scoped_nsobject<BookmarkItemAppleScript> bookmarkItem( |
| 99 [[BookmarkItemAppleScript alloc] initWithBookmarkNode:node]); | 99 [[BookmarkItemAppleScript alloc] initWithBookmarkNode:node]); |
| 100 [bookmarkItem setContainer:self | 100 [bookmarkItem setContainer:self |
| 101 property:AppleScript::kBookmarkItemsProperty]; | 101 property:AppleScript::kBookmarkItemsProperty]; |
| 102 [bookmarkItems addObject:bookmarkItem]; | 102 [bookmarkItems addObject:bookmarkItem]; |
| 103 } | 103 } |
| 104 | 104 |
| 105 return bookmarkItems; | 105 return bookmarkItems; |
| 106 } | 106 } |
| 107 | 107 |
| 108 - (void)insertInBookmarkItems:(BookmarkItemAppleScript*)aBookmarkItem { | 108 - (void)insertInBookmarkItems:(BookmarkItemAppleScript*)aBookmarkItem { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 ++index; | 193 ++index; |
| 194 int count = -1; | 194 int count = -1; |
| 195 while (index) { | 195 while (index) { |
| 196 if (bookmarkNode_->GetChild(++count)->is_url()) | 196 if (bookmarkNode_->GetChild(++count)->is_url()) |
| 197 --index; | 197 --index; |
| 198 } | 198 } |
| 199 return count; | 199 return count; |
| 200 } | 200 } |
| 201 | 201 |
| 202 @end | 202 @end |
| OLD | NEW |