| Index: extensions/renderer/bindings/api_binding.cc
|
| diff --git a/extensions/renderer/bindings/api_binding.cc b/extensions/renderer/bindings/api_binding.cc
|
| index e69eccab892f4b353b29b5c5192d380ccfb0b138..d5ee62f9c6a8a96aad011e315b1d69bb75a2cc5e 100644
|
| --- a/extensions/renderer/bindings/api_binding.cc
|
| +++ b/extensions/renderer/bindings/api_binding.cc
|
| @@ -30,6 +30,21 @@ namespace extensions {
|
|
|
| namespace {
|
|
|
| +std::string GetPlatformString() {
|
| +#if defined(OS_CHROMEOS)
|
| + return "chromeos";
|
| +#elif defined(OS_LINUX)
|
| + return "linux";
|
| +#elif defined(OS_MACOSX)
|
| + return "mac";
|
| +#elif defined(OS_WIN)
|
| + return "win";
|
| +#else
|
| + NOTREACHED();
|
| + return std::string();
|
| +#endif
|
| +}
|
| +
|
| // Returns the name of the enum value for use in JavaScript; JS enum entries use
|
| // SCREAMING_STYLE.
|
| std::string GetJSEnumEntryName(const std::string& original) {
|
| @@ -428,6 +443,23 @@ void APIBinding::DecorateTemplateWithProperties(
|
| continue;
|
| }
|
|
|
| + const base::ListValue* platforms = nullptr;
|
| + // TODO(devlin): This isn't great. It's bad to have availability primarily
|
| + // defined in the features files, and then partially defined within the
|
| + // API specification itself. Additionally, they aren't equivalent
|
| + // definitions. But given the rarity of property restrictions, and the fact
|
| + // that they are all limited by platform, it makes more sense to isolate
|
| + // this check here. If this becomes more common, we should really find a
|
| + // way of moving these checks to the features files.
|
| + if (dict->GetList("platforms", &platforms)) {
|
| + std::string this_platform = GetPlatformString();
|
| + auto is_this_platform = [&this_platform](const base::Value& platform) {
|
| + return platform.is_string() && platform.GetString() == this_platform;
|
| + };
|
| + if (std::none_of(platforms->begin(), platforms->end(), is_this_platform))
|
| + continue;
|
| + }
|
| +
|
| v8::Local<v8::String> v8_key = gin::StringToSymbol(isolate, iter.key());
|
| std::string ref;
|
| if (dict->GetString("$ref", &ref)) {
|
|
|