| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/extensions/user_script_master.h" | 5 #include "chrome/browser/extensions/user_script_master.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/pickle.h" | 14 #include "base/pickle.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "base/version.h" | 18 #include "base/version.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 21 #include "chrome/browser/extensions/extension_util.h" | 21 #include "chrome/browser/extensions/extension_util.h" |
| 22 #include "chrome/browser/extensions/image_loader.h" | 22 #include "chrome/browser/extensions/image_loader.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" | 24 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" |
| 25 #include "chrome/common/extensions/extension_file_util.h" | |
| 26 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" | 25 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" |
| 27 #include "chrome/common/extensions/message_bundle.h" | |
| 28 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
| 30 #include "extensions/browser/extension_system.h" | 28 #include "extensions/browser/extension_system.h" |
| 31 #include "extensions/common/extension.h" | 29 #include "extensions/common/extension.h" |
| 32 #include "extensions/common/extension_resource.h" | 30 #include "extensions/common/extension_resource.h" |
| 33 #include "extensions/common/extension_set.h" | 31 #include "extensions/common/extension_set.h" |
| 32 #include "extensions/common/file_util.h" |
| 33 #include "extensions/common/message_bundle.h" |
| 34 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
| 35 | 35 |
| 36 using content::BrowserThread; | 36 using content::BrowserThread; |
| 37 | 37 |
| 38 namespace extensions { | 38 namespace extensions { |
| 39 | 39 |
| 40 // Helper function to parse greasesmonkey headers | 40 // Helper function to parse greasesmonkey headers |
| 41 static bool GetDeclarationValue(const base::StringPiece& line, | 41 static bool GetDeclarationValue(const base::StringPiece& line, |
| 42 const base::StringPiece& prefix, | 42 const base::StringPiece& prefix, |
| 43 std::string* value) { | 43 std::string* value) { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 | 252 |
| 253 SubstitutionMap* UserScriptMaster::ScriptReloader::GetLocalizationMessages( | 253 SubstitutionMap* UserScriptMaster::ScriptReloader::GetLocalizationMessages( |
| 254 std::string extension_id) { | 254 std::string extension_id) { |
| 255 if (extensions_info_.find(extension_id) == extensions_info_.end()) { | 255 if (extensions_info_.find(extension_id) == extensions_info_.end()) { |
| 256 return NULL; | 256 return NULL; |
| 257 } | 257 } |
| 258 | 258 |
| 259 return extension_file_util::LoadMessageBundleSubstitutionMap( | 259 return file_util::LoadMessageBundleSubstitutionMap( |
| 260 extensions_info_[extension_id].first, | 260 extensions_info_[extension_id].first, |
| 261 extension_id, | 261 extension_id, |
| 262 extensions_info_[extension_id].second); | 262 extensions_info_[extension_id].second); |
| 263 } | 263 } |
| 264 | 264 |
| 265 // Pickle user scripts and return pointer to the shared memory. | 265 // Pickle user scripts and return pointer to the shared memory. |
| 266 static base::SharedMemory* Serialize(const UserScriptList& scripts) { | 266 static base::SharedMemory* Serialize(const UserScriptList& scripts) { |
| 267 Pickle pickle; | 267 Pickle pickle; |
| 268 pickle.WriteUInt64(scripts.size()); | 268 pickle.WriteUInt64(scripts.size()); |
| 269 for (size_t i = 0; i < scripts.size(); i++) { | 269 for (size_t i = 0; i < scripts.size(); i++) { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 | 457 |
| 458 base::SharedMemoryHandle handle_for_process; | 458 base::SharedMemoryHandle handle_for_process; |
| 459 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) | 459 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) |
| 460 return; // This can legitimately fail if the renderer asserts at startup. | 460 return; // This can legitimately fail if the renderer asserts at startup. |
| 461 | 461 |
| 462 if (base::SharedMemory::IsHandleValid(handle_for_process)) | 462 if (base::SharedMemory::IsHandleValid(handle_for_process)) |
| 463 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process)); | 463 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process)); |
| 464 } | 464 } |
| 465 | 465 |
| 466 } // namespace extensions | 466 } // namespace extensions |
| OLD | NEW |