OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // This class contains common functionality for search-based autocomplete | 5 // This class contains common functionality for search-based autocomplete |
6 // providers. Search provider and zero suggest provider both use it for common | 6 // providers. Search provider and zero suggest provider both use it for common |
7 // functionality. | 7 // functionality. |
8 | 8 |
9 #ifndef CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ | 9 #ifndef CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ |
10 #define CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ | 10 #define CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ |
11 | 11 |
12 #include <map> | 12 #include <map> |
13 #include <string> | 13 #include <string> |
14 #include <utility> | 14 #include <utility> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
18 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
19 #include "chrome/browser/autocomplete/autocomplete_input.h" | 19 #include "chrome/browser/autocomplete/autocomplete_input.h" |
20 #include "chrome/browser/autocomplete/autocomplete_match.h" | 20 #include "chrome/browser/autocomplete/autocomplete_match.h" |
21 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 21 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 22 #include "components/metrics/proto/omnibox_event.pb.h" |
22 #include "net/url_request/url_fetcher_delegate.h" | 23 #include "net/url_request/url_fetcher_delegate.h" |
23 | 24 |
24 class AutocompleteProviderListener; | 25 class AutocompleteProviderListener; |
25 class GURL; | 26 class GURL; |
26 class Profile; | 27 class Profile; |
27 class SuggestionDeletionHandler; | 28 class SuggestionDeletionHandler; |
28 class TemplateURL; | 29 class TemplateURL; |
29 | 30 |
30 namespace base { | 31 namespace base { |
31 class ListValue; | 32 class ListValue; |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // * The suggest request is sent over HTTPS. This avoids leaking the current | 372 // * The suggest request is sent over HTTPS. This avoids leaking the current |
372 // page URL or personal data in unencrypted network traffic. | 373 // page URL or personal data in unencrypted network traffic. |
373 // * The user has suggest enabled in their settings and is not in incognito | 374 // * The user has suggest enabled in their settings and is not in incognito |
374 // mode. (Incognito disables suggest entirely.) | 375 // mode. (Incognito disables suggest entirely.) |
375 // * The user's suggest provider is Google. We might want to allow other | 376 // * The user's suggest provider is Google. We might want to allow other |
376 // providers to see this data someday, but for now this has only been | 377 // providers to see this data someday, but for now this has only been |
377 // implemented for Google. | 378 // implemented for Google. |
378 static bool ZeroSuggestEnabled( | 379 static bool ZeroSuggestEnabled( |
379 const GURL& suggest_url, | 380 const GURL& suggest_url, |
380 const TemplateURL* template_url, | 381 const TemplateURL* template_url, |
381 AutocompleteInput::PageClassification page_classification, | 382 metrics::OmniboxEventProto::PageClassification page_classification, |
382 Profile* profile); | 383 Profile* profile); |
383 | 384 |
384 // Returns whether we can send the URL of the current page in any suggest | 385 // Returns whether we can send the URL of the current page in any suggest |
385 // requests. Doing this requires that all the following hold: | 386 // requests. Doing this requires that all the following hold: |
386 // * ZeroSuggestEnabled() is true, so we meet the requirements above. | 387 // * ZeroSuggestEnabled() is true, so we meet the requirements above. |
387 // * The current URL is HTTP, or HTTPS with the same domain as the suggest | 388 // * The current URL is HTTP, or HTTPS with the same domain as the suggest |
388 // server. Non-HTTP[S] URLs (e.g. FTP/file URLs) may contain sensitive | 389 // server. Non-HTTP[S] URLs (e.g. FTP/file URLs) may contain sensitive |
389 // information. HTTPS URLs may also contain sensitive information, but if | 390 // information. HTTPS URLs may also contain sensitive information, but if |
390 // they're on the same domain as the suggest server, then the relevant | 391 // they're on the same domain as the suggest server, then the relevant |
391 // entity could have already seen/logged this data. | 392 // entity could have already seen/logged this data. |
392 // * The user is OK in principle with sending URLs of current pages to their | 393 // * The user is OK in principle with sending URLs of current pages to their |
393 // provider. Today, there is no explicit setting that controls this, but if | 394 // provider. Today, there is no explicit setting that controls this, but if |
394 // the user has tab sync enabled and tab sync is unencrypted, then they're | 395 // the user has tab sync enabled and tab sync is unencrypted, then they're |
395 // already sending this data to Google for sync purposes. Thus we use this | 396 // already sending this data to Google for sync purposes. Thus we use this |
396 // setting as a proxy for "it's OK to send such data". In the future, | 397 // setting as a proxy for "it's OK to send such data". In the future, |
397 // especially if we want to support suggest providers other than Google, we | 398 // especially if we want to support suggest providers other than Google, we |
398 // may change this to be a standalone setting or part of some explicit | 399 // may change this to be a standalone setting or part of some explicit |
399 // general opt-in. | 400 // general opt-in. |
400 static bool CanSendURL( | 401 static bool CanSendURL( |
401 const GURL& current_page_url, | 402 const GURL& current_page_url, |
402 const GURL& suggest_url, | 403 const GURL& suggest_url, |
403 const TemplateURL* template_url, | 404 const TemplateURL* template_url, |
404 AutocompleteInput::PageClassification page_classification, | 405 metrics::OmniboxEventProto::PageClassification page_classification, |
405 Profile* profile); | 406 Profile* profile); |
406 | 407 |
407 // net::URLFetcherDelegate: | 408 // net::URLFetcherDelegate: |
408 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 409 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
409 | 410 |
410 // If the |deletion_url| is valid, then set |match.deletable| to true and | 411 // If the |deletion_url| is valid, then set |match.deletable| to true and |
411 // save the |deletion_url| into the |match|'s additional info under | 412 // save the |deletion_url| into the |match|'s additional info under |
412 // the key |kDeletionUrlKey|. | 413 // the key |kDeletionUrlKey|. |
413 void SetDeletionURL(const std::string& deletion_url, | 414 void SetDeletionURL(const std::string& deletion_url, |
414 AutocompleteMatch* match); | 415 AutocompleteMatch* match); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 | 522 |
522 // True if this provider's results are being displayed in the app list. By | 523 // True if this provider's results are being displayed in the app list. By |
523 // default this is false, meaning that the results will be shown in the | 524 // default this is false, meaning that the results will be shown in the |
524 // omnibox. | 525 // omnibox. |
525 bool in_app_list_; | 526 bool in_app_list_; |
526 | 527 |
527 DISALLOW_COPY_AND_ASSIGN(BaseSearchProvider); | 528 DISALLOW_COPY_AND_ASSIGN(BaseSearchProvider); |
528 }; | 529 }; |
529 | 530 |
530 #endif // CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ | 531 #endif // CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ |
OLD | NEW |