Chromium Code Reviews| 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 "content/common/pepper_plugin_list.h" | 5 #include "content/common/pepper_plugin_list.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 47 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 48 switches::kRegisterPepperPlugins); | 48 switches::kRegisterPepperPlugins); |
| 49 if (value.empty()) | 49 if (value.empty()) |
| 50 return; | 50 return; |
| 51 | 51 |
| 52 // FORMAT: | 52 // FORMAT: |
| 53 // command-line = <plugin-entry> + *( LWS + "," + LWS + <plugin-entry> ) | 53 // command-line = <plugin-entry> + *( LWS + "," + LWS + <plugin-entry> ) |
| 54 // plugin-entry = | 54 // plugin-entry = |
| 55 // <file-path> + | 55 // <file-path> + |
| 56 // ["#" + <name> + ["#" + <description> + ["#" + <version>]]] + | 56 // ["#" + <name> + ["#" + <description> + ["#" + <version>]]] + |
| 57 // *1( LWS + ";" + LWS + <mime-type> ) | 57 // *1( LWS + ";" + LWS + <mime-type-data> ) |
| 58 // mime-type-data = <mime-type> + *( LWS + "#" + LWS + <extension> ) | |
|
dcheng
2016/03/22 18:03:05
Nit: I think this should be *1, since there can on
piman
2016/03/23 05:30:24
[] actually. *1 is 1 or more. I intended to suppor
| |
| 58 std::vector<std::string> modules = base::SplitString( | 59 std::vector<std::string> modules = base::SplitString( |
| 59 value, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 60 value, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 60 | 61 |
| 61 size_t plugins_to_register = modules.size(); | 62 size_t plugins_to_register = modules.size(); |
| 62 if (plugins_to_register > kMaxPluginsToRegisterFromCommandLine) { | 63 if (plugins_to_register > kMaxPluginsToRegisterFromCommandLine) { |
| 63 DVLOG(1) << plugins_to_register << " pepper plugins registered from" | 64 DVLOG(1) << plugins_to_register << " pepper plugins registered from" |
| 64 << " command line which exceeds the limit (maximum " | 65 << " command line which exceeds the limit (maximum " |
| 65 << kMaxPluginsToRegisterFromCommandLine << " plugins allowed)"; | 66 << kMaxPluginsToRegisterFromCommandLine << " plugins allowed)"; |
| 66 plugins_to_register = kMaxPluginsToRegisterFromCommandLine; | 67 plugins_to_register = kMaxPluginsToRegisterFromCommandLine; |
| 67 } | 68 } |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 98 } | 99 } |
| 99 } | 100 } |
| 100 | 101 |
| 101 if (name_parts.size() > 1) | 102 if (name_parts.size() > 1) |
| 102 plugin.name = name_parts[1]; | 103 plugin.name = name_parts[1]; |
| 103 if (name_parts.size() > 2) | 104 if (name_parts.size() > 2) |
| 104 plugin.description = name_parts[2]; | 105 plugin.description = name_parts[2]; |
| 105 if (name_parts.size() > 3) | 106 if (name_parts.size() > 3) |
| 106 plugin.version = name_parts[3]; | 107 plugin.version = name_parts[3]; |
| 107 for (size_t j = 1; j < parts.size(); ++j) { | 108 for (size_t j = 1; j < parts.size(); ++j) { |
| 108 WebPluginMimeType mime_type(parts[j], | 109 std::vector<std::string> mime_parts = base::SplitString( |
| 109 std::string(), | 110 parts[j], "#", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 111 DCHECK_GT(mime_parts.size(), 1u); | |
| 112 std::string mime_extension; | |
| 113 if (mime_parts.size() > 1) | |
| 114 mime_extension = mime_parts[1]; | |
| 115 WebPluginMimeType mime_type(mime_parts[0], | |
| 116 mime_extension, | |
| 110 plugin.description); | 117 plugin.description); |
| 111 plugin.mime_types.push_back(mime_type); | 118 plugin.mime_types.push_back(mime_type); |
| 112 } | 119 } |
| 113 | 120 |
| 114 // If the plugin name is empty, use the filename. | 121 // If the plugin name is empty, use the filename. |
| 115 if (plugin.name.empty()) { | 122 if (plugin.name.empty()) { |
| 116 plugin.name = | 123 plugin.name = |
| 117 base::UTF16ToUTF8(plugin.path.BaseName().LossyDisplayName()); | 124 base::UTF16ToUTF8(plugin.path.BaseName().LossyDisplayName()); |
| 118 } | 125 } |
| 119 | 126 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 143 | 150 |
| 144 return true; | 151 return true; |
| 145 } | 152 } |
| 146 | 153 |
| 147 void ComputePepperPluginList(std::vector<PepperPluginInfo>* plugins) { | 154 void ComputePepperPluginList(std::vector<PepperPluginInfo>* plugins) { |
| 148 GetContentClient()->AddPepperPlugins(plugins); | 155 GetContentClient()->AddPepperPlugins(plugins); |
| 149 ComputePluginsFromCommandLine(plugins); | 156 ComputePluginsFromCommandLine(plugins); |
| 150 } | 157 } |
| 151 | 158 |
| 152 } // namespace content | 159 } // namespace content |
| OLD | NEW |