diff options
author | cira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-17 18:30:53 +0000 |
---|---|---|
committer | cira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-17 18:30:53 +0000 |
commit | 696044b0f89347690ac2323670a7edf2ad4d2b2a (patch) | |
tree | 663da3b9c0bb0cfc7e37950941837c78937ed2e3 /chrome/browser/net/chrome_url_request_context.h | |
parent | b79d7abdc9e7de5d17beca1ddcbfcd8c20e1cdd4 (diff) | |
download | chromium_src-696044b0f89347690ac2323670a7edf2ad4d2b2a.zip chromium_src-696044b0f89347690ac2323670a7edf2ad4d2b2a.tar.gz chromium_src-696044b0f89347690ac2323670a7edf2ad4d2b2a.tar.bz2 |
Load message catalogs on demand when chrome.i18n.getMessage needs them.
1. Added default locale to the url context
2. Removed old code that was uploading catalogs on load (to renderer)
3. Removed message bundle object from Extension class.
BUG=27361
TEST=Open Chrome with --lang=sr and load src\chrome\common\extensions\docs\examples\api\i18n\getMessage extension from chrome://extensions page. Click on icon and text in popup should be localized.
Review URL: http://codereview.chromium.org/463011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34846 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/chrome_url_request_context.h')
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.h | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index 5d697fc..060626e 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -88,9 +88,11 @@ class ChromeURLRequestContextGetter : public URLRequestContextGetter, // thread before the instance is deleted on the IO thread. void CleanupOnUIThread(); - // These methods simply forward to the corresponding method on + // These methods simply forward to the corresponding methods on // ChromeURLRequestContext. - void OnNewExtensions(const std::string& id, const FilePath& path); + void OnNewExtensions(const std::string& id, + const FilePath& path, + const std::string default_locale); void OnUnloadedExtension(const std::string& id); // NotificationObserver implementation. @@ -146,12 +148,17 @@ class ChromeURLRequestContextGetter : public URLRequestContextGetter, class ChromeURLRequestContext : public URLRequestContext { public: typedef std::map<std::string, FilePath> ExtensionPaths; + typedef std::map<std::string, std::string> ExtensionDefaultLocales; ChromeURLRequestContext(); // Gets the path to the directory for the specified extension. FilePath GetPathForExtension(const std::string& id); + // Returns an empty string if the extension with |id| doesn't have a default + // locale. + std::string GetDefaultLocaleForExtension(const std::string& id); + // Gets the path to the directory user scripts are stored in. FilePath user_script_dir_path() const { return user_script_dir_path_; @@ -173,6 +180,10 @@ class ChromeURLRequestContext : public URLRequestContext { return extension_paths_; } + const ExtensionDefaultLocales& extension_default_locales() const { + return extension_default_locales_; + } + virtual const std::string& GetUserAgent(const GURL& url) const; virtual bool InterceptCookie(const URLRequest* request, std::string* cookie); @@ -185,7 +196,9 @@ class ChromeURLRequestContext : public URLRequestContext { const Blacklist* GetBlacklist() const; // Callback for when new extensions are loaded. - void OnNewExtensions(const std::string& id, const FilePath& path); + void OnNewExtensions(const std::string& id, + const FilePath& path, + const std::string& default_locale); // Callback for when an extension is unloaded. void OnUnloadedExtension(const std::string& id); @@ -246,6 +259,9 @@ class ChromeURLRequestContext : public URLRequestContext { void set_extension_paths(const ExtensionPaths& paths) { extension_paths_ = paths; } + void set_extension_default_locales(const ExtensionDefaultLocales& locales) { + extension_default_locales_ = locales; + } void set_host_zoom_map(HostZoomMap* host_zoom_map) { host_zoom_map_ = host_zoom_map; } @@ -265,9 +281,14 @@ class ChromeURLRequestContext : public URLRequestContext { protected: // Maps extension IDs to paths on disk. This is initialized in the - // construtor and updated when extensions changed. + // constructor and updated when extensions changed. ExtensionPaths extension_paths_; + // Maps extension IDs to default locales. This is initialized in the + // constructor and updated when extensions change. Only extensions that + // have default_locale set are inserted. + ExtensionDefaultLocales extension_default_locales_; + // Path to the directory user scripts are stored in. FilePath user_script_dir_path_; @@ -318,6 +339,7 @@ class ChromeURLRequestContextFactory { std::string referrer_charset_; net::CookiePolicy::Type cookie_policy_type_; ChromeURLRequestContext::ExtensionPaths extension_paths_; + ChromeURLRequestContext::ExtensionDefaultLocales extension_default_locales_; FilePath user_script_dir_path_; scoped_refptr<HostZoomMap> host_zoom_map_; scoped_refptr<BlacklistManager> blacklist_manager_; |