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

Side by Side Diff: chrome/browser/ui/cocoa/applescript/bookmark_node_applescript.mm

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 years, 6 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 | Annotate | Revision Log
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/applescript/bookmark_node_applescript.h" 5 #import "chrome/browser/ui/cocoa/applescript/bookmark_node_applescript.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/memory/scoped_nsobject.h" 8 #import "base/mac/scoped_nsobject.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #import "chrome/browser/app_controller_mac.h" 10 #import "chrome/browser/app_controller_mac.h"
11 #include "chrome/browser/bookmarks/bookmark_model.h" 11 #include "chrome/browser/bookmarks/bookmark_model.h"
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
13 #import "chrome/browser/chrome_browser_application_mac.h" 13 #import "chrome/browser/chrome_browser_application_mac.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #import "chrome/browser/ui/cocoa/applescript/bookmark_item_applescript.h" 15 #import "chrome/browser/ui/cocoa/applescript/bookmark_item_applescript.h"
16 #import "chrome/browser/ui/cocoa/applescript/error_applescript.h" 16 #import "chrome/browser/ui/cocoa/applescript/error_applescript.h"
17 17
18 @interface BookmarkNodeAppleScript() 18 @interface BookmarkNodeAppleScript()
19 @property (nonatomic, copy) NSString* tempTitle; 19 @property (nonatomic, copy) NSString* tempTitle;
20 @end 20 @end
21 21
22 @implementation BookmarkNodeAppleScript 22 @implementation BookmarkNodeAppleScript
23 23
24 @synthesize tempTitle = tempTitle_; 24 @synthesize tempTitle = tempTitle_;
25 25
26 - (id)init { 26 - (id)init {
27 if ((self = [super init])) { 27 if ((self = [super init])) {
28 BookmarkModel* model = [self bookmarkModel]; 28 BookmarkModel* model = [self bookmarkModel];
29 if (!model) { 29 if (!model) {
30 [self release]; 30 [self release];
31 return nil; 31 return nil;
32 } 32 }
33 33
34 scoped_nsobject<NSNumber> numID( 34 base::scoped_nsobject<NSNumber> numID(
35 [[NSNumber alloc] initWithLongLong:model->next_node_id()]); 35 [[NSNumber alloc] initWithLongLong:model->next_node_id()]);
36 [self setUniqueID:numID]; 36 [self setUniqueID:numID];
37 [self setTempTitle:@""]; 37 [self setTempTitle:@""];
38 } 38 }
39 return self; 39 return self;
40 } 40 }
41 41
42 - (void)dealloc { 42 - (void)dealloc {
43 [tempTitle_ release]; 43 [tempTitle_ release];
44 [super dealloc]; 44 [super dealloc];
45 } 45 }
46 46
47 47
48 - (id)initWithBookmarkNode:(const BookmarkNode*)aBookmarkNode { 48 - (id)initWithBookmarkNode:(const BookmarkNode*)aBookmarkNode {
49 if (!aBookmarkNode) { 49 if (!aBookmarkNode) {
50 [self release]; 50 [self release];
51 return nil; 51 return nil;
52 } 52 }
53 53
54 if ((self = [super init])) { 54 if ((self = [super init])) {
55 // It is safe to be weak, if a bookmark item/folder goes away 55 // It is safe to be weak, if a bookmark item/folder goes away
56 // (eg user deleting a folder) the applescript runtime calls 56 // (eg user deleting a folder) the applescript runtime calls
57 // bookmarkFolders/bookmarkItems in BookmarkFolderAppleScript 57 // bookmarkFolders/bookmarkItems in BookmarkFolderAppleScript
58 // and this particular bookmark item/folder is never returned. 58 // and this particular bookmark item/folder is never returned.
59 bookmarkNode_ = aBookmarkNode; 59 bookmarkNode_ = aBookmarkNode;
60 60
61 scoped_nsobject<NSNumber> numID( 61 base::scoped_nsobject<NSNumber> numID(
62 [[NSNumber alloc] initWithLongLong:aBookmarkNode->id()]); 62 [[NSNumber alloc] initWithLongLong:aBookmarkNode->id()]);
63 [self setUniqueID:numID]; 63 [self setUniqueID:numID];
64 } 64 }
65 return self; 65 return self;
66 } 66 }
67 67
68 - (void)setBookmarkNode:(const BookmarkNode*)aBookmarkNode { 68 - (void)setBookmarkNode:(const BookmarkNode*)aBookmarkNode {
69 DCHECK(aBookmarkNode); 69 DCHECK(aBookmarkNode);
70 // It is safe to be weak, if a bookmark item/folder goes away 70 // It is safe to be weak, if a bookmark item/folder goes away
71 // (eg user deleting a folder) the applescript runtime calls 71 // (eg user deleting a folder) the applescript runtime calls
72 // bookmarkFolders/bookmarkItems in BookmarkFolderAppleScript 72 // bookmarkFolders/bookmarkItems in BookmarkFolderAppleScript
73 // and this particular bookmark item/folder is never returned. 73 // and this particular bookmark item/folder is never returned.
74 bookmarkNode_ = aBookmarkNode; 74 bookmarkNode_ = aBookmarkNode;
75 75
76 scoped_nsobject<NSNumber> numID( 76 base::scoped_nsobject<NSNumber> numID(
77 [[NSNumber alloc] initWithLongLong:aBookmarkNode->id()]); 77 [[NSNumber alloc] initWithLongLong:aBookmarkNode->id()]);
78 [self setUniqueID:numID]; 78 [self setUniqueID:numID];
79 79
80 [self setTitle:[self tempTitle]]; 80 [self setTitle:[self tempTitle]];
81 } 81 }
82 82
83 - (NSString*)title { 83 - (NSString*)title {
84 if (!bookmarkNode_) 84 if (!bookmarkNode_)
85 return tempTitle_; 85 return tempTitle_;
86 86
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 BookmarkModel* model = BookmarkModelFactory::GetForProfile(lastProfile); 122 BookmarkModel* model = BookmarkModelFactory::GetForProfile(lastProfile);
123 if (!model->loaded()) { 123 if (!model->loaded()) {
124 AppleScript::SetError(AppleScript::errBookmarkModelLoad); 124 AppleScript::SetError(AppleScript::errBookmarkModelLoad);
125 return NULL; 125 return NULL;
126 } 126 }
127 127
128 return model; 128 return model;
129 } 129 }
130 130
131 @end 131 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698