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

Unified Diff: chrome/browser/cocoa/applescript/bookmark_item_applescript.mm

Issue 3046042: Added AppleScript support (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/applescript/bookmark_item_applescript.mm
===================================================================
--- chrome/browser/cocoa/applescript/bookmark_item_applescript.mm (revision 0)
+++ chrome/browser/cocoa/applescript/bookmark_item_applescript.mm (revision 0)
@@ -0,0 +1,66 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/cocoa/applescript/bookmark_item_applescript.h"
+
+#include "base/sys_string_conversions.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
+#import "chrome/browser/cocoa/applescript/error_applescript.h"
+#include "chrome/browser/profile_manager.h"
+
+@interface BookmarkItemAppleScript()
+@property (nonatomic, copy) NSString* tempURL;
+@end
+
+@implementation BookmarkItemAppleScript
+
+@synthesize tempURL = tempURL_;
+
+- (id)init {
+ if ((self = [super init])) {
+ [self setTempURL:@""];
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [tempURL_ release];
+ [super dealloc];
+}
+
+- (void)setBookmarkNode:(const BookmarkNode*)aBookmarkNode {
+ [super setBookmarkNode:aBookmarkNode];
+ [self setURL:[self tempURL]];
+}
+
+- (NSString*)URL {
+ if (!bookmarkNode_)
+ return tempURL_;
+
+ const GURL& url = bookmarkNode_->GetURL();
+ return base::SysUTF8ToNSString(url.spec());
+}
+
+- (void)setURL:(NSString*)aURL {
+ // If a scripter sets a URL before the node is added, URL is saved at a
+ // temporary location.
+ if (!bookmarkNode_) {
+ [self setTempURL:aURL];
+ return;
+ }
+
+ BookmarkModel* model = [self bookmarkModel];
+ if (!model)
+ return;
+
+ GURL url(base::SysNSStringToUTF8(aURL));
+ if (!url.is_valid()) {
+ AppleScript::SetError(AppleScript::errInvalidURL);
+ return;
+ }
+
+ model->SetURL(bookmarkNode_, url);
+}
+
+@end
Property changes on: chrome/browser/cocoa/applescript/bookmark_item_applescript.mm
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698