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
3 // found in the LICENSE file.
5 #import "chrome/browser/ui/cocoa/applescript/bookmark_item_applescript.h"
7 #include "base/strings/sys_string_conversions.h"
8 #include "chrome/browser/profiles/profile_manager.h"
9 #import "chrome/browser/ui/cocoa/applescript/error_applescript.h"
10 #include "components/bookmarks/browser/bookmark_model.h"
12 @interface BookmarkItemAppleScript()
13 @property (nonatomic, copy) NSString* tempURL;
16 @implementation BookmarkItemAppleScript
18 @synthesize tempURL = tempURL_;
21 if ((self = [super init])) {
22 [self setTempURL:@""];
32 - (void)setBookmarkNode:(const BookmarkNode*)aBookmarkNode {
33 [super setBookmarkNode:aBookmarkNode];
34 [self setURL:[self tempURL]];
41 return base::SysUTF8ToNSString(bookmarkNode_->url().spec());
44 - (void)setURL:(NSString*)aURL {
45 // If a scripter sets a URL before the node is added, URL is saved at a
46 // temporary location.
48 [self setTempURL:aURL];
52 BookmarkModel* model = [self bookmarkModel];
56 GURL url(base::SysNSStringToUTF8(aURL));
57 if (!url.is_valid()) {
58 AppleScript::SetError(AppleScript::errInvalidURL);
62 model->SetURL(bookmarkNode_, url);