OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/common/user_script.h" | 5 #include "extensions/common/user_script.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
10 #include "base/strings/pattern.h" | 10 #include "base/strings/pattern.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 const char UserScript::kFileExtension[] = ".user.js"; | 45 const char UserScript::kFileExtension[] = ".user.js"; |
46 | 46 |
47 | 47 |
48 // static | 48 // static |
49 int UserScript::GenerateUserScriptID() { | 49 int UserScript::GenerateUserScriptID() { |
50 return g_user_script_id_generator.GetNext(); | 50 return g_user_script_id_generator.GetNext(); |
51 } | 51 } |
52 | 52 |
53 bool UserScript::IsURLUserScript(const GURL& url, | 53 bool UserScript::IsURLUserScript(const GURL& url, |
54 const std::string& mime_type) { | 54 const std::string& mime_type) { |
55 return base::EndsWith(url.ExtractFileName(), kFileExtension, false) && | 55 return base::EndsWith(url.ExtractFileName(), kFileExtension, |
| 56 base::CompareCase::INSENSITIVE_ASCII) && |
56 mime_type != "text/html"; | 57 mime_type != "text/html"; |
57 } | 58 } |
58 | 59 |
59 // static | 60 // static |
60 int UserScript::ValidUserScriptSchemes(bool canExecuteScriptEverywhere) { | 61 int UserScript::ValidUserScriptSchemes(bool canExecuteScriptEverywhere) { |
61 if (canExecuteScriptEverywhere) | 62 if (canExecuteScriptEverywhere) |
62 return URLPattern::SCHEME_ALL; | 63 return URLPattern::SCHEME_ALL; |
63 int valid_schemes = kValidUserScriptSchemes; | 64 int valid_schemes = kValidUserScriptSchemes; |
64 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 65 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
65 switches::kExtensionsOnChromeURLs)) { | 66 switches::kExtensionsOnChromeURLs)) { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 282 } |
282 | 283 |
283 bool operator<(const UserScript& script1, const UserScript& script2) { | 284 bool operator<(const UserScript& script1, const UserScript& script2) { |
284 // The only kind of script that should be compared is the kind that has its | 285 // The only kind of script that should be compared is the kind that has its |
285 // IDs initialized to a meaningful value. | 286 // IDs initialized to a meaningful value. |
286 DCHECK(script1.id() != -1 && script2.id() != -1); | 287 DCHECK(script1.id() != -1 && script2.id() != -1); |
287 return script1.id() < script2.id(); | 288 return script1.id() < script2.id(); |
288 } | 289 } |
289 | 290 |
290 } // namespace extensions | 291 } // namespace extensions |
OLD | NEW |