OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_EXTENSION_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "base/version.h" | 16 #include "base/version.h" |
17 #include "chrome/browser/extensions/extension_message_handler.h" | |
18 #include "chrome/browser/extensions/user_script_master.h" | |
17 #include "chrome/common/extensions/user_script.h" | 19 #include "chrome/common/extensions/user_script.h" |
18 #include "chrome/browser/extensions/user_script_master.h" | |
19 #include "chrome/common/extensions/url_pattern.h" | 20 #include "chrome/common/extensions/url_pattern.h" |
20 #include "chrome/common/page_action.h" | 21 #include "chrome/common/page_action.h" |
21 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
22 | 23 |
23 // Represents a Chrome extension. | 24 // Represents a Chrome extension. |
24 class Extension { | 25 class Extension { |
25 public: | 26 public: |
26 // What an extension was loaded from. | 27 // What an extension was loaded from. |
27 enum Location { | 28 enum Location { |
28 INVALID, | 29 INVALID, |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 const FilePath& path() const { return path_; } | 185 const FilePath& path() const { return path_; } |
185 void set_path(const FilePath& path) { path_ = path; } | 186 void set_path(const FilePath& path) { path_ = path; } |
186 const GURL& url() const { return extension_url_; } | 187 const GURL& url() const { return extension_url_; } |
187 const Location location() const { return location_; } | 188 const Location location() const { return location_; } |
188 void set_location(Location location) { location_ = location; } | 189 void set_location(Location location) { location_ = location; } |
189 const std::string& id() const { return id_; } | 190 const std::string& id() const { return id_; } |
190 const Version* version() const { return version_.get(); } | 191 const Version* version() const { return version_.get(); } |
191 // String representation of the version number. | 192 // String representation of the version number. |
192 const std::string VersionString() const; | 193 const std::string VersionString() const; |
193 const std::string& name() const { return name_; } | 194 const std::string& name() const { return name_; } |
195 // Sets name to a new value in case it got updated during l10n process. | |
196 void set_name(const std::string& name) { name_ = name; } | |
194 const std::string& public_key() const { return public_key_; } | 197 const std::string& public_key() const { return public_key_; } |
195 const std::string& description() const { return description_; } | 198 const std::string& description() const { return description_; } |
199 // Sets description to a new value in case it got updated during l10n process. | |
200 void set_description(const std::string& description) { | |
201 description_ = description; | |
202 } | |
196 const UserScriptList& content_scripts() const { return content_scripts_; } | 203 const UserScriptList& content_scripts() const { return content_scripts_; } |
197 const PageActionMap& page_actions() const { return page_actions_; } | 204 const PageActionMap& page_actions() const { return page_actions_; } |
198 const std::vector<PrivacyBlacklistInfo>& privacy_blacklists() const { | 205 const std::vector<PrivacyBlacklistInfo>& privacy_blacklists() const { |
199 return privacy_blacklists_; | 206 return privacy_blacklists_; |
200 } | 207 } |
201 const std::vector<PluginInfo>& plugins() const { return plugins_; } | 208 const std::vector<PluginInfo>& plugins() const { return plugins_; } |
202 const GURL& background_url() const { return background_url_; } | 209 const GURL& background_url() const { return background_url_; } |
203 const std::vector<ToolstripInfo>& toolstrips() const { return toolstrips_; } | 210 const std::vector<ToolstripInfo>& toolstrips() const { return toolstrips_; } |
204 const std::vector<URLPattern>& host_permissions() const { | 211 const std::vector<URLPattern>& host_permissions() const { |
205 return host_permissions_; | 212 return host_permissions_; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 void AddSupportedLocale(const std::string& supported_locale) { | 256 void AddSupportedLocale(const std::string& supported_locale) { |
250 supported_locales_.insert(supported_locale); | 257 supported_locales_.insert(supported_locale); |
251 } | 258 } |
252 | 259 |
253 // Getter/setter for a default_locale_. | 260 // Getter/setter for a default_locale_. |
254 const std::string& default_locale() const { return default_locale_; } | 261 const std::string& default_locale() const { return default_locale_; } |
255 void set_default_locale(const std::string& default_locale) { | 262 void set_default_locale(const std::string& default_locale) { |
256 default_locale_ = default_locale; | 263 default_locale_ = default_locale; |
257 } | 264 } |
258 | 265 |
266 // Getter/setter for application_locale. | |
267 const std::string& application_locale() const { return application_locale_; } | |
268 void set_application_locale(const std::string& application_locale) { | |
269 application_locale_ = application_locale; | |
Aaron Boodman
2009/08/31 21:42:55
Why do we need to store a duplicate copy of the ap
| |
270 } | |
271 | |
272 // Getter/setter for l10n message handler. | |
273 const ExtensionMessageHandler* message_handler() const { | |
274 return message_handler_.get(); | |
275 } | |
276 void set_message_handler(ExtensionMessageHandler* message_handler) { | |
277 message_handler_.reset(message_handler); | |
278 } | |
279 | |
259 // Runtime data: | 280 // Runtime data: |
260 // Put dynamic data about the state of a running extension below. | 281 // Put dynamic data about the state of a running extension below. |
261 | 282 |
262 // Whether the background page, if any, is ready. We don't load other | 283 // Whether the background page, if any, is ready. We don't load other |
263 // components until then. If there is no background page, we consider it to | 284 // components until then. If there is no background page, we consider it to |
264 // be ready. | 285 // be ready. |
265 bool GetBackgroundPageReady(); | 286 bool GetBackgroundPageReady(); |
266 void SetBackgroundPageReady(); | 287 void SetBackgroundPageReady(); |
267 | 288 |
268 private: | 289 private: |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 | 390 |
370 // A copy of the manifest that this extension was created from. | 391 // A copy of the manifest that this extension was created from. |
371 scoped_ptr<DictionaryValue> manifest_value_; | 392 scoped_ptr<DictionaryValue> manifest_value_; |
372 | 393 |
373 // List of all locales extension supports. | 394 // List of all locales extension supports. |
374 std::set<std::string> supported_locales_; | 395 std::set<std::string> supported_locales_; |
375 | 396 |
376 // Default locale, used for fallback. | 397 // Default locale, used for fallback. |
377 std::string default_locale_; | 398 std::string default_locale_; |
378 | 399 |
400 // Application locale (from l10n_util::GetApplicationLocale()). | |
401 std::string application_locale_; | |
402 | |
403 // Handles the l10n messages replacement and parsing. | |
404 scoped_ptr<ExtensionMessageHandler> message_handler_; | |
405 | |
379 // Runtime data: | 406 // Runtime data: |
380 | 407 |
381 // True if the background page is ready. | 408 // True if the background page is ready. |
382 bool background_page_ready_; | 409 bool background_page_ready_; |
383 | 410 |
384 FRIEND_TEST(ExtensionTest, LoadPageActionHelper); | 411 FRIEND_TEST(ExtensionTest, LoadPageActionHelper); |
385 | 412 |
386 DISALLOW_COPY_AND_ASSIGN(Extension); | 413 DISALLOW_COPY_AND_ASSIGN(Extension); |
387 }; | 414 }; |
388 | 415 |
389 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 416 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
OLD | NEW |