OLD | NEW |
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_WEB_CONTENTS_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_ANSWER_WEB_CONTENTS_DELEGATE_H_ |
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_ANSWER_WEB_CONTENTS_DELEGATE_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_ANSWER_WEB_CONTENTS_DELEGATE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "content/public/browser/web_contents_delegate.h" | 11 #include "content/public/browser/web_contents_delegate.h" |
12 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
| 15 class Profile; |
| 16 |
15 namespace app_list { | 17 namespace app_list { |
16 class AppListModel; | 18 class AppListModel; |
17 } | 19 } |
18 | 20 |
19 namespace content { | |
20 class BrowserContext; | |
21 } | |
22 | |
23 namespace views { | 21 namespace views { |
24 class View; | 22 class View; |
25 class WebView; | 23 class WebView; |
26 } | 24 } |
27 | 25 |
28 namespace app_list { | 26 namespace app_list { |
29 | 27 |
30 // Manages the web contents for the search answer web view. | 28 // Manages the web contents for the search answer web view. |
31 class SearchAnswerWebContentsDelegate : public content::WebContentsDelegate, | 29 class SearchAnswerWebContentsDelegate : public content::WebContentsDelegate, |
32 public content::WebContentsObserver { | 30 public content::WebContentsObserver { |
33 public: | 31 public: |
34 SearchAnswerWebContentsDelegate(content::BrowserContext* browser_context, | 32 SearchAnswerWebContentsDelegate(Profile* profile, |
35 app_list::AppListModel* model); | 33 app_list::AppListModel* model); |
36 | 34 |
37 ~SearchAnswerWebContentsDelegate() override; | 35 ~SearchAnswerWebContentsDelegate() override; |
38 | 36 |
39 // Updates the state after the query string or any other relevant condition | 37 // Updates the state after the query string or any other relevant condition |
40 // changes. | 38 // changes. |
41 void Update(); | 39 void Update(); |
42 | 40 |
43 // Returns a pointer to the web view for the web contents managed by this | 41 // Returns a pointer to the web view for the web contents managed by this |
44 // class. The object is owned by this class and has property | 42 // class. The object is owned by this class and has property |
45 // 'set_owned_by_client()' set. | 43 // 'set_owned_by_client()' set. |
46 views::View* web_view(); | 44 views::View* web_view(); |
47 | 45 |
48 // content::WebContentsDelegate overrides: | 46 // content::WebContentsDelegate overrides: |
49 void UpdatePreferredSize(content::WebContents* web_contents, | 47 void UpdatePreferredSize(content::WebContents* web_contents, |
50 const gfx::Size& pref_size) override; | 48 const gfx::Size& pref_size) override; |
| 49 content::WebContents* OpenURLFromTab( |
| 50 content::WebContents* source, |
| 51 const content::OpenURLParams& params) override; |
51 | 52 |
52 // content::WebContentsObserver overrides: | 53 // content::WebContentsObserver overrides: |
53 void DidFinishNavigation( | 54 void DidFinishNavigation( |
54 content::NavigationHandle* navigation_handle) override; | 55 content::NavigationHandle* navigation_handle) override; |
55 void DidStopLoading() override; | 56 void DidStopLoading() override; |
56 | 57 |
57 private: | 58 private: |
| 59 // Unowned pointer to the associated profile. |
| 60 Profile* const profile_; |
| 61 |
58 // Unowned pointer to app list model. | 62 // Unowned pointer to app list model. |
59 app_list::AppListModel* const model_; | 63 app_list::AppListModel* const model_; |
60 | 64 |
61 // Web view for the web contents managed by this class. | 65 // Web view for the web contents managed by this class. |
62 const std::unique_ptr<views::WebView> web_view_; | 66 const std::unique_ptr<views::WebView> web_view_; |
63 | 67 |
64 // Whether have received a server response for the current query string, and | 68 // Whether have received a server response for the current query string, and |
65 // the response contains an answer. | 69 // the response contains an answer. |
66 bool received_answer_ = false; | 70 bool received_answer_ = false; |
67 | 71 |
68 // Web contents managed by this class. | 72 // Web contents managed by this class. |
69 const std::unique_ptr<content::WebContents> web_contents_; | 73 const std::unique_ptr<content::WebContents> web_contents_; |
70 | 74 |
71 // If valid, URL of the answer server. Otherwise, search answers are disabled. | 75 // If valid, URL of the answer server. Otherwise, search answers are disabled. |
72 GURL answer_server_url_; | 76 GURL answer_server_url_; |
73 | 77 |
74 // URL of the current answer server request. | 78 // URL of the current answer server request. |
75 GURL current_request_url_; | 79 GURL current_request_url_; |
76 | 80 |
77 DISALLOW_COPY_AND_ASSIGN(SearchAnswerWebContentsDelegate); | 81 DISALLOW_COPY_AND_ASSIGN(SearchAnswerWebContentsDelegate); |
78 }; | 82 }; |
79 | 83 |
80 } // namespace app_list | 84 } // namespace app_list |
81 | 85 |
82 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_ANSWER_WEB_CONTENTS_DELEGATE_H_ | 86 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_ANSWER_WEB_CONTENTS_DELEGATE_H_ |
OLD | NEW |