| 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 #ifndef CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ | 5 #ifndef CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ |
| 6 #define CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ | 6 #define CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "ui/base/window_open_disposition.h" | 23 #include "ui/base/window_open_disposition.h" |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 | 25 |
| 26 class SearchBox : public content::RenderFrameObserver, | 26 class SearchBox : public content::RenderFrameObserver, |
| 27 public content::RenderFrameObserverTracker<SearchBox>, | 27 public content::RenderFrameObserverTracker<SearchBox>, |
| 28 public chrome::mojom::SearchBox { | 28 public chrome::mojom::SearchBox { |
| 29 public: | 29 public: |
| 30 enum ImageSourceType { | 30 enum ImageSourceType { |
| 31 NONE = -1, | 31 NONE = -1, |
| 32 FAVICON, | 32 FAVICON, |
| 33 LARGE_ICON, | |
| 34 FALLBACK_ICON, | |
| 35 THUMB | 33 THUMB |
| 36 }; | 34 }; |
| 37 | 35 |
| 38 // Helper class for GenerateImageURLFromTransientURL() to adapt SearchBox's | 36 // Helper class for GenerateImageURLFromTransientURL() to adapt SearchBox's |
| 39 // instance, thereby allow mocking for unit tests. | 37 // instance, thereby allow mocking for unit tests. |
| 40 class IconURLHelper { | 38 class IconURLHelper { |
| 41 public: | 39 public: |
| 42 IconURLHelper(); | 40 IconURLHelper(); |
| 43 virtual ~IconURLHelper(); | 41 virtual ~IconURLHelper(); |
| 44 // Retruns view id for validating icon URL. | 42 // Retruns view id for validating icon URL. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 70 // Sends HistorySyncCheck to the browser. | 68 // Sends HistorySyncCheck to the browser. |
| 71 void CheckIsUserSyncingHistory(); | 69 void CheckIsUserSyncingHistory(); |
| 72 | 70 |
| 73 // Sends DeleteMostVisitedItem to the browser. | 71 // Sends DeleteMostVisitedItem to the browser. |
| 74 void DeleteMostVisitedItem(InstantRestrictedID most_visited_item_id); | 72 void DeleteMostVisitedItem(InstantRestrictedID most_visited_item_id); |
| 75 | 73 |
| 76 // Generates the image URL of |type| for the most visited item specified in | 74 // Generates the image URL of |type| for the most visited item specified in |
| 77 // |transient_url|. If |transient_url| is valid, |url| with a translated URL | 75 // |transient_url|. If |transient_url| is valid, |url| with a translated URL |
| 78 // and returns true. Otherwise it depends on |type|: | 76 // and returns true. Otherwise it depends on |type|: |
| 79 // - FAVICON: Returns true and renders an URL to display the default favicon. | 77 // - FAVICON: Returns true and renders an URL to display the default favicon. |
| 80 // - LARGE_ICON and FALLBACK_ICON: Returns false. | |
| 81 // | 78 // |
| 82 // For |type| == FAVICON, valid forms of |transient_url|: | 79 // For |type| == FAVICON, valid forms of |transient_url|: |
| 83 // chrome-search://favicon/<view_id>/<restricted_id> | 80 // chrome-search://favicon/<view_id>/<restricted_id> |
| 84 // chrome-search://favicon/<favicon_parameters>/<view_id>/<restricted_id> | 81 // chrome-search://favicon/<favicon_parameters>/<view_id>/<restricted_id> |
| 85 // | 82 // |
| 86 // For |type| == LARGE_ICON, valid form of |transient_url|: | |
| 87 // chrome-search://large-icon/<size>/<view_id>/<restricted_id> | |
| 88 // | |
| 89 // For |type| == FALLBACK_ICON, valid form of |transient_url|: | |
| 90 // chrome-search://fallback-icon/<icon specs>/<view_id>/<restricted_id> | |
| 91 // | |
| 92 // For |type| == THUMB, valid form of |transient_url|: | 83 // For |type| == THUMB, valid form of |transient_url|: |
| 93 // chrome-search://thumb/<render_view_id>/<most_visited_item_id> | 84 // chrome-search://thumb/<render_view_id>/<most_visited_item_id> |
| 94 // | 85 // |
| 95 // We do this to prevent search providers from abusing image URLs and deduce | 86 // We do this to prevent search providers from abusing image URLs and deduce |
| 96 // whether the user has visited a particular page. For example, if | 87 // whether the user has visited a particular page. For example, if |
| 97 // "chrome-search://favicon/http://www.secretsite.com" is accessible, then | 88 // "chrome-search://favicon/http://www.secretsite.com" is accessible, then |
| 98 // the search provider can use its return code to determine whether the user | 89 // the search provider can use its return code to determine whether the user |
| 99 // has visited "http://www.secretsite.com". Therefore we require search | 90 // has visited "http://www.secretsite.com". Therefore we require search |
| 100 // providers to specify URL by "<view_id>/<restricted_id>". We then translate | 91 // providers to specify URL by "<view_id>/<restricted_id>". We then translate |
| 101 // this to the original |url|, and pass the request to the proper endpoint. | 92 // this to the original |url|, and pass the request to the proper endpoint. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 base::string16 query_; | 166 base::string16 query_; |
| 176 EmbeddedSearchRequestParams embedded_search_request_params_; | 167 EmbeddedSearchRequestParams embedded_search_request_params_; |
| 177 InstantSuggestion suggestion_; | 168 InstantSuggestion suggestion_; |
| 178 chrome::mojom::InstantAssociatedPtr instant_service_; | 169 chrome::mojom::InstantAssociatedPtr instant_service_; |
| 179 mojo::AssociatedBinding<chrome::mojom::SearchBox> binding_; | 170 mojo::AssociatedBinding<chrome::mojom::SearchBox> binding_; |
| 180 | 171 |
| 181 DISALLOW_COPY_AND_ASSIGN(SearchBox); | 172 DISALLOW_COPY_AND_ASSIGN(SearchBox); |
| 182 }; | 173 }; |
| 183 | 174 |
| 184 #endif // CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ | 175 #endif // CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ |
| OLD | NEW |