summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-11 22:35:56 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-11 22:35:56 +0000
commit098ca94b1a0da99230fcdbb7653f738e286a21a7 (patch)
treea6a1659e7c729d6f90797d67936de6a6e815fa1a /chrome
parentb4e9c1a0aba8ccb23afb461e99e90090845b0a3e (diff)
downloadchromium_src-098ca94b1a0da99230fcdbb7653f738e286a21a7.zip
chromium_src-098ca94b1a0da99230fcdbb7653f738e286a21a7.tar.gz
chromium_src-098ca94b1a0da99230fcdbb7653f738e286a21a7.tar.bz2
Revise the omnibox extension API so that specifying descriptionStyles is easier.
Now each style has a range that it applies to. The styles can also overlap and be listed out of order. BUG=62385 TEST=covered by unit/browser tests Review URL: http://codereview.chromium.org/4660008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extension_omnibox_api.cc122
-rw-r--r--chrome/browser/extensions/extension_omnibox_api.h9
-rw-r--r--chrome/browser/extensions/extension_omnibox_unittest.cc144
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/common/extensions/api/extension_api.json29
-rw-r--r--chrome/common/extensions/docs/examples/extensions/chrome_search/background.html6
-rw-r--r--chrome/common/extensions/docs/experimental.omnibox.html262
-rw-r--r--chrome/renderer/resources/extension_process_bindings.js16
-rw-r--r--chrome/test/data/extensions/api_test/omnibox/test.html6
9 files changed, 391 insertions, 204 deletions
diff --git a/chrome/browser/extensions/extension_omnibox_api.cc b/chrome/browser/extensions/extension_omnibox_api.cc
index 93b44bd..705771f 100644
--- a/chrome/browser/extensions/extension_omnibox_api.cc
+++ b/chrome/browser/extensions/extension_omnibox_api.cc
@@ -30,6 +30,7 @@ const char kSuggestionDescription[] = "description";
const char kSuggestionDescriptionStyles[] = "descriptionStyles";
const char kDescriptionStylesType[] = "type";
const char kDescriptionStylesOffset[] = "offset";
+const char kDescriptionStylesLength[] = "length";
}; // namespace
// static
@@ -103,47 +104,10 @@ bool OmniboxSendSuggestionsFunction::RunImpl() {
ListValue* styles;
EXTENSION_FUNCTION_VALIDATE(
suggestion_value->GetList(kSuggestionDescriptionStyles, &styles));
-
+ EXTENSION_FUNCTION_VALIDATE(suggestion.ReadStylesFromValue(*styles));
+ } else {
suggestion.description_styles.clear();
-
- int last_offset = -1;
- for (size_t j = 0; j < styles->GetSize(); ++j) {
- DictionaryValue* style;
- std::string type;
- int offset;
- EXTENSION_FUNCTION_VALIDATE(styles->GetDictionary(j, &style));
- EXTENSION_FUNCTION_VALIDATE(
- style->GetString(kDescriptionStylesType, &type));
- EXTENSION_FUNCTION_VALIDATE(
- style->GetInteger(kDescriptionStylesOffset, &offset));
-
- int type_class =
- (type == "none") ? ACMatchClassification::NONE :
- (type == "url") ? ACMatchClassification::URL :
- (type == "match") ? ACMatchClassification::MATCH :
- (type == "dim") ? ACMatchClassification::DIM : -1;
- EXTENSION_FUNCTION_VALIDATE(type_class != -1);
-
- if (offset <= last_offset) {
- error_ = kDescriptionStylesOrderError;
- return false;
- }
- if (static_cast<size_t>(offset) >= suggestion.description.length()) {
- error_ = kDescriptionStylesLengthError;
- return false;
- }
-
- suggestion.description_styles.push_back(
- ACMatchClassification(offset, type_class));
- last_offset = offset;
- }
- }
-
- // Ensure the styles cover the whole range of text.
- if (suggestion.description_styles.empty() ||
- suggestion.description_styles[0].offset != 0) {
- suggestion.description_styles.insert(
- suggestion.description_styles.begin(),
+ suggestion.description_styles.push_back(
ACMatchClassification(0, ACMatchClassification::NONE));
}
}
@@ -160,7 +124,83 @@ ExtensionOmniboxSuggestion::ExtensionOmniboxSuggestion() {}
ExtensionOmniboxSuggestion::~ExtensionOmniboxSuggestion() {}
+bool ExtensionOmniboxSuggestion::ReadStylesFromValue(
+ const ListValue& styles_value) {
+ // Start with a NONE style covering the entire range. As we iterate over the
+ // styles, bisect or overwrite the running style list with each new style.
+ description_styles.clear();
+ description_styles.push_back(
+ ACMatchClassification(0, ACMatchClassification::NONE));
+
+ for (size_t i = 0; i < styles_value.GetSize(); ++i) {
+ DictionaryValue* style;
+ std::string type;
+ int offset;
+ int length;
+ if (!styles_value.GetDictionary(i, &style))
+ return false;
+ if (!style->GetString(kDescriptionStylesType, &type))
+ return false;
+ if (!style->GetInteger(kDescriptionStylesOffset, &offset))
+ return false;
+ if (!style->GetInteger(kDescriptionStylesLength, &length))
+ return false;
+
+ int type_class =
+ (type == "url") ? ACMatchClassification::URL :
+ (type == "match") ? ACMatchClassification::MATCH :
+ (type == "dim") ? ACMatchClassification::DIM : -1;
+ if (type_class == -1)
+ return false;
+
+ InsertNewStyle(type_class, offset, length);
+ }
+
+ return true;
+}
+
+void ExtensionOmniboxSuggestion::InsertNewStyle(int type,
+ size_t offset,
+ size_t length) {
+ // Find the first and last existing styles that this new style overlaps. Those
+ // will have to be removed (if they completely overlap), or bisected.
+ size_t start = 0, end = 0;
+ while (end < description_styles.size()) {
+ if (start < description_styles.size() &&
+ description_styles[start].offset < offset)
+ ++start;
+ if (description_styles[end].offset <= offset + length) {
+ ++end;
+ } else {
+ break;
+ }
+ }
+
+ DCHECK_GT(end, 0u);
+ DCHECK(start == description_styles.size() ||
+ description_styles[start].offset >= offset);
+ DCHECK(end == description_styles.size() ||
+ description_styles[end].offset > offset + length);
+
+ // The last style in the overlapping range will come after our new style.
+ int last_style = description_styles[end - 1].style;
+
+ // Remove all overlapping styles.
+ if (start < end) {
+ description_styles.erase(description_styles.begin() + start,
+ description_styles.begin() + end);
+ }
+
+ // Insert our new style.
+ description_styles.insert(description_styles.begin() + start,
+ ACMatchClassification(offset, type));
+ if (offset + length < description.length()) {
+ description_styles.insert(description_styles.begin() + start + 1,
+ ACMatchClassification(offset + length,
+ last_style));
+ }
+}
+
ExtensionOmniboxSuggestions::ExtensionOmniboxSuggestions() : request_id(0) {}
ExtensionOmniboxSuggestions::~ExtensionOmniboxSuggestions() {}
-
diff --git a/chrome/browser/extensions/extension_omnibox_api.h b/chrome/browser/extensions/extension_omnibox_api.h
index 9d0dc99..98758cb 100644
--- a/chrome/browser/extensions/extension_omnibox_api.h
+++ b/chrome/browser/extensions/extension_omnibox_api.h
@@ -49,6 +49,10 @@ struct ExtensionOmniboxSuggestion {
ExtensionOmniboxSuggestion();
~ExtensionOmniboxSuggestion();
+ // Converts a list of style ranges from the extension into the format expected
+ // by the autocomplete system.
+ bool ReadStylesFromValue(const ListValue& value);
+
// The text that gets put in the edit box.
string16 content;
@@ -57,6 +61,11 @@ struct ExtensionOmniboxSuggestion {
// Contains style ranges for the description.
ACMatchClassifications description_styles;
+
+ private:
+ // Helper function to add the given style to the running list of
+ // |description_styles|.
+ void InsertNewStyle(int type, size_t offset, size_t length);
};
struct ExtensionOmniboxSuggestions {
diff --git a/chrome/browser/extensions/extension_omnibox_unittest.cc b/chrome/browser/extensions/extension_omnibox_unittest.cc
new file mode 100644
index 0000000..ca2d1e0
--- /dev/null
+++ b/chrome/browser/extensions/extension_omnibox_unittest.cc
@@ -0,0 +1,144 @@
+// Copyright (c) 2010 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.
+
+#include "base/values.h"
+#include "chrome/browser/extensions/extension_omnibox_api.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/platform_test.h"
+
+namespace {
+
+void AppendStyle(const std::string& type,
+ int offset, int length,
+ ListValue* styles) {
+ DictionaryValue* style = new DictionaryValue;
+ style->SetString("type", type);
+ style->SetInteger("offset", offset);
+ style->SetInteger("length", length);
+ styles->Append(style);
+}
+
+void CompareClassification(const ACMatchClassifications& expected,
+ const ACMatchClassifications& actual) {
+ EXPECT_EQ(expected.size(), actual.size());
+ for (size_t i = 0; i < expected.size() && i < actual.size(); ++i) {
+ EXPECT_EQ(expected[i].offset, actual[i].offset) << "Index:" << i;
+ EXPECT_EQ(expected[i].style, actual[i].style) << "Index:" << i;
+ }
+}
+
+} // namespace
+
+// Test output key: n = character with no styling, d = dim, m = match, u = url
+
+// 0123456789
+// mmmm
+// + ddd
+// = nmmmmndddn
+TEST(ExtensionOmniboxTest, DescriptionStylesSimple) {
+ ListValue styles_value;
+ AppendStyle("match", 1, 4, &styles_value);
+ AppendStyle("dim", 6, 3, &styles_value);
+
+ ACMatchClassifications styles_expected;
+ styles_expected.push_back(
+ ACMatchClassification(0, ACMatchClassification::NONE));
+ styles_expected.push_back(
+ ACMatchClassification(1, ACMatchClassification::MATCH));
+ styles_expected.push_back(
+ ACMatchClassification(5, ACMatchClassification::NONE));
+ styles_expected.push_back(
+ ACMatchClassification(6, ACMatchClassification::DIM));
+ styles_expected.push_back(
+ ACMatchClassification(9, ACMatchClassification::NONE));
+
+ ExtensionOmniboxSuggestion suggestions;
+ suggestions.description.resize(10);
+ EXPECT_TRUE(suggestions.ReadStylesFromValue(styles_value));
+ CompareClassification(styles_expected, suggestions.description_styles);
+
+ // Same input, but swap the order. Ensure it still works.
+ styles_value.Clear();
+ AppendStyle("dim", 6, 3, &styles_value);
+ AppendStyle("match", 1, 4, &styles_value);
+ EXPECT_TRUE(suggestions.ReadStylesFromValue(styles_value));
+ CompareClassification(styles_expected, suggestions.description_styles);
+}
+
+// 0123456789
+// uuuuuu
+// + dd
+// + mm
+// + mmmm
+// + dd
+// = mddmunnnnm
+TEST(ExtensionOmniboxTest, DescriptionStylesOverlap) {
+ ListValue styles_value;
+ AppendStyle("url", 0, 5, &styles_value);
+ AppendStyle("dim", 9, 2, &styles_value);
+ AppendStyle("match", 9, 2, &styles_value);
+ AppendStyle("match", 0, 4, &styles_value);
+ AppendStyle("dim", 1, 2, &styles_value);
+
+ ACMatchClassifications styles_expected;
+ styles_expected.push_back(
+ ACMatchClassification(0, ACMatchClassification::MATCH));
+ styles_expected.push_back(
+ ACMatchClassification(1, ACMatchClassification::DIM));
+ styles_expected.push_back(
+ ACMatchClassification(3, ACMatchClassification::MATCH));
+ styles_expected.push_back(
+ ACMatchClassification(4, ACMatchClassification::URL));
+ styles_expected.push_back(
+ ACMatchClassification(5, ACMatchClassification::NONE));
+ styles_expected.push_back(
+ ACMatchClassification(9, ACMatchClassification::MATCH));
+
+ ExtensionOmniboxSuggestion suggestions;
+ suggestions.description.resize(10);
+ EXPECT_TRUE(suggestions.ReadStylesFromValue(styles_value));
+ CompareClassification(styles_expected, suggestions.description_styles);
+
+ // Try moving the "dim/match" style pair at offset 9. Output should be the
+ // same.
+ styles_value.Clear();
+ AppendStyle("url", 0, 5, &styles_value);
+ AppendStyle("match", 0, 4, &styles_value);
+ AppendStyle("dim", 9, 2, &styles_value);
+ AppendStyle("match", 9, 2, &styles_value);
+ AppendStyle("dim", 1, 2, &styles_value);
+ EXPECT_TRUE(suggestions.ReadStylesFromValue(styles_value));
+ CompareClassification(styles_expected, suggestions.description_styles);
+}
+
+// 0123456789
+// uuuuu
+// + mmmmm
+// + mmm
+// + ddd
+// + ddd
+// = dddddnnnnn
+TEST(ExtensionOmniboxTest, DescriptionStylesOverlap2) {
+ ListValue styles_value;
+ AppendStyle("url", 0, 5, &styles_value);
+ AppendStyle("match", 0, 5, &styles_value);
+ AppendStyle("match", 0, 3, &styles_value);
+ AppendStyle("dim", 2, 3, &styles_value);
+ AppendStyle("dim", 0, 3, &styles_value);
+
+ // We don't merge adjacent identical styles, but the autocomplete system
+ // doesn't mind.
+ ACMatchClassifications styles_expected;
+ styles_expected.push_back(
+ ACMatchClassification(0, ACMatchClassification::DIM));
+ styles_expected.push_back(
+ ACMatchClassification(3, ACMatchClassification::DIM));
+ styles_expected.push_back(
+ ACMatchClassification(5, ACMatchClassification::NONE));
+
+ ExtensionOmniboxSuggestion suggestions;
+ suggestions.description.resize(10);
+ EXPECT_TRUE(suggestions.ReadStylesFromValue(styles_value));
+ CompareClassification(styles_expected, suggestions.description_styles);
+}
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 3755925..81b1abd 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1271,6 +1271,7 @@
'browser/extensions/extension_prefs_unittest.cc',
'browser/extensions/extension_pref_store_unittest.cc',
'browser/extensions/extension_process_manager_unittest.cc',
+ 'browser/extensions/extension_omnibox_unittest.cc',
'browser/extensions/extension_ui_unittest.cc',
'browser/extensions/extension_updater_unittest.cc',
'browser/extensions/extension_webnavigation_unittest.cc',
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index a5ef58f..68c9af0 100644
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -3919,12 +3919,13 @@
"descriptionStyles": {
"type": "array",
"optional": true,
+ "description": "An array of style objects, created using styleUrl, styleMatch, or styleDim. A style applies to the region of text specified by the style's starting offset and length. If there are any overlapping regions of text covered by multiple styles, the last-specified style will be applied to the overlapping region.",
"items": {
"type": "object",
- "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", "url", "match", "dim"]},
- "offset": {"type": "integer"}
+ "type": {"type": "string", "enum": ["url", "match", "dim"]},
+ "offset": {"type": "integer"},
+ "length": {"type": "integer"}
}
}
}
@@ -3949,28 +3950,31 @@
]
},
{
- "name": "styleNone",
- "type": "function",
- "description": "Constructor for the descriptionStyles parameter of the suggest callback.",
- "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} ]
+ "parameters": [
+ {"type": "integer", "name": "offset", "minimum": 0},
+ {"type": "integer", "name": "length", "minimum": 1}
+ ]
},
{
"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.",
- "parameters": [ {"type": "integer", "name": "offset", "minimum": 0} ]
+ "parameters": [
+ {"type": "integer", "name": "offset", "minimum": 0},
+ {"type": "integer", "name": "length", "minimum": 1}
+ ]
},
{
"name": "styleDim",
"type": "function",
"description": "Constructor for the descriptionStyles parameter of the suggest callback. This style designates a region of dim helper text.",
- "parameters": [ {"type": "integer", "name": "offset", "minimum": 0} ]
+ "parameters": [
+ {"type": "integer", "name": "offset", "minimum": 0},
+ {"type": "integer", "name": "length", "minimum": 1}
+ ]
}
],
"events": [
@@ -3994,7 +3998,6 @@
"type": "function",
"description": "A callback passed to the onInputChanged event used for sending suggestions back to the browser.",
"parameters": [
- {"type": "integer", "name": "requestId"},
{
"type": "array",
"description": "Array of suggest results",
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 5dd51b3..1e8afc0 100644
--- a/chrome/common/extensions/docs/examples/extensions/chrome_search/background.html
+++ b/chrome/common/extensions/docs/examples/extensions/chrome_search/background.html
@@ -28,8 +28,7 @@ chrome.experimental.omnibox.onInputChanged.addListener(
description = description.replace(/<\/?.+?>/g, '');
description = file + ': ' + description;
descriptionStyles = [
- chrome.experimental.omnibox.styleUrl(0),
- chrome.experimental.omnibox.styleNone(file.length),
+ chrome.experimental.omnibox.styleUrl(0, file.length),
]
// Highlight all occurrences of the match text.
@@ -39,8 +38,7 @@ chrome.experimental.omnibox.onInputChanged.addListener(
if (index < 0) break;
if (index > file.length) {
descriptionStyles.push(
- chrome.experimental.omnibox.styleMatch(index),
- chrome.experimental.omnibox.styleNone(index + text.length)
+ chrome.experimental.omnibox.styleMatch(index, text.length)
);
}
}
diff --git a/chrome/common/extensions/docs/experimental.omnibox.html b/chrome/common/extensions/docs/experimental.omnibox.html
index b5497d7..e5cf6ba 100644
--- a/chrome/common/extensions/docs/experimental.omnibox.html
+++ b/chrome/common/extensions/docs/experimental.omnibox.html
@@ -282,8 +282,6 @@
</li><li>
<a href="#method-styleMatch">styleMatch</a>
</li><li>
- <a href="#method-styleNone">styleNone</a>
- </li><li>
<a href="#method-styleUrl">styleUrl</a>
</li>
</ol>
@@ -497,7 +495,8 @@ You can find samples of this API on the
<div class="summary"><span style="display: none; ">void</span>
<!-- Note: intentionally longer 80 columns -->
<span>chrome.experimental.omnibox.styleDim</span>(<span class="null"><span style="display: none; ">, </span><span>integer</span>
- <var><span>offset</span></var></span>)</div>
+ <var><span>offset</span></var></span><span class="null"><span>, </span><span>integer</span>
+ <var><span>length</span></var></span>)</div>
<div class="description">
<p class="todo" style="display: none; ">Undocumented.</p>
@@ -566,6 +565,66 @@ You can find samples of this API on the
</dd>
</div>
+ </div><div>
+ <div>
+ <dt>
+ <var>length</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>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
</div>
</dl>
@@ -618,7 +677,8 @@ You can find samples of this API on the
<div class="summary"><span style="display: none; ">void</span>
<!-- Note: intentionally longer 80 columns -->
<span>chrome.experimental.omnibox.styleMatch</span>(<span class="null"><span style="display: none; ">, </span><span>integer</span>
- <var><span>offset</span></var></span>)</div>
+ <var><span>offset</span></var></span><span class="null"><span>, </span><span>integer</span>
+ <var><span>length</span></var></span>)</div>
<div class="description">
<p class="todo" style="display: none; ">Undocumented.</p>
@@ -687,71 +747,10 @@ You can find samples of this API on the
</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><div class="apiItem">
- <a name="method-styleNone"></a> <!-- method-anchor -->
- <h4>styleNone</h4>
-
- <div class="summary"><span style="display: none; ">void</span>
- <!-- Note: intentionally longer 80 columns -->
- <span>chrome.experimental.omnibox.styleNone</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.</p>
-
- <!-- PARAMETERS -->
- <h4>Parameters</h4>
- <dl>
- <div>
+ </div><div>
<div>
<dt>
- <var>offset</var>
+ <var>length</var>
<em>
<!-- TYPE -->
@@ -860,7 +859,8 @@ You can find samples of this API on the
<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>
+ <var><span>offset</span></var></span><span class="null"><span>, </span><span>integer</span>
+ <var><span>length</span></var></span>)</div>
<div class="description">
<p class="todo" style="display: none; ">Undocumented.</p>
@@ -929,6 +929,66 @@ You can find samples of this API on the
</dd>
</div>
+ </div><div>
+ <div>
+ <dt>
+ <var>length</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>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
</div>
</dl>
@@ -1144,66 +1204,6 @@ You can find samples of this API on the
<div>
<div>
<dt>
- <var>requestId</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>
-
- <!-- FUNCTION PARAMETERS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- </div>
- </div><div>
- <div>
- <dt>
<var style="display: none; ">paramName</var>
<em>
@@ -1599,12 +1599,10 @@ You can find samples of this API on the
</em>
</dt>
- <dd class="todo">
+ <dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd style="display: none; ">
- Description of this parameter from the json schema.
- </dd>
+ <dd>An array of style objects, created using styleUrl, styleMatch, or styleDim. A style applies to the region of text specified by the style's starting offset and length. If there are any overlapping regions of text covered by multiple styles, the last-specified style will be applied to the overlapping region.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
diff --git a/chrome/renderer/resources/extension_process_bindings.js b/chrome/renderer/resources/extension_process_bindings.js
index a72068f4..e619217 100644
--- a/chrome/renderer/resources/extension_process_bindings.js
+++ b/chrome/renderer/resources/extension_process_bindings.js
@@ -690,21 +690,17 @@ var chrome = chrome || {};
return newArgs;
};
- apiFunctions["experimental.omnibox.styleNone"].handleRequest =
- function(offset) {
- return {type: "none", offset: offset};
- };
apiFunctions["experimental.omnibox.styleUrl"].handleRequest =
- function(offset) {
- return {type: "url", offset: offset};
+ function(offset, length) {
+ return {type: "url", offset: offset, length: length};
};
apiFunctions["experimental.omnibox.styleMatch"].handleRequest =
- function(offset) {
- return {type: "match", offset: offset};
+ function(offset, length) {
+ return {type: "match", offset: offset, length: length};
};
apiFunctions["experimental.omnibox.styleDim"].handleRequest =
- function(offset) {
- return {type: "dim", offset: offset};
+ function(offset, length) {
+ return {type: "dim", offset: offset, length: length};
};
if (chrome.test) {
diff --git a/chrome/test/data/extensions/api_test/omnibox/test.html b/chrome/test/data/extensions/api_test/omnibox/test.html
index 95cfcc2..6394fab 100644
--- a/chrome/test/data/extensions/api_test/omnibox/test.html
+++ b/chrome/test/data/extensions/api_test/omnibox/test.html
@@ -15,10 +15,8 @@ chrome.omnibox.onInputChanged.addListener(
content: text + "n1",
description: desc,
descriptionStyles: [
- chrome.omnibox.styleMatch(desc.indexOf('<')),
- chrome.omnibox.styleNone(desc.indexOf('>')),
- chrome.omnibox.styleDim(desc.indexOf('[')),
- chrome.omnibox.styleNone(desc.indexOf(']')),
+ chrome.omnibox.styleMatch(desc.indexOf('<'), 6),
+ chrome.omnibox.styleDim(desc.indexOf('['), 4),
]
},
{content: text + "n2", description: "description2"},