| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/renderer/searchbox/searchbox.h" | 5 #include "chrome/renderer/searchbox/searchbox.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 return false; | 56 return false; |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 return true; | 59 return true; |
| 60 } | 60 } |
| 61 | 61 |
| 62 const char* GetIconTypeUrlHost(SearchBox::ImageSourceType type) { | 62 const char* GetIconTypeUrlHost(SearchBox::ImageSourceType type) { |
| 63 switch (type) { | 63 switch (type) { |
| 64 case SearchBox::FAVICON: | 64 case SearchBox::FAVICON: |
| 65 return "favicon"; | 65 return "favicon"; |
| 66 case SearchBox::LARGE_ICON: | |
| 67 return "large-icon"; | |
| 68 case SearchBox::FALLBACK_ICON: | |
| 69 return "fallback-icon"; | |
| 70 case SearchBox::THUMB: | 66 case SearchBox::THUMB: |
| 71 return "thumb"; | 67 return "thumb"; |
| 72 default: | 68 default: |
| 73 NOTREACHED(); | 69 NOTREACHED(); |
| 74 } | 70 } |
| 75 return nullptr; | 71 return nullptr; |
| 76 } | 72 } |
| 77 | 73 |
| 78 // Given |path| from an image URL, returns starting index of the page URL, | 74 // Given |path| from an image URL, returns starting index of the page URL, |
| 79 // depending on |type| of image URL. Returns -1 if parse fails. | 75 // depending on |type| of image URL. Returns -1 if parse fails. |
| 80 int GetImagePathStartOfPageURL(SearchBox::ImageSourceType type, | 76 int GetImagePathStartOfPageURL(SearchBox::ImageSourceType type, |
| 81 const std::string& path) { | 77 const std::string& path) { |
| 82 // TODO(huangs): Refactor this: http://crbug.com/468320. | 78 // TODO(huangs): Refactor this: http://crbug.com/468320. |
| 83 switch (type) { | 79 switch (type) { |
| 84 case SearchBox::FAVICON: { | 80 case SearchBox::FAVICON: { |
| 85 chrome::ParsedFaviconPath parsed; | 81 chrome::ParsedFaviconPath parsed; |
| 86 return chrome::ParseFaviconPath(path, &parsed) ? parsed.path_index : -1; | 82 return chrome::ParseFaviconPath(path, &parsed) ? parsed.path_index : -1; |
| 87 } | 83 } |
| 88 case SearchBox::LARGE_ICON: { | |
| 89 LargeIconUrlParser parser; | |
| 90 return parser.Parse(path) ? parser.path_index() : -1; | |
| 91 } | |
| 92 case SearchBox::FALLBACK_ICON: { | |
| 93 chrome::ParsedFallbackIconPath parser; | |
| 94 return parser.Parse(path) ? parser.path_index() : -1; | |
| 95 } | |
| 96 case SearchBox::THUMB: { | 84 case SearchBox::THUMB: { |
| 97 return 0; | 85 return 0; |
| 98 } | 86 } |
| 99 default: { | 87 default: { |
| 100 NOTREACHED(); | 88 NOTREACHED(); |
| 101 break; | 89 break; |
| 102 } | 90 } |
| 103 } | 91 } |
| 104 return -1; | 92 return -1; |
| 105 } | 93 } |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 embedded_search_request_params_ = EmbeddedSearchRequestParams(); | 447 embedded_search_request_params_ = EmbeddedSearchRequestParams(); |
| 460 suggestion_ = InstantSuggestion(); | 448 suggestion_ = InstantSuggestion(); |
| 461 is_focused_ = false; | 449 is_focused_ = false; |
| 462 is_key_capture_enabled_ = false; | 450 is_key_capture_enabled_ = false; |
| 463 theme_info_ = ThemeBackgroundInfo(); | 451 theme_info_ = ThemeBackgroundInfo(); |
| 464 } | 452 } |
| 465 | 453 |
| 466 void SearchBox::OnDestruct() { | 454 void SearchBox::OnDestruct() { |
| 467 delete this; | 455 delete this; |
| 468 } | 456 } |
| OLD | NEW |