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

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

Issue 2477633003: [Mac] Add a feature flag to disable Javascript execution in Applescript (Closed)
Patch Set: nit Created 4 years, 1 month 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) 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_item_applescript.h" 5 #import "chrome/browser/ui/cocoa/applescript/bookmark_item_applescript.h"
6 6
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #include "chrome/browser/profiles/profile_manager.h" 8 #include "chrome/browser/profiles/profile_manager.h"
9 #import "chrome/browser/ui/cocoa/applescript/error_applescript.h" 9 #import "chrome/browser/ui/cocoa/applescript/error_applescript.h"
10 #include "chrome/common/chrome_features.h"
10 #include "components/bookmarks/browser/bookmark_model.h" 11 #include "components/bookmarks/browser/bookmark_model.h"
11 12
12 using bookmarks::BookmarkModel; 13 using bookmarks::BookmarkModel;
13 using bookmarks::BookmarkNode; 14 using bookmarks::BookmarkNode;
14 15
15 @interface BookmarkItemAppleScript() 16 @interface BookmarkItemAppleScript()
16 @property (nonatomic, copy) NSString* tempURL; 17 @property (nonatomic, copy) NSString* tempURL;
17 @end 18 @end
18 19
19 @implementation BookmarkItemAppleScript 20 @implementation BookmarkItemAppleScript
(...skipping 18 matching lines...) Expand all
38 } 39 }
39 40
40 - (NSString*)URL { 41 - (NSString*)URL {
41 if (!bookmarkNode_) 42 if (!bookmarkNode_)
42 return tempURL_; 43 return tempURL_;
43 44
44 return base::SysUTF8ToNSString(bookmarkNode_->url().spec()); 45 return base::SysUTF8ToNSString(bookmarkNode_->url().spec());
45 } 46 }
46 47
47 - (void)setURL:(NSString*)aURL { 48 - (void)setURL:(NSString*)aURL {
49 GURL url(base::SysNSStringToUTF8(aURL));
50 if (!base::FeatureList::IsEnabled(features::kAppleScriptExecuteJavaScript) &&
51 url.SchemeIs(url::kJavaScriptScheme)) {
52 AppleScript::SetError(AppleScript::errJavaScriptUnsupported);
53 return;
54 }
55
48 // If a scripter sets a URL before the node is added, URL is saved at a 56 // If a scripter sets a URL before the node is added, URL is saved at a
49 // temporary location. 57 // temporary location.
50 if (!bookmarkNode_) { 58 if (!bookmarkNode_) {
51 [self setTempURL:aURL]; 59 [self setTempURL:aURL];
52 return; 60 return;
53 } 61 }
54 62
55 BookmarkModel* model = [self bookmarkModel]; 63 BookmarkModel* model = [self bookmarkModel];
56 if (!model) 64 if (!model)
57 return; 65 return;
58 66
59 GURL url(base::SysNSStringToUTF8(aURL));
60 if (!url.is_valid()) { 67 if (!url.is_valid()) {
61 AppleScript::SetError(AppleScript::errInvalidURL); 68 AppleScript::SetError(AppleScript::errInvalidURL);
62 return; 69 return;
63 } 70 }
64 71
65 model->SetURL(bookmarkNode_, url); 72 model->SetURL(bookmarkNode_, url);
66 } 73 }
67 74
68 @end 75 @end
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/ui/cocoa/applescript/error_applescript.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698