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

Side by Side Diff: chrome/common/extensions/extension_unpacker.cc

Issue 671011: All platforms don't support same locales at the same time. Make locale check ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/common/extensions/extension_unpacker.h" 5 #include "chrome/common/extensions/extension_unpacker.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/scoped_handle.h" 8 #include "base/scoped_handle.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/thread.h" 11 #include "base/thread.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "net/base/file_stream.h" 13 #include "net/base/file_stream.h"
14 #include "chrome/common/common_param_traits.h" 14 #include "chrome/common/common_param_traits.h"
15 #include "chrome/common/extensions/extension.h" 15 #include "chrome/common/extensions/extension.h"
16 #include "chrome/common/extensions/extension_constants.h" 16 #include "chrome/common/extensions/extension_constants.h"
17 #include "chrome/common/extensions/extension_file_util.h" 17 #include "chrome/common/extensions/extension_file_util.h"
18 #include "chrome/common/extensions/extension_l10n_util.h"
18 #include "chrome/common/json_value_serializer.h" 19 #include "chrome/common/json_value_serializer.h"
19 #include "chrome/common/notification_service.h" 20 #include "chrome/common/notification_service.h"
20 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
21 #include "chrome/common/zip.h" 22 #include "chrome/common/zip.h"
22 #include "ipc/ipc_message_utils.h" 23 #include "ipc/ipc_message_utils.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 24 #include "third_party/skia/include/core/SkBitmap.h"
24 #include "webkit/glue/image_decoder.h" 25 #include "webkit/glue/image_decoder.h"
25 26
26 namespace errors = extension_manifest_errors; 27 namespace errors = extension_manifest_errors;
27 namespace keys = extension_manifest_keys; 28 namespace keys = extension_manifest_keys;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 109 }
109 110
110 return static_cast<DictionaryValue*>(root.release()); 111 return static_cast<DictionaryValue*>(root.release());
111 } 112 }
112 113
113 bool ExtensionUnpacker::ReadAllMessageCatalogs( 114 bool ExtensionUnpacker::ReadAllMessageCatalogs(
114 const std::string& default_locale) { 115 const std::string& default_locale) {
115 FilePath locales_path = 116 FilePath locales_path =
116 temp_install_dir_.Append(Extension::kLocaleFolder); 117 temp_install_dir_.Append(Extension::kLocaleFolder);
117 118
118 // Treat all folders under _locales as valid locales. 119 // Not all folders under _locales are valid locales.
119 file_util::FileEnumerator locales(locales_path, 120 file_util::FileEnumerator locales(locales_path,
120 false, 121 false,
121 file_util::FileEnumerator::DIRECTORIES); 122 file_util::FileEnumerator::DIRECTORIES);
122 123
123 FilePath locale_path = locales.Next(); 124 std::set<std::string> all_locales;
124 do { 125 extension_l10n_util::GetAllLocales(&all_locales);
125 // Since we use this string as a key in a DictionaryValue, be paranoid about 126 FilePath locale_path;
126 // skipping any strings with '.'. This happens sometimes, for example with 127 while (!(locale_path = locales.Next()).empty()) {
127 // '.svn' directories. 128 if (extension_l10n_util::ShouldSkipValidation(locales_path, locale_path,
128 FilePath relative_path; 129 all_locales))
129 // message_path was created from temp_install_dir. This should never fail.
130 if (!temp_install_dir_.AppendRelativePath(locale_path, &relative_path))
131 NOTREACHED();
132 std::wstring subdir(relative_path.ToWStringHack());
133 if (std::find(subdir.begin(), subdir.end(), L'.') != subdir.end())
134 continue; 130 continue;
135 131
136 FilePath messages_path = 132 FilePath messages_path =
137 locale_path.Append(Extension::kMessagesFilename); 133 locale_path.Append(Extension::kMessagesFilename);
138 134
139 if (!ReadMessageCatalog(messages_path)) 135 if (!ReadMessageCatalog(messages_path))
140 return false; 136 return false;
141 } while (!(locale_path = locales.Next()).empty()); 137 }
142 138
143 return true; 139 return true;
144 } 140 }
145 141
146 bool ExtensionUnpacker::Run() { 142 bool ExtensionUnpacker::Run() {
147 LOG(INFO) << "Installing extension " << extension_path_.value(); 143 LOG(INFO) << "Installing extension " << extension_path_.value();
148 144
149 // <profile>/Extensions/INSTALL_TEMP/<version> 145 // <profile>/Extensions/INSTALL_TEMP/<version>
150 temp_install_dir_ = 146 temp_install_dir_ =
151 extension_path_.DirName().AppendASCII(kTempExtensionName); 147 extension_path_.DirName().AppendASCII(kTempExtensionName);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 NOTREACHED(); 263 NOTREACHED();
268 264
269 parsed_catalogs_->Set(relative_path.DirName().ToWStringHack(), root); 265 parsed_catalogs_->Set(relative_path.DirName().ToWStringHack(), root);
270 266
271 return true; 267 return true;
272 } 268 }
273 269
274 void ExtensionUnpacker::SetError(const std::string &error) { 270 void ExtensionUnpacker::SetError(const std::string &error) {
275 error_message_ = error; 271 error_message_ = error;
276 } 272 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_l10n_util_unittest.cc ('k') | chrome/common/extensions/extension_unpacker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698