summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-14 18:23:54 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-14 18:23:54 +0000
commit0434b74ae8d335202a70230120f1c15b2b0ffd91 (patch)
tree92aeccc8850b07258aab15b36275e4253a9b2ecc /chrome/common/extensions
parenta951498d7a926f3fcda318cbe5d34955e4ab8d3e (diff)
downloadchromium_src-0434b74ae8d335202a70230120f1c15b2b0ffd91.zip
chromium_src-0434b74ae8d335202a70230120f1c15b2b0ffd91.tar.gz
chromium_src-0434b74ae8d335202a70230120f1c15b2b0ffd91.tar.bz2
Add chrome.experimental.omnibox.styleUrl for highlighting text as an URL.
Update the chrome code search sample extension to have some fancier highlighting. TEST=none Review URL: http://codereview.chromium.org/2944012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52358 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions')
-rw-r--r--chrome/common/extensions/api/extension_api.json10
-rw-r--r--chrome/common/extensions/docs/examples/extensions/chrome_search/background.html24
-rw-r--r--chrome/common/extensions/docs/examples/extensions/chrome_search/manifest.json1
-rw-r--r--chrome/common/extensions/docs/experimental.omnibox.html117
4 files changed, 144 insertions, 8 deletions
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index 1de35a8..0dc0fd6 100644
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -3074,9 +3074,9 @@
"optional": true,
"items": {
"type": "object",
- "description": "A style object, created using styleNone, styleMatch, or styleDim. A style applies to the region of text starting at the style's offset, until either the next style or the end of the description.",
+ "description": "A style object, created using styleNone, styleUrl, styleMatch, or styleDim. A style applies to the region of text starting at the style's offset, until either the next style or the end of the description.",
"properties": {
- "type": {"type": "string", "enum": ["none", "match", "dim"]},
+ "type": {"type": "string", "enum": ["none", "url", "match", "dim"]},
"offset": {"type": "integer"}
}
}
@@ -3108,6 +3108,12 @@
"parameters": [ {"type": "integer", "name": "offset", "minimum": 0} ]
},
{
+ "name": "styleUrl",
+ "type": "function",
+ "description": "Constructor for the descriptionStyles parameter of the suggest callback. This style designates a region of text matching a URL or filename.",
+ "parameters": [ {"type": "integer", "name": "offset", "minimum": 0} ]
+ },
+ {
"name": "styleMatch",
"type": "function",
"description": "Constructor for the descriptionStyles parameter of the suggest callback. This style designates a region of text matching what the user typed.",
diff --git a/chrome/common/extensions/docs/examples/extensions/chrome_search/background.html b/chrome/common/extensions/docs/examples/extensions/chrome_search/background.html
index 258ee77..5dd51b3 100644
--- a/chrome/common/extensions/docs/examples/extensions/chrome_search/background.html
+++ b/chrome/common/extensions/docs/examples/extensions/chrome_search/background.html
@@ -27,14 +27,28 @@ chrome.experimental.omnibox.onInputChanged.addListener(
var description = entry.getElementsByTagName("content")[0].textContent;
description = description.replace(/<\/?.+?>/g, '');
description = file + ': ' + description;
+ descriptionStyles = [
+ chrome.experimental.omnibox.styleUrl(0),
+ chrome.experimental.omnibox.styleNone(file.length),
+ ]
+
+ // Highlight all occurrences of the match text.
+ var index = -1;
+ for (;;) {
+ var index = description.indexOf(text, index+1);
+ if (index < 0) break;
+ if (index > file.length) {
+ descriptionStyles.push(
+ chrome.experimental.omnibox.styleMatch(index),
+ chrome.experimental.omnibox.styleNone(index + text.length)
+ );
+ }
+ }
results.push({
content: path + '@' + line,
description: description,
- descriptionStyles: [
- chrome.experimental.omnibox.styleMatch(0),
- chrome.experimental.omnibox.styleNone(file.length),
- ],
+ descriptionStyles: descriptionStyles,
});
}
@@ -45,7 +59,7 @@ chrome.experimental.omnibox.onInputChanged.addListener(
function search(query, callback) {
var url = "http://www.google.com/codesearch/feeds/search?" +
- "q=package:git.chromium.org/chromium.git+" + query;
+ "q=package:chromium.git+" + query;
var req = new XMLHttpRequest();
req.open("GET", url, true);
req.setRequestHeader("GData-Version", "2");
diff --git a/chrome/common/extensions/docs/examples/extensions/chrome_search/manifest.json b/chrome/common/extensions/docs/examples/extensions/chrome_search/manifest.json
index ace8a0b..3eee569af 100644
--- a/chrome/common/extensions/docs/examples/extensions/chrome_search/manifest.json
+++ b/chrome/common/extensions/docs/examples/extensions/chrome_search/manifest.json
@@ -5,6 +5,5 @@
"name": "Chromium Search",
"omnibox_keyword": "src",
"permissions": [ "experimental", "tabs", "http://www.google.com/" ],
- "update_url": "http://dl.dropbox.com/u/124107/chromium-search/update.xml",
"version": "4"
}
diff --git a/chrome/common/extensions/docs/experimental.omnibox.html b/chrome/common/extensions/docs/experimental.omnibox.html
index 8d98a71..32ad149 100644
--- a/chrome/common/extensions/docs/experimental.omnibox.html
+++ b/chrome/common/extensions/docs/experimental.omnibox.html
@@ -244,6 +244,8 @@
<a href="#method-styleMatch">styleMatch</a>
</li><li>
<a href="#method-styleNone">styleNone</a>
+ </li><li>
+ <a href="#method-styleUrl">styleUrl</a>
</li>
</ol>
</li>
@@ -725,6 +727,121 @@ see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
</p>
</div> <!-- /description -->
+ </div><div class="apiItem">
+ <a name="method-styleUrl"></a> <!-- method-anchor -->
+ <h4>styleUrl</h4>
+
+ <div class="summary"><span style="display: none; ">void</span>
+ <!-- Note: intentionally longer 80 columns -->
+ <span>chrome.experimental.omnibox.styleUrl</span>(<span class="null"><span style="display: none; ">, </span><span>integer</span>
+ <var><span>offset</span></var></span>)</div>
+
+ <div class="description">
+ <p class="todo" style="display: none; ">Undocumented.</p>
+ <p>Constructor for the descriptionStyles parameter of the suggest callback. This style designates a region of text matching a URL or filename.</p>
+
+ <!-- PARAMETERS -->
+ <h4>Parameters</h4>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>offset</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional" style="display: none; ">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>integer</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo">
+ Undocumented.
+ </dd>
+ <dd style="display: none; ">
+ Description of this parameter from the json schema.
+ </dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+ </div>
+ </div>
+ </dl>
+
+ <!-- RETURNS -->
+ <h4 style="display: none; ">Returns</h4>
+ <dl>
+ <div style="display: none; ">
+ <div>
+ </div>
+ </div>
+ </dl>
+
+ <!-- CALLBACK -->
+ <div style="display: none; ">
+ <div>
+ <h4>Callback function</h4>
+ <p>
+ The callback <em>parameter</em> should specify a function
+ that looks like this:
+ </p>
+ <p>
+ If you specify the <em>callback</em> parameter, it should
+ specify a function that looks like this:
+ </p>
+
+ <!-- Note: intentionally longer 80 columns -->
+ <pre>function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span>);</pre>
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </div>
+ </div>
+
+ <!-- MIN_VERSION -->
+ <p style="display: none; ">
+ This function was added in version <b><span></span></b>.
+ If you require this function, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </p>
+ </div> <!-- /description -->
+
</div> <!-- /apiItem -->
</div> <!-- /apiGroup -->