OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 5 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/extensions/tab_helper.h" | 10 #include "chrome/browser/extensions/tab_helper.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 321 |
322 int length = description.length(); | 322 int length = description.length(); |
323 if (style->length) | 323 if (style->length) |
324 length = *style->length; | 324 length = *style->length; |
325 | 325 |
326 size_t offset = style->offset >= 0 ? style->offset : | 326 size_t offset = style->offset >= 0 ? style->offset : |
327 std::max(0, static_cast<int>(description.length()) + style->offset); | 327 std::max(0, static_cast<int>(description.length()) + style->offset); |
328 | 328 |
329 int type_class; | 329 int type_class; |
330 switch (style->type) { | 330 switch (style->type) { |
331 case omnibox::SuggestResult::DescriptionStylesType::TYPE_URL: | 331 case omnibox::DESCRIPTION_STYLE_TYPE_URL: |
332 type_class = AutocompleteMatch::ACMatchClassification::URL; | 332 type_class = AutocompleteMatch::ACMatchClassification::URL; |
333 break; | 333 break; |
334 case omnibox::SuggestResult::DescriptionStylesType::TYPE_MATCH: | 334 case omnibox::DESCRIPTION_STYLE_TYPE_MATCH: |
335 type_class = AutocompleteMatch::ACMatchClassification::MATCH; | 335 type_class = AutocompleteMatch::ACMatchClassification::MATCH; |
336 break; | 336 break; |
337 case omnibox::SuggestResult::DescriptionStylesType::TYPE_DIM: | 337 case omnibox::DESCRIPTION_STYLE_TYPE_DIM: |
338 type_class = AutocompleteMatch::ACMatchClassification::DIM; | 338 type_class = AutocompleteMatch::ACMatchClassification::DIM; |
339 break; | 339 break; |
340 default: | 340 default: |
341 type_class = AutocompleteMatch::ACMatchClassification::NONE; | 341 type_class = AutocompleteMatch::ACMatchClassification::NONE; |
342 return match_classifications; | 342 return match_classifications; |
343 } | 343 } |
344 | 344 |
345 for (size_t j = offset; j < offset + length && j < styles.size(); ++j) | 345 for (size_t j = offset; j < offset + length && j < styles.size(); ++j) |
346 styles[j] |= type_class; | 346 styles[j] |= type_class; |
347 } | 347 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 for (size_t i = 0; i < description_styles.size(); ++i) { | 389 for (size_t i = 0; i < description_styles.size(); ++i) { |
390 if (description_styles[i].offset > placeholder) | 390 if (description_styles[i].offset > placeholder) |
391 description_styles[i].offset += replacement.length() - 2; | 391 description_styles[i].offset += replacement.length() - 2; |
392 } | 392 } |
393 } | 393 } |
394 | 394 |
395 match->contents.assign(description); | 395 match->contents.assign(description); |
396 } | 396 } |
397 | 397 |
398 } // namespace extensions | 398 } // namespace extensions |
OLD | NEW |