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

Side by Side Diff: chrome/common/extensions/user_script.h

Issue 412008: Introduce a new 'all_frames' property to content scripts and (Closed)
Patch Set: responses to comments Created 11 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 2009 The Chromium Authors. All rights reserved. 1 // Copyright 2009 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 #ifndef CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ 5 #ifndef CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_
6 #define CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ 6 #define CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_
7 7
8 #include <vector> 8 #include <vector>
9 #include <string> 9 #include <string>
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 // Set when the content is loaded by LoadContent 96 // Set when the content is loaded by LoadContent
97 std::string content_; 97 std::string content_;
98 }; 98 };
99 99
100 typedef std::vector<File> FileList; 100 typedef std::vector<File> FileList;
101 101
102 // Constructor. Default the run location to document end, which is like 102 // Constructor. Default the run location to document end, which is like
103 // Greasemonkey and probably more useful for typical scripts. 103 // Greasemonkey and probably more useful for typical scripts.
104 UserScript() 104 UserScript()
105 : run_location_(DOCUMENT_IDLE), emulate_greasemonkey_(false) { 105 : run_location_(DOCUMENT_IDLE), emulate_greasemonkey_(false),
106 match_all_frames_(false) {
106 } 107 }
107 108
108 const std::string& name_space() const { return name_space_; } 109 const std::string& name_space() const { return name_space_; }
109 void set_name_space(const std::string& name_space) { 110 void set_name_space(const std::string& name_space) {
110 name_space_ = name_space; 111 name_space_ = name_space;
111 } 112 }
112 113
113 const std::string& name() const { return name_; } 114 const std::string& name() const { return name_; }
114 void set_name(const std::string& name) { name_ = name; } 115 void set_name(const std::string& name) { name_ = name; }
115 116
116 const std::string& description() const { return description_; } 117 const std::string& description() const { return description_; }
117 void set_description(const std::string& description) { 118 void set_description(const std::string& description) {
118 description_ = description; 119 description_ = description;
119 } 120 }
120 121
121 // The place in the document to run the script. 122 // The place in the document to run the script.
122 RunLocation run_location() const { return run_location_; } 123 RunLocation run_location() const { return run_location_; }
123 void set_run_location(RunLocation location) { run_location_ = location; } 124 void set_run_location(RunLocation location) { run_location_ = location; }
124 125
125 // Whether to emulate greasemonkey when running this script. 126 // Whether to emulate greasemonkey when running this script.
126 bool emulate_greasemonkey() const { return emulate_greasemonkey_; } 127 bool emulate_greasemonkey() const { return emulate_greasemonkey_; }
127 void set_emulate_greasemonkey(bool val) { emulate_greasemonkey_ = val; } 128 void set_emulate_greasemonkey(bool val) { emulate_greasemonkey_ = val; }
128 129
130 // Whether to match all frames, or only the top one.
131 bool match_all_frames() const { return match_all_frames_; }
132 void set_match_all_frames(bool val) { match_all_frames_ = val; }
133
129 // The globs, if any, that determine which pages this script runs against. 134 // The globs, if any, that determine which pages this script runs against.
130 // These are only used with "standalone" Greasemonkey-like user scripts. 135 // These are only used with "standalone" Greasemonkey-like user scripts.
131 const std::vector<std::string>& globs() const { return globs_; } 136 const std::vector<std::string>& globs() const { return globs_; }
132 void add_glob(const std::string& glob) { globs_.push_back(glob); } 137 void add_glob(const std::string& glob) { globs_.push_back(glob); }
133 void clear_globs() { globs_.clear(); } 138 void clear_globs() { globs_.clear(); }
134 const std::vector<std::string>& exclude_globs() const { 139 const std::vector<std::string>& exclude_globs() const {
135 return exclude_globs_; 140 return exclude_globs_;
136 } 141 }
137 void add_exclude_glob(const std::string& glob) { 142 void add_exclude_glob(const std::string& glob) {
138 exclude_globs_.push_back(glob); 143 exclude_globs_.push_back(glob);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // List of css scripts defined in content_scripts 207 // List of css scripts defined in content_scripts
203 FileList css_scripts_; 208 FileList css_scripts_;
204 209
205 // The ID of the extension this script is a part of, if any. Can be empty if 210 // The ID of the extension this script is a part of, if any. Can be empty if
206 // the script is a "standlone" user script. 211 // the script is a "standlone" user script.
207 std::string extension_id_; 212 std::string extension_id_;
208 213
209 // Whether we should try to emulate Greasemonkey's APIs when running this 214 // Whether we should try to emulate Greasemonkey's APIs when running this
210 // script. 215 // script.
211 bool emulate_greasemonkey_; 216 bool emulate_greasemonkey_;
217
218 // Whether the user script should run in all frames, or only just the top one.
219 // Defaults to false.
220 bool match_all_frames_;
212 }; 221 };
213 222
214 typedef std::vector<UserScript> UserScriptList; 223 typedef std::vector<UserScript> UserScriptList;
215 224
216 #endif // CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ 225 #endif // CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | chrome/common/extensions/user_script.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698