OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/user_script_loader.h" | 5 #include "extensions/browser/user_script_loader.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/version.h" | 10 #include "base/version.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 if (!in_metadata) { | 80 if (!in_metadata) { |
81 if (line.starts_with(kUserScriptBegin)) | 81 if (line.starts_with(kUserScriptBegin)) |
82 in_metadata = true; | 82 in_metadata = true; |
83 } else { | 83 } else { |
84 if (line.starts_with(kUserScriptEng)) | 84 if (line.starts_with(kUserScriptEng)) |
85 break; | 85 break; |
86 | 86 |
87 std::string value; | 87 std::string value; |
88 if (GetDeclarationValue(line, kIncludeDeclaration, &value)) { | 88 if (GetDeclarationValue(line, kIncludeDeclaration, &value)) { |
89 // We escape some characters that MatchPattern() considers special. | 89 // We escape some characters that MatchPattern() considers special. |
90 ReplaceSubstringsAfterOffset(&value, 0, "\\", "\\\\"); | 90 base::ReplaceSubstringsAfterOffset(&value, 0, "\\", "\\\\"); |
91 ReplaceSubstringsAfterOffset(&value, 0, "?", "\\?"); | 91 base::ReplaceSubstringsAfterOffset(&value, 0, "?", "\\?"); |
92 script->add_glob(value); | 92 script->add_glob(value); |
93 } else if (GetDeclarationValue(line, kExcludeDeclaration, &value)) { | 93 } else if (GetDeclarationValue(line, kExcludeDeclaration, &value)) { |
94 ReplaceSubstringsAfterOffset(&value, 0, "\\", "\\\\"); | 94 base::ReplaceSubstringsAfterOffset(&value, 0, "\\", "\\\\"); |
95 ReplaceSubstringsAfterOffset(&value, 0, "?", "\\?"); | 95 base::ReplaceSubstringsAfterOffset(&value, 0, "?", "\\?"); |
96 script->add_exclude_glob(value); | 96 script->add_exclude_glob(value); |
97 } else if (GetDeclarationValue(line, kNamespaceDeclaration, &value)) { | 97 } else if (GetDeclarationValue(line, kNamespaceDeclaration, &value)) { |
98 script->set_name_space(value); | 98 script->set_name_space(value); |
99 } else if (GetDeclarationValue(line, kNameDeclaration, &value)) { | 99 } else if (GetDeclarationValue(line, kNameDeclaration, &value)) { |
100 script->set_name(value); | 100 script->set_name(value); |
101 } else if (GetDeclarationValue(line, kVersionDeclaration, &value)) { | 101 } else if (GetDeclarationValue(line, kVersionDeclaration, &value)) { |
102 Version version(value); | 102 Version version(value); |
103 if (version.IsValid()) | 103 if (version.IsValid()) |
104 script->set_version(version.GetString()); | 104 script->set_version(version.GetString()); |
105 } else if (GetDeclarationValue(line, kDescriptionDeclaration, &value)) { | 105 } else if (GetDeclarationValue(line, kDescriptionDeclaration, &value)) { |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) | 397 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) |
398 return; // This can legitimately fail if the renderer asserts at startup. | 398 return; // This can legitimately fail if the renderer asserts at startup. |
399 | 399 |
400 if (base::SharedMemory::IsHandleValid(handle_for_process)) { | 400 if (base::SharedMemory::IsHandleValid(handle_for_process)) { |
401 process->Send(new ExtensionMsg_UpdateUserScripts( | 401 process->Send(new ExtensionMsg_UpdateUserScripts( |
402 handle_for_process, host_id(), changed_hosts, whitelisted_only)); | 402 handle_for_process, host_id(), changed_hosts, whitelisted_only)); |
403 } | 403 } |
404 } | 404 } |
405 | 405 |
406 } // namespace extensions | 406 } // namespace extensions |
OLD | NEW |