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

Unified Diff: extensions/common/file_util.cc

Issue 2686463003: [Extensions] Fix a data race in ChromeExtensionMessageFilter. (Closed)
Patch Set: [Extensions] Fix a data race in ChromeExtensionMessageFilter. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: extensions/common/file_util.cc
diff --git a/extensions/common/file_util.cc b/extensions/common/file_util.cc
index 96982d064d9f9f43815f44b00f34fc298902839a..c2212c3dd99992ce4e1b3d461ea17e28615ea22d 100644
--- a/extensions/common/file_util.cc
+++ b/extensions/common/file_util.cc
@@ -38,7 +38,6 @@
#include "extensions/common/manifest_handler.h"
#include "extensions/common/manifest_handlers/default_locale_handler.h"
#include "extensions/common/manifest_handlers/icons_handler.h"
-#include "extensions/common/manifest_handlers/shared_module_info.h"
#include "grit/extensions_strings.h"
#include "net/base/escape.h"
#include "net/base/filename_util.h"
@@ -534,10 +533,10 @@ MessageBundle::SubstitutionMap* LoadMessageBundleSubstitutionMap(
return return_value;
}
-MessageBundle::SubstitutionMap* LoadMessageBundleSubstitutionMapWithImports(
+MessageBundle::SubstitutionMap* LoadMessageBundleSubstitutionMapFromPaths(
atuchin 2017/02/08 05:51:42 In addition: What do you think about implementing
Devlin 2017/02/14 17:45:49 Sounds good to me, now that this no longer does an
atuchin 2017/02/15 08:17:29 Ok, done.
+ const std::vector<base::FilePath>& paths,
const std::string& extension_id,
- const ExtensionSet& extension_set) {
- const Extension* extension = extension_set.GetByID(extension_id);
+ const std::string& default_locale) {
MessageBundle::SubstitutionMap* return_value =
new MessageBundle::SubstitutionMap();
@@ -546,45 +545,17 @@ MessageBundle::SubstitutionMap* LoadMessageBundleSubstitutionMapWithImports(
return_value->insert(
std::make_pair(MessageBundle::kExtensionIdKey, extension_id));
- base::FilePath extension_path;
- std::string default_locale;
- if (!extension) {
- NOTREACHED() << "Missing extension " << extension_id;
- return return_value;
- }
-
// Touch disk only if extension is localized.
- default_locale = LocaleInfo::GetDefaultLocale(extension);
- if (default_locale.empty()) {
+ if (default_locale.empty())
return return_value;
- }
std::string error;
- std::unique_ptr<MessageBundle> bundle(
- LoadMessageBundle(extension->path(), default_locale, &error));
-
- if (bundle.get()) {
- for (auto iter : *bundle->dictionary()) {
- return_value->insert(std::make_pair(iter.first, iter.second));
- }
- }
-
- auto imports = extensions::SharedModuleInfo::GetImports(extension);
- // Iterate through the imports in reverse. This will allow later imported
- // modules to override earlier imported modules, as the list order is
- // maintained from the definition in manifest.json of the imports.
- for (auto it = imports.rbegin(); it != imports.rend(); ++it) {
- const extensions::Extension* imported_extension =
- extension_set.GetByID(it->extension_id);
- if (!imported_extension) {
- NOTREACHED() << "Missing shared module " << it->extension_id;
- continue;
- }
- std::unique_ptr<MessageBundle> imported_bundle(
- LoadMessageBundle(imported_extension->path(), default_locale, &error));
+ for (const base::FilePath& path : paths) {
+ std::unique_ptr<MessageBundle> bundle(
+ LoadMessageBundle(path, default_locale, &error));
- if (imported_bundle.get()) {
- for (auto iter : *imported_bundle->dictionary()) {
+ if (bundle.get()) {
Devlin 2017/02/14 17:45:49 nit: s/bundle.get()/bundle
atuchin 2017/02/15 08:17:29 Done.
+ for (auto iter : *bundle->dictionary()) {
// |insert| only adds new entries, and does not replace entries in
// the main extension or previously processed imports.
return_value->insert(std::make_pair(iter.first, iter.second));

Powered by Google App Engine
This is Rietveld 408576698