diff options
46 files changed, 152 insertions, 427 deletions
diff --git a/chrome/common/extensions/api/browserAction.json b/chrome/common/extensions/api/browserAction.json index b21cc99..6288fab 100644 --- a/chrome/common/extensions/api/browserAction.json +++ b/chrome/common/extensions/api/browserAction.json @@ -263,7 +263,7 @@ "parameters": [ { "name": "tab", - "$ref": "tabs.Tab" + "$ref": "Tab" } ] } diff --git a/chrome/common/extensions/api/contextMenus.json b/chrome/common/extensions/api/contextMenus.json index 17c6f27..efebc34 100644 --- a/chrome/common/extensions/api/contextMenus.json +++ b/chrome/common/extensions/api/contextMenus.json @@ -109,7 +109,7 @@ }, { "name": "tab", - "$ref": "tabs.Tab", + "$ref": "Tab", "description": "The details of the tab where the click took place." } ] diff --git a/chrome/common/extensions/api/declarativeWebRequest.json b/chrome/common/extensions/api/declarativeWebRequest.json index c3d19dd..5b65657 100644 --- a/chrome/common/extensions/api/declarativeWebRequest.json +++ b/chrome/common/extensions/api/declarativeWebRequest.json @@ -13,7 +13,7 @@ "description": "Matches network events by various criteria.", "properties": { "url": { - "$ref": "declarative.UrlFilter", + "$ref": "UrlFilter", "description": "Matches if the condition of the UrlFilter are fulfilled for the URL of the request.", "optional": true }, @@ -52,11 +52,8 @@ "options": { "supportsListeners": false, "supportsRules": true, - "conditions": ["declarativeWebRequest.RequestMatcher"], - "actions": [ - "declarativeWebRequest.CancelRequest", - "declarativeWebRequest.RedirectRequest" - ] + "conditions": ["RequestMatcher"], + "actions": ["CancelRequest", "RedirectRequest"] } } ] diff --git a/chrome/common/extensions/api/devtools_api.json b/chrome/common/extensions/api/devtools_api.json index f10e0c8..4d21eed 100644 --- a/chrome/common/extensions/api/devtools_api.json +++ b/chrome/common/extensions/api/devtools_api.json @@ -490,7 +490,7 @@ "description": "A function that is called when the user clicks on a valid resource link in Developer Tools window. Note that if the user clicks an invalid URL or an XHR, this function is not called.", "parameters": [ { - "name": "devtools.inspectedWindow.Resource", + "name": "Resource", "type": "object", "description": "A <a href=\"devtools.inspectedWindow.html#type-Resource\">Resource</a> object for the resource that was clicked." } diff --git a/chrome/common/extensions/api/experimental.bookmarkManager.json b/chrome/common/extensions/api/experimental.bookmarkManager.json index 4ad1415..9d130c8 100644 --- a/chrome/common/extensions/api/experimental.bookmarkManager.json +++ b/chrome/common/extensions/api/experimental.bookmarkManager.json @@ -194,7 +194,7 @@ "name": "callback", "type": "function", "parameters": [ - {"name": "results", "type": "array", "items": { "$ref": "bookmarks.BookmarkTreeNode"} } + {"name": "results", "type": "array", "items": { "$ref": "BookmarkTreeNode"} } ] } ] diff --git a/chrome/common/extensions/api/experimental.infobars.json b/chrome/common/extensions/api/experimental.infobars.json index c8e161e..f7d797d 100644 --- a/chrome/common/extensions/api/experimental.infobars.json +++ b/chrome/common/extensions/api/experimental.infobars.json @@ -40,7 +40,7 @@ "optional": true, "parameters": [ { - "name": "window", "$ref": "windows.Window", "description": "Contains details about the window in which the infobar was created." + "name": "window", "$ref": "Window", "description": "Contains details about the window in which the infobar was created." } ] } diff --git a/chrome/common/extensions/api/extension.json b/chrome/common/extensions/api/extension.json index 1e735ad..59f497c 100644 --- a/chrome/common/extensions/api/extension.json +++ b/chrome/common/extensions/api/extension.json @@ -13,7 +13,7 @@ "type": "object", "description": "An object containing information about the script context that sent a message or request.", "properties": { - "tab": {"$ref": "tabs.Tab", "optional": true, "description":"This property will <b>only</b> be present when the connection was opened from a tab or content script."}, + "tab": {"$ref": "Tab", "optional": true, "description":"This property will <b>only</b> be present when the connection was opened from a tab or content script."}, "id": {"type": "string", "description": "The extension ID of the extension that opened the connection."} } }, diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc index d315a64..5c2ba8b 100644 --- a/chrome/common/extensions/api/extension_api.cc +++ b/chrome/common/extensions/api/extension_api.cc @@ -125,69 +125,6 @@ struct Static { base::LazyInstance<Static> g_lazy_instance = LAZY_INSTANCE_INITIALIZER; -// If it exists and does not already specify a namespace, then the value stored -// with key |key| in |schema| will be updated to |schema_namespace| + "." + -// |schema[key]|. -void MaybePrefixFieldWithNamespace(const std::string& schema_namespace, - DictionaryValue* schema, - const std::string& key) { - if (!schema->HasKey(key)) - return; - - std::string old_id; - CHECK(schema->GetString(key, &old_id)); - if (old_id.find(".") == std::string::npos) - schema->SetString(key, schema_namespace + "." + old_id); -} - -// Modify all "$ref" keys anywhere in |schema| to be prefxied by -// |schema_namespace| if they do not already specify a namespace. -void PrefixRefsWithNamespace(const std::string& schema_namespace, - Value* value) { - if (value->IsType(Value::TYPE_LIST)) { - ListValue* list; - CHECK(value->GetAsList(&list)); - for (ListValue::iterator i = list->begin(); i != list->end(); ++i) { - PrefixRefsWithNamespace(schema_namespace, *i); - } - } else if (value->IsType(Value::TYPE_DICTIONARY)) { - DictionaryValue* dict; - CHECK(value->GetAsDictionary(&dict)); - MaybePrefixFieldWithNamespace(schema_namespace, dict, "$ref"); - for (DictionaryValue::key_iterator i = dict->begin_keys(); - i != dict->end_keys(); ++i) { - Value* next_value; - CHECK(dict->GetWithoutPathExpansion(*i, &next_value)); - PrefixRefsWithNamespace(schema_namespace, next_value); - } - } -} - -// Modify all objects in the "types" section of the schema to be prefixed by -// |schema_namespace| if they do not already specify a namespace. -void PrefixTypesWithNamespace(const std::string& schema_namespace, - DictionaryValue* schema) { - if (!schema->HasKey("types")) - return; - - // Add the namespace to all of the types defined in this schema - ListValue *types; - CHECK(schema->GetList("types", &types)); - for (size_t i = 0; i < types->GetSize(); ++i) { - DictionaryValue *type; - CHECK(types->GetDictionary(i, &type)); - MaybePrefixFieldWithNamespace(schema_namespace, type, "id"); - MaybePrefixFieldWithNamespace(schema_namespace, type, "customBindings"); - } -} - -// Modify the schema so that all types are fully qualified. -void PrefixWithNamespace(const std::string& schema_namespace, - DictionaryValue* schema) { - PrefixTypesWithNamespace(schema_namespace, schema); - PrefixRefsWithNamespace(schema_namespace, schema); -} - } // namespace // static @@ -224,16 +161,15 @@ void ExtensionAPI::LoadSchema(const std::string& name, std::string schema_namespace; while (!schema_list->empty()) { - DictionaryValue* schema = NULL; + const DictionaryValue* schema = NULL; { Value* value = NULL; schema_list->Remove(schema_list->GetSize() - 1, &value); CHECK(value->IsType(Value::TYPE_DICTIONARY)); - schema = static_cast<DictionaryValue*>(value); + schema = static_cast<const DictionaryValue*>(value); } CHECK(schema->GetString("namespace", &schema_namespace)); - PrefixWithNamespace(schema_namespace, schema); schemas_[schema_namespace] = make_linked_ptr(schema); CHECK_EQ(1u, unloaded_schemas_.erase(schema_namespace)); diff --git a/chrome/common/extensions/api/extension_api_unittest.cc b/chrome/common/extensions/api/extension_api_unittest.cc index a0a94e5..e25adb0 100644 --- a/chrome/common/extensions/api/extension_api_unittest.cc +++ b/chrome/common/extensions/api/extension_api_unittest.cc @@ -416,74 +416,5 @@ TEST(ExtensionAPI, FeaturesRequireContexts) { } } -static void GetDictionaryFromList(const DictionaryValue* schema, - const std::string& list_name, - const int list_index, - DictionaryValue** out) { - ListValue* list; - EXPECT_TRUE(schema->GetList(list_name, &list)); - EXPECT_TRUE(list->GetDictionary(list_index, out)); -} - -TEST(ExtensionAPI, TypesHaveNamespace) { - FilePath manifest_path; - PathService::Get(chrome::DIR_TEST_DATA, &manifest_path); - manifest_path = manifest_path.AppendASCII("extensions") - .AppendASCII("extension_api_unittest") - .AppendASCII("types_have_namespace.json"); - - std::string manifest_str; - ASSERT_TRUE(file_util::ReadFileToString(manifest_path, &manifest_str)) - << "Failed to load: " << manifest_path.value(); - - ExtensionAPI api; - api.RegisterSchema("test.foo", manifest_str); - api.LoadAllSchemas(); - - const DictionaryValue* schema = api.GetSchema("test.foo"); - - DictionaryValue* dict; - DictionaryValue* sub_dict; - std::string type; - - GetDictionaryFromList(schema, "types", 0, &dict); - EXPECT_TRUE(dict->GetString("id", &type)); - EXPECT_EQ("test.foo.TestType", type); - EXPECT_TRUE(dict->GetString("customBindings", &type)); - EXPECT_EQ("test.foo.TestType", type); - EXPECT_TRUE(dict->GetDictionary("properties", &sub_dict)); - DictionaryValue* property; - EXPECT_TRUE(sub_dict->GetDictionary("foo", &property)); - EXPECT_TRUE(property->GetString("$ref", &type)); - EXPECT_EQ("test.foo.OtherType", type); - EXPECT_TRUE(sub_dict->GetDictionary("bar", &property)); - EXPECT_TRUE(property->GetString("$ref", &type)); - EXPECT_EQ("fully.qualified.Type", type); - - GetDictionaryFromList(schema, "functions", 0, &dict); - GetDictionaryFromList(dict, "parameters", 0, &sub_dict); - EXPECT_TRUE(sub_dict->GetString("$ref", &type)); - EXPECT_EQ("test.foo.TestType", type); - EXPECT_TRUE(dict->GetDictionary("returns", &sub_dict)); - EXPECT_TRUE(sub_dict->GetString("$ref", &type)); - EXPECT_EQ("fully.qualified.Type", type); - - GetDictionaryFromList(schema, "functions", 1, &dict); - GetDictionaryFromList(dict, "parameters", 0, &sub_dict); - EXPECT_TRUE(sub_dict->GetString("$ref", &type)); - EXPECT_EQ("fully.qualified.Type", type); - EXPECT_TRUE(dict->GetDictionary("returns", &sub_dict)); - EXPECT_TRUE(sub_dict->GetString("$ref", &type)); - EXPECT_EQ("test.foo.TestType", type); - - GetDictionaryFromList(schema, "events", 0, &dict); - GetDictionaryFromList(dict, "parameters", 0, &sub_dict); - EXPECT_TRUE(sub_dict->GetString("$ref", &type)); - EXPECT_EQ("test.foo.TestType", type); - GetDictionaryFromList(dict, "parameters", 1, &sub_dict); - EXPECT_TRUE(sub_dict->GetString("$ref", &type)); - EXPECT_EQ("fully.qualified.Type", type); -} - } // namespace } // namespace extensions diff --git a/chrome/common/extensions/api/pageAction.json b/chrome/common/extensions/api/pageAction.json index 5f0031a..c25a540 100644 --- a/chrome/common/extensions/api/pageAction.json +++ b/chrome/common/extensions/api/pageAction.json @@ -152,7 +152,7 @@ "parameters": [ { "name": "tab", - "$ref": "tabs.Tab" + "$ref": "Tab" } ] } diff --git a/chrome/common/extensions/api/privacy.json b/chrome/common/extensions/api/privacy.json index 721ec0c..c3e144b 100644 --- a/chrome/common/extensions/api/privacy.json +++ b/chrome/common/extensions/api/privacy.json @@ -13,7 +13,7 @@ "description": "Settings that influence Chrome's handling of network connections in general.", "properties": { "networkPredictionEnabled": { - "$ref": "types.ChromeSetting", + "$ref": "ChromeSetting", "value": ["networkPredictionEnabled", {"type":"boolean"}], "description": "If enabled, Chrome attempts to speed up your web browsing experience by pre-resolving DNS entries, prerendering sites (<code><link rel='prefetch' ...></code>), and preemptively opening TCP and SSL connections to servers. This preference's value is a boolean, defaulting to <code>true</code>." } @@ -25,37 +25,37 @@ "description": "Settings that enable or disable features that require third-party network services provided by Google and your default search provider.", "properties": { "alternateErrorPagesEnabled": { - "$ref": "types.ChromeSetting", + "$ref": "ChromeSetting", "value": ["alternateErrorPagesEnabled", {"type":"boolean"}], "description": "If enabled, Chrome uses a web service to help resolve navigation errors. This preference's value is a boolean, defaulting to <code>true</code>." }, "autofillEnabled": { - "$ref": "types.ChromeSetting", + "$ref": "ChromeSetting", "value": ["autofillEnabled", {"type":"boolean"}], "description": "If enabled, Chrome offers to automatically fill in forms. This preference's value is a boolean, defaulting to <code>true</code>." }, "instantEnabled": { - "$ref": "types.ChromeSetting", + "$ref": "ChromeSetting", "value": ["instantEnabled", {"type":"boolean"}], "description": "If enabled, Chrome automatically performs and displays search requests for text you type into the Omnibox as you type it. This preference's value is a boolean, defaulting to <code>true</code>." }, "safeBrowsingEnabled": { - "$ref": "types.ChromeSetting", + "$ref": "ChromeSetting", "value": ["safeBrowsingEnabled", {"type":"boolean"}], "description": "If enabled, Chrome does its best to protect you from phishing and malware. This preference's value is a boolean, defaulting to <code>true</code>." }, "searchSuggestEnabled": { - "$ref": "types.ChromeSetting", + "$ref": "ChromeSetting", "value": ["searchSuggestEnabled", {"type":"boolean"}], "description": "If enabled, Chrome sends the text you type into the Omnibox to your default search engine, which provides predictions of websites and searches that are likely completions of what you've typed so far. This preference's value is a boolean, defaulting to <code>true</code>." }, "spellingServiceEnabled": { - "$ref": "types.ChromeSetting", + "$ref": "ChromeSetting", "value": ["spellingServiceEnabled", {"type":"boolean"}], "description": "If enabled, Chrome uses a web service to help correct spelling errors. This preference's value is a boolean, defaulting to <code>false</code>." }, "translationServiceEnabled": { - "$ref": "types.ChromeSetting", + "$ref": "ChromeSetting", "value": ["translationServiceEnabled", {"type":"boolean"}], "description": "If enabled, Chrome offers to translate pages that aren't in a language you read. This preference's value is a boolean, defaulting to <code>true</code>." } @@ -67,17 +67,17 @@ "description": "Settings that determine what information Chrome makes available to websites.", "properties": { "thirdPartyCookiesAllowed": { - "$ref": "types.ChromeSetting", + "$ref": "ChromeSetting", "value": ["thirdPartyCookiesAllowed", {"type": "boolean"}], "description": "If disabled, Chrome blocks third-party sites from setting cookies. The value of this preference is of type boolean, and the default value is <code>true</code>." }, "hyperlinkAuditingEnabled": { - "$ref": "types.ChromeSetting", + "$ref": "ChromeSetting", "value": ["hyperlinkAuditingEnabled", {"type":"boolean"}], "description": "If enabled, Chrome sends auditing pings when requested by a website (<code><a ping></code>). The value of this preference is of type boolean, and the default value is <code>true</code>." }, "referrersEnabled": { - "$ref": "types.ChromeSetting", + "$ref": "ChromeSetting", "value": ["referrersEnabled", {"type":"boolean"}], "description": "If enabled, Chrome sends <code>referer</code> headers with your requests. Yes, the name of this preference doesn't match the misspelled header. No, we're not going to change it. The value of this preference is of type boolean, and the default value is <code>true</code>." }, diff --git a/chrome/common/extensions/api/proxy.json b/chrome/common/extensions/api/proxy.json index eeb957a..ef8d38a 100644 --- a/chrome/common/extensions/api/proxy.json +++ b/chrome/common/extensions/api/proxy.json @@ -57,7 +57,7 @@ ], "properties": { "settings": { - "$ref": "types.ChromeSetting", + "$ref": "ChromeSetting", "description": "Proxy settings to be used. The value of this setting is a ProxyConfig object.", "value": [ "proxy", diff --git a/chrome/common/extensions/api/tabs.json b/chrome/common/extensions/api/tabs.json index 909230d..848bae4 100644 --- a/chrome/common/extensions/api/tabs.json +++ b/chrome/common/extensions/api/tabs.json @@ -86,7 +86,7 @@ } ], "returns": { - "$ref": "extension.Port", + "$ref": "Port", "description": "A port that can be used to communicate with the content scripts running in the specified tab. The port's <a href='extension.html#type-Port'>onDisconnect</a> event is fired if the tab closes or does not exist. " } }, @@ -371,7 +371,7 @@ "parameters": [ { "name": "window", - "$ref": "windows.Window", + "$ref": "Window", "description": "Contains details about the window whose tabs were highlighted." } ] diff --git a/chrome/common/extensions/api/ttsEngine.json b/chrome/common/extensions/api/ttsEngine.json index 6279ccc..0fbabb9 100644 --- a/chrome/common/extensions/api/ttsEngine.json +++ b/chrome/common/extensions/api/ttsEngine.json @@ -19,7 +19,7 @@ }, { "name": "event", - "$ref": "tts.TtsEvent", + "$ref": "TtsEvent", "description": "The update event from the text-to-speech engine indicating the status of this utterance." } ] @@ -87,7 +87,7 @@ "parameters": [ { "name": "event", - "$ref": "tts.TtsEvent", + "$ref": "TtsEvent", "description": "The event from the text-to-speech engine indicating the status of this utterance." } ] diff --git a/chrome/common/extensions/api/windows.json b/chrome/common/extensions/api/windows.json index 58b6cf2..80fe9cf 100644 --- a/chrome/common/extensions/api/windows.json +++ b/chrome/common/extensions/api/windows.json @@ -17,7 +17,7 @@ "left": {"type": "integer", "description": "The offset of the window from the left edge of the screen in pixels."}, "width": {"type": "integer", "description": "The width of the window in pixels."}, "height": {"type": "integer", "description": "The height of the window in pixels."}, - "tabs": {"type": "array", "items": { "$ref": "tabs.Tab" }, "optional": true, "description": "Array of $ref:tabs.Tab objects representing the current tabs in the window."}, + "tabs": {"type": "array", "items": { "$ref": "Tab" }, "optional": true, "description": "Array of $ref:Tab objects representing the current tabs in the window."}, "incognito": {"type": "boolean", "description": "Whether the window is incognito."}, "type": { "type": "string", @@ -56,7 +56,7 @@ "optional": true, "description": "", "properties": { - "populate": {"type": "boolean", "optional": true, "description": "If true, the window object will have a <var>tabs</var> property that contains a list of the $ref:tabs.Tab objects" } + "populate": {"type": "boolean", "optional": true, "description": "If true, the window object will have a <var>tabs</var> property that contains a list of the $ref:Tab objects" } } }, { @@ -81,7 +81,7 @@ "optional": true, "description": "", "properties": { - "populate": {"type": "boolean", "optional": true, "description": "If true, the window object will have a <var>tabs</var> property that contains a list of the $ref:tabs.Tab objects" } + "populate": {"type": "boolean", "optional": true, "description": "If true, the window object will have a <var>tabs</var> property that contains a list of the $ref:Tab objects" } } }, { @@ -106,7 +106,7 @@ "optional": true, "description": "", "properties": { - "populate": {"type": "boolean", "optional": true, "description": "If true, the window object will have a <var>tabs</var> property that contains a list of the $ref:tabs.Tab objects" } + "populate": {"type": "boolean", "optional": true, "description": "If true, the window object will have a <var>tabs</var> property that contains a list of the $ref:Tab objects" } } }, { @@ -131,7 +131,7 @@ "optional": true, "description": "", "properties": { - "populate": {"type": "boolean", "optional": true, "description": "If true, each window object will have a <var>tabs</var> property that contains a list of the $ref:tabs.Tab objects for that window." } + "populate": {"type": "boolean", "optional": true, "description": "If true, each window object will have a <var>tabs</var> property that contains a list of the $ref:Tab objects for that window." } } }, { diff --git a/chrome/common/extensions/docs/browserAction.html b/chrome/common/extensions/docs/browserAction.html index 341ef27..7a2c5b1 100644 --- a/chrome/common/extensions/docs/browserAction.html +++ b/chrome/common/extensions/docs/browserAction.html @@ -1502,7 +1502,7 @@ For other examples and for help in viewing the source code, see <h4>onClicked</h4> <div class="summary"> <!-- Note: intentionally longer 80 columns --> - <span class="subdued">chrome.browserAction.</span><span>onClicked</span><span class="subdued">.addListener</span>(function(<span>tabs.Tab tab</span>) <span class="subdued">{...}</span><span></span>); + <span class="subdued">chrome.browserAction.</span><span>onClicked</span><span class="subdued">.addListener</span>(function(<span>Tab tab</span>) <span class="subdued">{...}</span><span></span>); </div> <div class="description"> <p>Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup.</p> @@ -1520,7 +1520,7 @@ For other examples and for help in viewing the source code, see ( <span id="typeTemplate"> <span> - <a>tabs.Tab</a> + <a href="tabs.html#type-Tab">Tab</a> </span> </span> ) diff --git a/chrome/common/extensions/docs/contextMenus.html b/chrome/common/extensions/docs/contextMenus.html index 6f146c5..50825e5 100644 --- a/chrome/common/extensions/docs/contextMenus.html +++ b/chrome/common/extensions/docs/contextMenus.html @@ -504,7 +504,7 @@ You can find samples of this API on the ( <span id="typeTemplate"> <span> - <a>tabs.Tab</a> + <a href="tabs.html#type-Tab">Tab</a> </span> </span> ) diff --git a/chrome/common/extensions/docs/declarativeWebRequest.html b/chrome/common/extensions/docs/declarativeWebRequest.html index dbf8450..f39906d 100644 --- a/chrome/common/extensions/docs/declarativeWebRequest.html +++ b/chrome/common/extensions/docs/declarativeWebRequest.html @@ -462,7 +462,7 @@ very fast URL matching algorithm for hundreds of thousands of URLs. <span class="optional">optional</span> <span id="typeTemplate"> <span> - <a>experimental.declarative.UrlFilter</a> + <a href="declarative.html#type-UrlFilter">UrlFilter</a> </span> </span> ) diff --git a/chrome/common/extensions/docs/devtools.panels.html b/chrome/common/extensions/docs/devtools.panels.html index 7acbe14f..94593a0 100644 --- a/chrome/common/extensions/docs/devtools.panels.html +++ b/chrome/common/extensions/docs/devtools.panels.html @@ -629,12 +629,12 @@ You can find examples that use this API in specify a function that looks like this: </p> <!-- Note: intentionally longer 80 columns --> - <pre>function(<span>object devtools.inspectedWindow.Resource</span>) <span class="subdued">{...}</span>;</pre> + <pre>function(<span>object Resource</span>) <span class="subdued">{...}</span>;</pre> <dl> <div> <div> <dt> - <var>devtools.inspectedWindow.Resource</var> + <var>Resource</var> <em> <!-- TYPE --> <div style="display:inline"> diff --git a/chrome/common/extensions/docs/experimental.alarms.html b/chrome/common/extensions/docs/experimental.alarms.html index 994bee2..b020cd1 100644 --- a/chrome/common/extensions/docs/experimental.alarms.html +++ b/chrome/common/extensions/docs/experimental.alarms.html @@ -222,11 +222,11 @@ <a href="#types">Types</a> <ol> <li> - <a href="#type-experimental.alarms.Alarm">experimental.alarms.Alarm</a> + <a href="#type-Alarm">Alarm</a> <ol> </ol> </li><li> - <a href="#type-experimental.alarms.AlarmCreateInfo">experimental.alarms.AlarmCreateInfo</a> + <a href="#type-AlarmCreateInfo">AlarmCreateInfo</a> <ol> </ol> </li> @@ -321,7 +321,7 @@ <div class="summary"> <!-- Note: intentionally longer 80 columns --> <span>chrome.experimental.alarms.create</span>(<span class="optional"><span>string</span> - <var><span>name</span></var></span><span class="null"><span>, </span><span>experimental.alarms.AlarmCreateInfo</span> + <var><span>name</span></var></span><span class="null"><span>, </span><span>AlarmCreateInfo</span> <var><span>alarmInfo</span></var></span>)</div> <div class="description"> <p>Creates an alarm. After the delay is elapsed, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm. string.</p> @@ -362,7 +362,7 @@ ( <span id="typeTemplate"> <span> - <a href="experimental.alarms.html#type-experimental.alarms.AlarmCreateInfo">experimental.alarms.AlarmCreateInfo</a> + <a href="experimental.alarms.html#type-AlarmCreateInfo">AlarmCreateInfo</a> </span> </span> ) @@ -460,7 +460,7 @@ ( <span id="typeTemplate"> <span> - <a href="experimental.alarms.html#type-experimental.alarms.Alarm">experimental.alarms.Alarm</a> + <a href="experimental.alarms.html#type-Alarm">Alarm</a> </span> </span> ) @@ -494,7 +494,7 @@ that looks like this: </p> <!-- Note: intentionally longer 80 columns --> - <pre>function(<span>experimental.alarms.Alarm alarm</span>) <span class="subdued">{...}</span>;</pre> + <pre>function(<span>Alarm alarm</span>) <span class="subdued">{...}</span>;</pre> <dl> <div> <div> @@ -506,7 +506,7 @@ ( <span id="typeTemplate"> <span> - <a href="experimental.alarms.html#type-experimental.alarms.Alarm">experimental.alarms.Alarm</a> + <a href="experimental.alarms.html#type-Alarm">Alarm</a> </span> </span> ) @@ -580,7 +580,7 @@ <span> array of <span><span> <span> - <a href="experimental.alarms.html#type-experimental.alarms.Alarm">experimental.alarms.Alarm</a> + <a href="experimental.alarms.html#type-Alarm">Alarm</a> </span> </span></span> </span> @@ -617,7 +617,7 @@ that looks like this: </p> <!-- Note: intentionally longer 80 columns --> - <pre>function(<span>array of experimental.alarms.Alarm alarms</span>) <span class="subdued">{...}</span>;</pre> + <pre>function(<span>array of Alarm alarms</span>) <span class="subdued">{...}</span>;</pre> <dl> <div> <div> @@ -632,7 +632,7 @@ <span> array of <span><span> <span> - <a href="experimental.alarms.html#type-experimental.alarms.Alarm">experimental.alarms.Alarm</a> + <a href="experimental.alarms.html#type-Alarm">Alarm</a> </span> </span></span> </span> @@ -668,7 +668,7 @@ <h4>onAlarm</h4> <div class="summary"> <!-- Note: intentionally longer 80 columns --> - <span class="subdued">chrome.experimental.alarms.</span><span>onAlarm</span><span class="subdued">.addListener</span>(function(<span>experimental.alarms.Alarm alarm</span>) <span class="subdued">{...}</span><span></span>); + <span class="subdued">chrome.experimental.alarms.</span><span>onAlarm</span><span class="subdued">.addListener</span>(function(<span>Alarm alarm</span>) <span class="subdued">{...}</span><span></span>); </div> <div class="description"> <p>Fired when an alarm has elapsed. Useful for transient background pages.</p> @@ -686,7 +686,7 @@ ( <span id="typeTemplate"> <span> - <a href="experimental.alarms.html#type-experimental.alarms.Alarm">experimental.alarms.Alarm</a> + <a href="experimental.alarms.html#type-Alarm">Alarm</a> </span> </span> ) @@ -715,8 +715,8 @@ <h3 id="types">Types</h3> <!-- iterates over all types --> <div class="apiItem"> - <a name="type-experimental.alarms.Alarm"></a> - <h4>experimental.alarms.Alarm</h4> + <a name="type-Alarm"></a> + <h4>Alarm</h4> <div> <dt> <em> @@ -815,8 +815,8 @@ <!-- FUNCTION PARAMETERS --> </div> </div><div class="apiItem"> - <a name="type-experimental.alarms.AlarmCreateInfo"></a> - <h4>experimental.alarms.AlarmCreateInfo</h4> + <a name="type-AlarmCreateInfo"></a> + <h4>AlarmCreateInfo</h4> <div> <dt> <em> diff --git a/chrome/common/extensions/docs/experimental.infobars.html b/chrome/common/extensions/docs/experimental.infobars.html index 467440a..a7bb557 100644 --- a/chrome/common/extensions/docs/experimental.infobars.html +++ b/chrome/common/extensions/docs/experimental.infobars.html @@ -423,7 +423,7 @@ For example: specify a function that looks like this: </p> <!-- Note: intentionally longer 80 columns --> - <pre>function(<span>windows.Window window</span>) <span class="subdued">{...}</span>;</pre> + <pre>function(<span>Window window</span>) <span class="subdued">{...}</span>;</pre> <dl> <div> <div> @@ -435,7 +435,7 @@ For example: ( <span id="typeTemplate"> <span> - <a>windows.Window</a> + <a href="windows.html#type-Window">Window</a> </span> </span> ) diff --git a/chrome/common/extensions/docs/extension.html b/chrome/common/extensions/docs/extension.html index 4c19a17..fbcad44 100644 --- a/chrome/common/extensions/docs/extension.html +++ b/chrome/common/extensions/docs/extension.html @@ -1605,7 +1605,7 @@ For details, see <span class="optional">optional</span> <span id="typeTemplate"> <span> - <a>tabs.Tab</a> + <a href="tabs.html#type-Tab">Tab</a> </span> </span> ) diff --git a/chrome/common/extensions/docs/pageAction.html b/chrome/common/extensions/docs/pageAction.html index 19ecd8f..4bd5254 100644 --- a/chrome/common/extensions/docs/pageAction.html +++ b/chrome/common/extensions/docs/pageAction.html @@ -1060,7 +1060,7 @@ For other examples and for help in viewing the source code, see <h4>onClicked</h4> <div class="summary"> <!-- Note: intentionally longer 80 columns --> - <span class="subdued">chrome.pageAction.</span><span>onClicked</span><span class="subdued">.addListener</span>(function(<span>tabs.Tab tab</span>) <span class="subdued">{...}</span><span></span>); + <span class="subdued">chrome.pageAction.</span><span>onClicked</span><span class="subdued">.addListener</span>(function(<span>Tab tab</span>) <span class="subdued">{...}</span><span></span>); </div> <div class="description"> <p>Fired when a page action icon is clicked. This event will not fire if the page action has a popup.</p> @@ -1078,7 +1078,7 @@ For other examples and for help in viewing the source code, see ( <span id="typeTemplate"> <span> - <a>tabs.Tab</a> + <a href="tabs.html#type-Tab">Tab</a> </span> </span> ) diff --git a/chrome/common/extensions/docs/privacy.html b/chrome/common/extensions/docs/privacy.html index d5f83fc..ccb5867 100644 --- a/chrome/common/extensions/docs/privacy.html +++ b/chrome/common/extensions/docs/privacy.html @@ -469,7 +469,7 @@ ( <span id="typeTemplate"> <span> - <a>types.ChromeSetting</a> + <a href="types.html#type-ChromeSetting">ChromeSetting</a> </span> </span> ) @@ -526,7 +526,7 @@ ( <span id="typeTemplate"> <span> - <a>types.ChromeSetting</a> + <a href="types.html#type-ChromeSetting">ChromeSetting</a> </span> </span> ) @@ -549,7 +549,7 @@ ( <span id="typeTemplate"> <span> - <a>types.ChromeSetting</a> + <a href="types.html#type-ChromeSetting">ChromeSetting</a> </span> </span> ) @@ -572,7 +572,7 @@ ( <span id="typeTemplate"> <span> - <a>types.ChromeSetting</a> + <a href="types.html#type-ChromeSetting">ChromeSetting</a> </span> </span> ) @@ -595,7 +595,7 @@ ( <span id="typeTemplate"> <span> - <a>types.ChromeSetting</a> + <a href="types.html#type-ChromeSetting">ChromeSetting</a> </span> </span> ) @@ -618,7 +618,7 @@ ( <span id="typeTemplate"> <span> - <a>types.ChromeSetting</a> + <a href="types.html#type-ChromeSetting">ChromeSetting</a> </span> </span> ) @@ -641,7 +641,7 @@ ( <span id="typeTemplate"> <span> - <a>types.ChromeSetting</a> + <a href="types.html#type-ChromeSetting">ChromeSetting</a> </span> </span> ) @@ -664,7 +664,7 @@ ( <span id="typeTemplate"> <span> - <a>types.ChromeSetting</a> + <a href="types.html#type-ChromeSetting">ChromeSetting</a> </span> </span> ) @@ -721,7 +721,7 @@ ( <span id="typeTemplate"> <span> - <a>types.ChromeSetting</a> + <a href="types.html#type-ChromeSetting">ChromeSetting</a> </span> </span> ) @@ -744,7 +744,7 @@ ( <span id="typeTemplate"> <span> - <a>types.ChromeSetting</a> + <a href="types.html#type-ChromeSetting">ChromeSetting</a> </span> </span> ) @@ -767,7 +767,7 @@ ( <span id="typeTemplate"> <span> - <a>types.ChromeSetting</a> + <a href="types.html#type-ChromeSetting">ChromeSetting</a> </span> </span> ) diff --git a/chrome/common/extensions/docs/proxy.html b/chrome/common/extensions/docs/proxy.html index 01ae0f0..5eba638 100644 --- a/chrome/common/extensions/docs/proxy.html +++ b/chrome/common/extensions/docs/proxy.html @@ -468,7 +468,7 @@ identical to the <code>value</code> object passed to callback function of ( <span id="typeTemplate"> <span> - <a>types.ChromeSetting</a> + <a href="types.html#type-ChromeSetting">ChromeSetting</a> </span> </span> ) diff --git a/chrome/common/extensions/docs/tabs.html b/chrome/common/extensions/docs/tabs.html index ba581f5..014798f 100644 --- a/chrome/common/extensions/docs/tabs.html +++ b/chrome/common/extensions/docs/tabs.html @@ -520,7 +520,7 @@ For other examples and for help in viewing the source code, see </div><div class="apiItem"> <a name="method-connect"></a> <!-- method-anchor --> <h4>connect</h4> - <div class="summary"><span>extension.Port</span> + <div class="summary"><span>Port</span> <!-- Note: intentionally longer 80 columns --> <span>chrome.tabs.connect</span>(<span class="null"><span>integer</span> <var><span>tabId</span></var></span><span class="optional"><span>, </span><span>object</span> @@ -624,7 +624,7 @@ For other examples and for help in viewing the source code, see ( <span id="typeTemplate"> <span> - <a>extension.Port</a> + <a href="extension.html#type-Port">Port</a> </span> </span> ) @@ -1539,7 +1539,7 @@ For other examples and for help in viewing the source code, see that looks like this: </p> <!-- Note: intentionally longer 80 columns --> - <pre>function(<span>windows.Window window</span>) <span class="subdued">{...}</span>;</pre> + <pre>function(<span>Window window</span>) <span class="subdued">{...}</span>;</pre> <dl> <div> <div> @@ -1551,7 +1551,7 @@ For other examples and for help in viewing the source code, see ( <span id="typeTemplate"> <span> - <a>windows.Window</a> + <a href="windows.html#type-Window">Window</a> </span> </span> ) diff --git a/chrome/common/extensions/docs/ttsEngine.html b/chrome/common/extensions/docs/ttsEngine.html index dc81ae5..95ed74c 100644 --- a/chrome/common/extensions/docs/ttsEngine.html +++ b/chrome/common/extensions/docs/ttsEngine.html @@ -611,7 +611,7 @@ dynamically decide whether to handle it.</p> ( <span id="typeTemplate"> <span> - <a>tts.TtsEvent</a> + <a href="tts.html#type-TtsEvent">TtsEvent</a> </span> </span> ) diff --git a/chrome/common/extensions/docs/windows.html b/chrome/common/extensions/docs/windows.html index 56b9a65..48ce56c 100644 --- a/chrome/common/extensions/docs/windows.html +++ b/chrome/common/extensions/docs/windows.html @@ -812,7 +812,7 @@ For other examples and for help in viewing the source code, see </div> </em> </dt> - <dd>If true, the window object will have a <var>tabs</var> property that contains a list of the $ref:tabs.Tab objects</dd> + <dd>If true, the window object will have a <var>tabs</var> property that contains a list of the <a href="tabs.html#type-Tab">Tab</a> objects</dd> <!-- OBJECT PROPERTIES --> <!-- OBJECT METHODS --> <!-- OBJECT EVENT FIELDS --> @@ -952,7 +952,7 @@ For other examples and for help in viewing the source code, see </div> </em> </dt> - <dd>If true, each window object will have a <var>tabs</var> property that contains a list of the $ref:tabs.Tab objects for that window.</dd> + <dd>If true, each window object will have a <var>tabs</var> property that contains a list of the <a href="tabs.html#type-Tab">Tab</a> objects for that window.</dd> <!-- OBJECT PROPERTIES --> <!-- OBJECT METHODS --> <!-- OBJECT EVENT FIELDS --> @@ -1098,7 +1098,7 @@ For other examples and for help in viewing the source code, see </div> </em> </dt> - <dd>If true, the window object will have a <var>tabs</var> property that contains a list of the $ref:tabs.Tab objects</dd> + <dd>If true, the window object will have a <var>tabs</var> property that contains a list of the <a href="tabs.html#type-Tab">Tab</a> objects</dd> <!-- OBJECT PROPERTIES --> <!-- OBJECT METHODS --> <!-- OBJECT EVENT FIELDS --> @@ -1238,7 +1238,7 @@ For other examples and for help in viewing the source code, see </div> </em> </dt> - <dd>If true, the window object will have a <var>tabs</var> property that contains a list of the $ref:tabs.Tab objects</dd> + <dd>If true, the window object will have a <var>tabs</var> property that contains a list of the <a href="tabs.html#type-Tab">Tab</a> objects</dd> <!-- OBJECT PROPERTIES --> <!-- OBJECT METHODS --> <!-- OBJECT EVENT FIELDS --> @@ -2045,7 +2045,7 @@ For other examples and for help in viewing the source code, see <span> array of <span><span> <span> - <a>tabs.Tab</a> + <a href="tabs.html#type-Tab">Tab</a> </span> </span></span> </span> @@ -2055,7 +2055,7 @@ For other examples and for help in viewing the source code, see </div> </em> </dt> - <dd>Array of $ref:tabs.Tab objects representing the current tabs in the window.</dd> + <dd>Array of <a href="tabs.html#type-Tab">Tab</a> objects representing the current tabs in the window.</dd> <!-- OBJECT PROPERTIES --> <!-- OBJECT METHODS --> <!-- OBJECT EVENT FIELDS --> diff --git a/chrome/renderer/resources/extensions/content_settings_custom_bindings.js b/chrome/renderer/resources/extensions/content_settings_custom_bindings.js index 826ff45..d07cb69 100644 --- a/chrome/renderer/resources/extensions/content_settings_custom_bindings.js +++ b/chrome/renderer/resources/extensions/content_settings_custom_bindings.js @@ -7,7 +7,7 @@ var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); var sendRequest = require('sendRequest').sendRequest; -chromeHidden.registerCustomType('contentSettings.ContentSetting', function() { +chromeHidden.registerCustomType('ContentSetting', function() { function extendSchema(schema) { var extendedSchema = schema.slice(); extendedSchema.unshift({'type': 'string'}); diff --git a/chrome/renderer/resources/extensions/declarative_webrequest_custom_bindings.js b/chrome/renderer/resources/extensions/declarative_webrequest_custom_bindings.js index 27b70c4..9ae24cc 100644 --- a/chrome/renderer/resources/extensions/declarative_webrequest_custom_bindings.js +++ b/chrome/renderer/resources/extensions/declarative_webrequest_custom_bindings.js @@ -11,9 +11,7 @@ chromeHidden.registerCustomHook('declarativeWebRequest', function(api) { function getSchema(namespace, typeId) { var filterNamespace = function(val) {return val.namespace === namespace;}; var apiSchema = api.apiDefinitions.filter(filterNamespace)[0]; - var filterTypeId = function (val) { - return val.id === namespace + "." + typeId; - }; + var filterTypeId = function (val) {return val.id === typeId;}; var resultSchema = apiSchema.types.filter(filterTypeId)[0]; return resultSchema; } diff --git a/chrome/renderer/resources/extensions/storage_custom_bindings.js b/chrome/renderer/resources/extensions/storage_custom_bindings.js index 7d8eaa1..027017f 100644 --- a/chrome/renderer/resources/extensions/storage_custom_bindings.js +++ b/chrome/renderer/resources/extensions/storage_custom_bindings.js @@ -7,7 +7,7 @@ var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); var sendRequest = require('sendRequest').sendRequest; -chromeHidden.registerCustomType('storage.StorageArea', function() { +chromeHidden.registerCustomType('StorageArea', function() { function extendSchema(schema) { var extendedSchema = schema.slice(); extendedSchema.unshift({'type': 'string'}); diff --git a/chrome/renderer/resources/extensions/types_custom_bindings.js b/chrome/renderer/resources/extensions/types_custom_bindings.js index daf029a..55c88eb 100644 --- a/chrome/renderer/resources/extensions/types_custom_bindings.js +++ b/chrome/renderer/resources/extensions/types_custom_bindings.js @@ -7,7 +7,7 @@ var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); var sendRequest = require('sendRequest').sendRequest; -chromeHidden.registerCustomType('types.ChromeSetting', function() { +chromeHidden.registerCustomType('ChromeSetting', function() { function extendSchema(schema) { var extendedSchema = schema.slice(); diff --git a/chrome/test/data/extensions/extension_api_unittest/types_have_namespace.json b/chrome/test/data/extensions/extension_api_unittest/types_have_namespace.json deleted file mode 100644 index 6b83542..0000000 --- a/chrome/test/data/extensions/extension_api_unittest/types_have_namespace.json +++ /dev/null @@ -1,38 +0,0 @@ -[{ - "namespace":"test.foo", - "types": [ - { - "id": "TestType", - "type": "object", - "customBindings": "TestType", - "properties": { - "foo": {"$ref": "OtherType"}, - "bar": {"$ref": "fully.qualified.Type"} - } - } - ], - "functions": [ - { - "name": "doFoo", - "type": "function", - "parameters": [ { "name": "t", "$ref": "TestType" } ], - "returns": { "$ref": "fully.qualified.Type" } - }, - { - "name": "doBar", - "type": "function", - "parameters": [ { "name": "t", "$ref": "fully.qualified.Type" } ], - "returns": { "$ref": "TestType" } - } - ], - "events": [ - { - "name": "onFoo", - "type": "function", - "parameters": [ - { "name": "t1", "$ref": "TestType" }, - { "name": "t2", "$ref": "fully.qualified.Type" } - ] - } - ] -}] diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py index 508e0f2..3efad84 100644 --- a/tools/json_schema_compiler/cc_generator.py +++ b/tools/json_schema_compiler/cc_generator.py @@ -7,7 +7,6 @@ from model import PropertyType import any_helper import cpp_util import model -import schema_util import sys import util_cc_helper @@ -72,8 +71,8 @@ class CCGenerator(object): .Append() ) for type_ in self._namespace.types.values(): - (c.Concat(self._GenerateType( - schema_util.StripSchemaNamespace(type_.name), type_)).Append() + (c.Concat(self._GenerateType(type_.name, type_)) + .Append() ) if self._namespace.functions: (c.Append('//') @@ -96,7 +95,7 @@ class CCGenerator(object): def _GenerateType(self, cpp_namespace, type_): """Generates the function definitions for a type. """ - classname = cpp_util.Classname(schema_util.StripSchemaNamespace(type_.name)) + classname = cpp_util.Classname(type_.name) c = Code() if type_.functions: @@ -175,7 +174,7 @@ class CCGenerator(object): E.g for type "Foo", generates Foo::Populate() """ - classname = cpp_util.Classname(schema_util.StripSchemaNamespace(type_.name)) + classname = cpp_util.Classname(type_.name) c = Code() (c.Append('// static') .Sblock('bool %(namespace)s::Populate' diff --git a/tools/json_schema_compiler/cpp_type_generator.py b/tools/json_schema_compiler/cpp_type_generator.py index 1d3ac303..5afc915 100644 --- a/tools/json_schema_compiler/cpp_type_generator.py +++ b/tools/json_schema_compiler/cpp_type_generator.py @@ -6,8 +6,6 @@ from code import Code from model import PropertyType import any_helper import cpp_util -import schema_util -import string class CppTypeGenerator(object): """Manages the types of properties and provides utilities for getting the @@ -30,10 +28,12 @@ class CppTypeGenerator(object): beneath the root namespace. """ for type_ in namespace.types: - if type_ in self._type_namespaces: + qualified_name = self._QualifyName(namespace, type_) + if qualified_name in self._type_namespaces: raise ValueError('Type %s is declared in both %s and %s' % - (type_, namespace.name, self._type_namespaces[type_].name)) - self._type_namespaces[type_] = namespace + (qualified_name, namespace.name, + self._type_namespaces[qualified_name].name)) + self._type_namespaces[qualified_name] = namespace self._cpp_namespaces[namespace] = cpp_namespace def GetExpandedChoicesInParams(self, params): @@ -125,9 +125,9 @@ class CppTypeGenerator(object): raise KeyError('Cannot find referenced type: %s' % prop.ref_type) if self._namespace != dependency_namespace: cpp_type = '%s::%s' % (self._cpp_namespaces[dependency_namespace], - schema_util.StripSchemaNamespace(prop.ref_type)) + prop.ref_type) else: - cpp_type = schema_util.StripSchemaNamespace(prop.ref_type) + cpp_type = prop.ref_type elif prop.type_ == PropertyType.BOOLEAN: cpp_type = 'bool' elif prop.type_ == PropertyType.INTEGER: @@ -175,21 +175,20 @@ class CppTypeGenerator(object): for namespace, types in sorted(self._NamespaceTypeDependencies().items()): c.Append('namespace %s {' % namespace.name) for type_ in types: - type_name = schema_util.StripSchemaNamespace(type_) if namespace.types[type_].type_ == PropertyType.STRING: - c.Append('typedef std::string %s;' % type_name) + c.Append('typedef std::string %s;' % type_) elif namespace.types[type_].type_ == PropertyType.ARRAY: c.Append('typedef std::vector<%(item_type)s> %(name)s;') - c.Substitute({'name': type_name, 'item_type': + c.Substitute({'name': type_, 'item_type': self.GetType(namespace.types[type_].item_type, wrap_optional=True)}) else: - c.Append('struct %s;' % type_name) + c.Append('struct %s;' % type_) c.Append('}') c.Concat(self.GetNamespaceStart()) for (name, type_) in self._namespace.types.items(): if not type_.functions and type_.type_ == PropertyType.OBJECT: - c.Append('struct %s;' % schema_util.StripSchemaNamespace(name)) + c.Append('struct %s;' % name) c.Concat(self.GetNamespaceEnd()) return c @@ -204,13 +203,23 @@ class CppTypeGenerator(object): return c def _ResolveTypeNamespace(self, ref_type): - """Resolves a type, which must be explicitly qualified, to its enclosing - namespace. + """Resolves a type name to its enclosing namespace. + + Searches for the ref_type first as an explicitly qualified name, then within + the enclosing namespace, then within other namespaces that the current + namespace depends upon. """ if ref_type in self._type_namespaces: return self._type_namespaces[ref_type] - raise KeyError(('Cannot resolve type: %s.' % ref_type) + - 'Maybe it needs a namespace prefix if it comes from another namespace?') + + qualified_name = self._QualifyName(self._namespace, ref_type) + if qualified_name in self._type_namespaces: + return self._type_namespaces[qualified_name] + + for (type_name, namespace) in self._type_namespaces.items(): + if type_name == self._QualifyName(namespace, ref_type): + return namespace + return None def GetReferencedProperty(self, prop): @@ -224,6 +233,9 @@ class CppTypeGenerator(object): return self._ResolveTypeNamespace(prop.ref_type).types.get(prop.ref_type, None) + def _QualifyName(self, namespace, name): + return '.'.join([namespace.name, name]) + def _NamespaceTypeDependencies(self): """Returns a dict containing a mapping of model.Namespace to the C++ type of type dependencies for self._namespace. diff --git a/tools/json_schema_compiler/cpp_type_generator_test.py b/tools/json_schema_compiler/cpp_type_generator_test.py index 46b10a2..708bd46 100755 --- a/tools/json_schema_compiler/cpp_type_generator_test.py +++ b/tools/json_schema_compiler/cpp_type_generator_test.py @@ -119,27 +119,27 @@ class CppTypeGeneratorTest(unittest.TestCase): manager = CppTypeGenerator('', self.tabs, self.tabs.unix_name) self.assertEquals('int', manager.GetType( - self.tabs.types['tabs.Tab'].properties['id'])) + self.tabs.types['Tab'].properties['id'])) self.assertEquals('std::string', manager.GetType( - self.tabs.types['tabs.Tab'].properties['status'])) + self.tabs.types['Tab'].properties['status'])) self.assertEquals('bool', manager.GetType( - self.tabs.types['tabs.Tab'].properties['selected'])) + self.tabs.types['Tab'].properties['selected'])) def testStringAsType(self): manager = CppTypeGenerator('', self.font_settings, self.font_settings.unix_name) self.assertEquals('std::string', manager.GetType( - self.font_settings.types['fontSettings.ScriptCode'])) + self.font_settings.types['ScriptCode'])) def testArrayAsType(self): manager = CppTypeGenerator('', self.browser_action, self.browser_action.unix_name) self.assertEquals('std::vector<int>', manager.GetType( - self.browser_action.types['browserAction.ColorArray'])) + self.browser_action.types['ColorArray'])) def testGetTypeArray(self): manager = CppTypeGenerator('', self.windows, self.windows.unix_name) @@ -147,8 +147,9 @@ class CppTypeGeneratorTest(unittest.TestCase): manager.GetType( self.windows.functions['getAll'].callback.params[0])) manager = CppTypeGenerator('', self.permissions, self.permissions.unix_name) - self.assertEquals('std::vector<std::string>', manager.GetType( - self.permissions.types['permissions.Permissions'].properties['origins'])) + self.assertEquals('std::vector<std::string>', + manager.GetType( + self.permissions.types['Permissions'].properties['origins'])) def testGetTypeLocalRef(self): manager = CppTypeGenerator('', self.tabs, self.tabs.unix_name) @@ -161,16 +162,16 @@ class CppTypeGeneratorTest(unittest.TestCase): manager.AddNamespace(self.tabs, self.tabs.unix_name) self.assertEquals('std::vector<linked_ptr<tabs::Tab> >', manager.GetType( - self.windows.types['windows.Window'].properties['tabs'])) + self.windows.types['Window'].properties['tabs'])) def testGetTypeNotfound(self): - prop = self.windows.types['windows.Window'].properties['tabs'].item_type + prop = self.windows.types['Window'].properties['tabs'].item_type prop.ref_type = 'Something' manager = CppTypeGenerator('', self.windows, self.windows.unix_name) self.assertRaises(KeyError, manager.GetType, prop) def testGetTypeNotimplemented(self): - prop = self.windows.types['windows.Window'].properties['tabs'].item_type + prop = self.windows.types['Window'].properties['tabs'].item_type prop.type_ = 10 manager = CppTypeGenerator('', self.windows, self.windows.unix_name) self.assertRaises(NotImplementedError, manager.GetType, prop) @@ -179,7 +180,7 @@ class CppTypeGeneratorTest(unittest.TestCase): manager = CppTypeGenerator('', self.permissions, self.permissions.unix_name) self.assertEquals('std::vector<std::string> ', manager.GetType( - self.permissions.types['permissions.Permissions'].properties['origins'], + self.permissions.types['Permissions'].properties['origins'], pad_for_generics=True)) self.assertEquals('bool', manager.GetType( diff --git a/tools/json_schema_compiler/h_generator.py b/tools/json_schema_compiler/h_generator.py index a028813..9ce2868 100644 --- a/tools/json_schema_compiler/h_generator.py +++ b/tools/json_schema_compiler/h_generator.py @@ -7,7 +7,6 @@ from model import PropertyType import cpp_util import model import os -import schema_util class HGenerator(object): """A .h generator for a namespace. @@ -157,7 +156,7 @@ class HGenerator(object): def _GenerateType(self, type_): """Generates a struct for a type. """ - classname = cpp_util.Classname(schema_util.StripSchemaNamespace(type_.name)) + classname = cpp_util.Classname(type_.name) c = Code() if type_.functions: diff --git a/tools/json_schema_compiler/idl_schema.py b/tools/json_schema_compiler/idl_schema.py index bdaa2ca..087b2f4 100644 --- a/tools/json_schema_compiler/idl_schema.py +++ b/tools/json_schema_compiler/idl_schema.py @@ -5,10 +5,8 @@ import json import os.path -import re import sys - -import schema_util +import re # This file is a peer to json_schema.py. Each of these files understands a # certain format describing APIs (either JSON or IDL), reads files written @@ -258,7 +256,6 @@ class IDLSchema(object): continue else: sys.exit("Did not process %s %s" % (node.cls, node)) - schema_util.PrefixSchemasWithNamespace(namespaces) return namespaces def Load(filename): diff --git a/tools/json_schema_compiler/idl_schema_test.py b/tools/json_schema_compiler/idl_schema_test.py index 024f408..d045f62 100755 --- a/tools/json_schema_compiler/idl_schema_test.py +++ b/tools/json_schema_compiler/idl_schema_test.py @@ -33,14 +33,14 @@ class IdlSchemaTest(unittest.TestCase): self.assertEquals(expected, getParams(schema, 'function5')) expected = [{'type':'function', 'name':'Callback3', - 'parameters':[{'name':'arg', '$ref':'idl_basics.MyType1'}]}] + 'parameters':[{'name':'arg', '$ref':'MyType1'}]}] self.assertEquals(expected, getParams(schema, 'function6')) def testCallbackWithArrayArgument(self): schema = self.idl_basics expected = [{'type':'function', 'name':'Callback4', 'parameters':[{'name':'arg', 'type':'array', - 'items':{'$ref':'idl_basics.MyType2'}}]}] + 'items':{'$ref':'MyType2'}}]}] self.assertEquals(expected, getParams(schema, 'function12')) diff --git a/tools/json_schema_compiler/json_schema.py b/tools/json_schema_compiler/json_schema.py index 636f837..f51cece 100644 --- a/tools/json_schema_compiler/json_schema.py +++ b/tools/json_schema_compiler/json_schema.py @@ -10,7 +10,6 @@ import sys _script_path = os.path.realpath(__file__) sys.path.insert(0, os.path.normpath(_script_path + "/../../")) import json_comment_eater -import schema_util def DeleteNocompileNodes(item): def HasNocompile(thing): @@ -33,10 +32,9 @@ def DeleteNocompileNodes(item): def Load(filename): with open(filename, 'r') as handle: - schemas = DeleteNocompileNodes( + return DeleteNocompileNodes( json.loads(json_comment_eater.Nom(handle.read()))) - schema_util.PrefixSchemasWithNamespace(schemas) - return schemas + # A dictionary mapping |filename| to the object resulting from loading the JSON # at |filename|. diff --git a/tools/json_schema_compiler/model_test.py b/tools/json_schema_compiler/model_test.py index 0a15187..577b3ca 100755 --- a/tools/json_schema_compiler/model_test.py +++ b/tools/json_schema_compiler/model_test.py @@ -32,26 +32,25 @@ class ModelTest(unittest.TestCase): sorted(self.permissions.functions.keys())) def testHasTypes(self): - self.assertEquals(['tabs.Tab'], self.tabs.types.keys()) - self.assertEquals(['permissions.Permissions'], - self.permissions.types.keys()) - self.assertEquals(['windows.Window'], self.windows.types.keys()) + self.assertEquals(['Tab'], self.tabs.types.keys()) + self.assertEquals(['Permissions'], self.permissions.types.keys()) + self.assertEquals(['Window'], self.windows.types.keys()) def testHasProperties(self): self.assertEquals(["active", "favIconUrl", "highlighted", "id", "incognito", "index", "pinned", "selected", "status", "title", "url", "windowId"], - sorted(self.tabs.types['tabs.Tab'].properties.keys())) + sorted(self.tabs.types['Tab'].properties.keys())) def testProperties(self): - string_prop = self.tabs.types['tabs.Tab'].properties['status'] + string_prop = self.tabs.types['Tab'].properties['status'] self.assertEquals(model.PropertyType.STRING, string_prop.type_) - integer_prop = self.tabs.types['tabs.Tab'].properties['id'] + integer_prop = self.tabs.types['Tab'].properties['id'] self.assertEquals(model.PropertyType.INTEGER, integer_prop.type_) - array_prop = self.windows.types['windows.Window'].properties['tabs'] + array_prop = self.windows.types['Window'].properties['tabs'] self.assertEquals(model.PropertyType.ARRAY, array_prop.type_) self.assertEquals(model.PropertyType.REF, array_prop.item_type.type_) - self.assertEquals('tabs.Tab', array_prop.item_type.ref_type) + self.assertEquals('Tab', array_prop.item_type.ref_type) object_prop = self.tabs.functions['query'].params[0] self.assertEquals(model.PropertyType.OBJECT, object_prop.type_) self.assertEquals( diff --git a/tools/json_schema_compiler/schema_util.py b/tools/json_schema_compiler/schema_util.py deleted file mode 100644 index 289d24d..0000000 --- a/tools/json_schema_compiler/schema_util.py +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (c) 2012 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -"""Utilies for the processing of schema python structures. -""" - -def StripSchemaNamespace(s): - last_dot = s.rfind('.') - if not last_dot == -1: - return s[last_dot + 1:] - return s - -def PrefixSchemasWithNamespace(schemas): - for s in schemas: - _PrefixWithNamespace(s.get("namespace"), s) - -def _MaybePrefixFieldWithNamespace(namespace, schema, key): - if type(schema) == dict and key in schema: - old_value = schema[key] - if not "." in old_value: - schema[key] = namespace + "." + old_value - -def _PrefixTypesWithNamespace(namespace, types): - for t in types: - _MaybePrefixFieldWithNamespace(namespace, t, "id") - _MaybePrefixFieldWithNamespace(namespace, t, "customBindings") - -def _PrefixWithNamespace(namespace, schema): - if type(schema) == dict: - if "types" in schema: - _PrefixTypesWithNamespace(namespace, schema.get("types")) - _MaybePrefixFieldWithNamespace(namespace, schema, "$ref") - for s in schema: - _PrefixWithNamespace(namespace, schema[s]) - elif type(schema) == list: - for s in schema: - _PrefixWithNamespace(namespace, s) diff --git a/tools/json_schema_compiler/schema_util_test.py b/tools/json_schema_compiler/schema_util_test.py deleted file mode 100755 index ecdd17c..0000000 --- a/tools/json_schema_compiler/schema_util_test.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2012 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import schema_util -import unittest - -class SchemaUtilTest(unittest.TestCase): - def testStripSchemaNamespace(self): - self.assertEquals('Bar', schema_util.StripSchemaNamespace('foo.Bar')) - self.assertEquals('Baz', schema_util.StripSchemaNamespace('Baz')) - - def testPrefixSchemasWithNamespace(self): - schemas = [ - { 'namespace': 'n1', - 'types': [ - { - 'id': 'T1', - 'customBindings': 'T1', - 'properties': { - 'p1': {'$ref': 'T1'}, - 'p2': {'$ref': 'fully.qualified.T'}, - } - } - ], - 'functions': [ - { - 'parameters': [ - { '$ref': 'T1' }, - { '$ref': 'fully.qualified.T' }, - ], - 'returns': { '$ref': 'T1' } - }, - ], - 'events': [ - { - 'parameters': [ - { '$ref': 'T1' }, - { '$ref': 'fully.qualified.T' }, - ], - }, - ], - }, - ] - schema_util.PrefixSchemasWithNamespace(schemas) - self.assertEquals('n1.T1', schemas[0]['types'][0]['id']) - self.assertEquals('n1.T1', schemas[0]['types'][0]['customBindings']) - self.assertEquals('n1.T1', - schemas[0]['types'][0]['properties']['p1']['$ref']) - self.assertEquals('fully.qualified.T', - schemas[0]['types'][0]['properties']['p2']['$ref']) - - self.assertEquals('n1.T1', - schemas[0]['functions'][0]['parameters'][0]['$ref']) - self.assertEquals('fully.qualified.T', - schemas[0]['functions'][0]['parameters'][1]['$ref']) - self.assertEquals('n1.T1', - schemas[0]['functions'][0]['returns']['$ref']) - - self.assertEquals('n1.T1', - schemas[0]['events'][0]['parameters'][0]['$ref']) - self.assertEquals('fully.qualified.T', - schemas[0]['events'][0]['parameters'][1]['$ref']) - -if __name__ == '__main__': - unittest.main() diff --git a/tools/json_schema_compiler/test/crossref.json b/tools/json_schema_compiler/test/crossref.json index 9d3f905..02e5c94 100644 --- a/tools/json_schema_compiler/test/crossref.json +++ b/tools/json_schema_compiler/test/crossref.json @@ -8,7 +8,7 @@ "type": "object", "properties": { "testType": { - "$ref": "simple_api.TestType", + "$ref": "TestType", "optional": true } } @@ -22,7 +22,7 @@ "parameters": [ { "name": "testType", - "$ref": "simple_api.TestType", + "$ref": "TestType", "optional": true }, { @@ -43,7 +43,7 @@ "parameters": [ { "name": "result", - "$ref": "simple_api.TestType", + "$ref": "TestType", "description": "A TestType." } ] @@ -59,7 +59,7 @@ "name": "paramObject", "type": "object", "properties": { - "testType": {"$ref": "simple_api.TestType", "optional": true}, + "testType": {"$ref": "TestType", "optional": true}, "boolean": {"type": "boolean"} } }, diff --git a/tools/json_schema_compiler/test/dependencyTester.json b/tools/json_schema_compiler/test/dependencyTester.json index aec4c15..43b145a 100644 --- a/tools/json_schema_compiler/test/dependencyTester.json +++ b/tools/json_schema_compiler/test/dependencyTester.json @@ -18,10 +18,10 @@ "type": "object", "properties": { "color": { - "$ref": "browserAction.ColorArray" + "$ref": "ColorArray" }, "scriptCode": { - "$ref": "fontSettings.ScriptCode" + "$ref": "ScriptCode" } } } diff --git a/tools/json_schema_compiler/test/windows.json b/tools/json_schema_compiler/test/windows.json index f6062d4..52fc683d 100644 --- a/tools/json_schema_compiler/test/windows.json +++ b/tools/json_schema_compiler/test/windows.json @@ -12,7 +12,7 @@ "left": {"type": "integer", "description": "The offset of the window from the left edge of the screen in pixels."}, "width": {"type": "integer", "description": "The width of the window in pixels."}, "height": {"type": "integer", "description": "The height of the window in pixels."}, - "tabs": {"type": "array", "items": { "$ref": "tabs.Tab" }, "optional": true, "description": "Array of $ref:Tab objects representing the current tabs in the window."}, + "tabs": {"type": "array", "items": { "$ref": "Tab" }, "optional": true, "description": "Array of $ref:Tab objects representing the current tabs in the window."}, "incognito": {"type": "boolean", "description": "Whether the window is incognito."}, "type": { "type": "string", |