Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: chrome/browser/ui/app_list/search/answer_card/answer_card_search_provider.h

Issue 2947283002: Unit-testing AnswerCardSearchProvider. (Closed)
Patch Set: CR comments Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_BROWSER_UI_APP_LIST_SEARCH_ANSWER_CARD_ANSWER_CARD_SEARCH_PROVIDE R_H_ 5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_ANSWER_CARD_ANSWER_CARD_SEARCH_PROVIDE R_H_
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_ANSWER_CARD_ANSWER_CARD_SEARCH_PROVIDE R_H_ 6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_ANSWER_CARD_ANSWER_CARD_SEARCH_PROVIDE R_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "chrome/browser/ui/app_list/search/answer_card/answer_card_contents.h" 12 #include "chrome/browser/ui/app_list/search/answer_card/answer_card_contents.h"
13 #include "ui/app_list/search_provider.h" 13 #include "ui/app_list/search_provider.h"
14 #include "ui/gfx/geometry/size.h" 14 #include "ui/gfx/geometry/size.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 class AppListControllerDelegate; 17 class AppListControllerDelegate;
18 class Profile; 18 class Profile;
19 class TemplateURLService; 19 class TemplateURLService;
20 20
21 namespace app_list { 21 namespace app_list {
22 class AppListModel; 22 class AppListModel;
23 } 23 }
24 24
25 namespace net {
26 class HttpResponseHeaders;
27 }
28
29 namespace app_list { 25 namespace app_list {
30 26
31 // Search provider for the answer card. 27 // Search provider for the answer card.
32 class AnswerCardSearchProvider : public SearchProvider, 28 class AnswerCardSearchProvider : public SearchProvider,
33 public AnswerCardContents::Delegate { 29 public AnswerCardContents::Delegate {
34 public: 30 public:
35 AnswerCardSearchProvider(Profile* profile, 31 AnswerCardSearchProvider(Profile* profile,
36 app_list::AppListModel* model, 32 app_list::AppListModel* model,
37 AppListControllerDelegate* list_controller, 33 AppListControllerDelegate* list_controller,
38 std::unique_ptr<AnswerCardContents> contents); 34 std::unique_ptr<AnswerCardContents> contents);
39 35
40 ~AnswerCardSearchProvider() override; 36 ~AnswerCardSearchProvider() override;
41 37
42 // SearchProvider overrides: 38 // SearchProvider overrides:
43 void Start(bool is_voice_query, const base::string16& query) override; 39 void Start(bool is_voice_query, const base::string16& query) override;
44 void Stop() override {} 40 void Stop() override {}
45 41
46 // AnswerCardContents::Delegate overrides: 42 // AnswerCardContents::Delegate overrides:
47 void UpdatePreferredSize(const gfx::Size& pref_size) override; 43 void UpdatePreferredSize(const gfx::Size& pref_size) override;
48 content::WebContents* OpenURLFromTab( 44 void DidFinishNavigation(const GURL& url,
49 const content::OpenURLParams& params) override; 45 bool has_error,
50 void DidFinishNavigation( 46 bool has_answer_card,
51 content::NavigationHandle* navigation_handle) override; 47 const std::string& result_title,
48 const std::string& issued_query) override;
52 void DidStopLoading() override; 49 void DidStopLoading() override;
53 50
54 private: 51 private:
55 bool IsCardSizeOk() const; 52 bool IsCardSizeOk() const;
56 void RecordReceivedAnswerFinalResult(); 53 void RecordReceivedAnswerFinalResult();
57 void OnResultAvailable(bool is_available); 54 void OnResultAvailable(bool is_available);
58 bool ParseResponseHeaders(const net::HttpResponseHeaders* headers);
59 // Returns Url to open when the user clicks at the result for |query|. 55 // Returns Url to open when the user clicks at the result for |query|.
60 std::string GetResultUrl(const base::string16& query) const; 56 std::string GetResultUrl(const base::string16& query) const;
61 57
62 // Unowned pointer to the associated profile. 58 // Unowned pointer to the associated profile.
63 Profile* const profile_; 59 Profile* const profile_;
64 60
65 // Unowned pointer to app list model. 61 // Unowned pointer to app list model.
66 app_list::AppListModel* const model_; 62 app_list::AppListModel* const model_;
67 63
68 // Unowned pointer to app list controller. 64 // Unowned pointer to app list controller.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 98
103 // Unowned pointer to template URL service. 99 // Unowned pointer to template URL service.
104 TemplateURLService* const template_url_service_; 100 TemplateURLService* const template_url_service_;
105 101
106 DISALLOW_COPY_AND_ASSIGN(AnswerCardSearchProvider); 102 DISALLOW_COPY_AND_ASSIGN(AnswerCardSearchProvider);
107 }; 103 };
108 104
109 } // namespace app_list 105 } // namespace app_list
110 106
111 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_ANSWER_CARD_ANSWER_CARD_SEARCH_PROV IDER_H_ 107 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_ANSWER_CARD_ANSWER_CARD_SEARCH_PROV IDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698