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

Side by Side Diff: chrome/browser/ui/app_list/search_answer_web_contents_delegate.cc

Issue 2910173003: Revert of Making answer card to behave like other results. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « chrome/browser/chromeos/login/ui/webui_login_view.cc ('k') | ui/app_list/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/ui/app_list/search_answer_web_contents_delegate.h" 5 #include "chrome/browser/ui/app_list/search_answer_web_contents_delegate.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/metrics/user_metrics.h" 9 #include "base/metrics/user_metrics.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser_navigator.h" 12 #include "chrome/browser/ui/browser_navigator.h"
13 #include "chrome/browser/ui/browser_navigator_params.h" 13 #include "chrome/browser/ui/browser_navigator_params.h"
14 #include "content/public/browser/navigation_handle.h" 14 #include "content/public/browser/navigation_handle.h"
15 #include "content/public/browser/render_view_host.h" 15 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/browser/web_contents_delegate.h" 17 #include "content/public/browser/web_contents_delegate.h"
18 #include "content/public/common/renderer_preferences.h" 18 #include "content/public/common/renderer_preferences.h"
19 #include "net/http/http_response_headers.h" 19 #include "net/http/http_response_headers.h"
20 #include "net/http/http_status_code.h" 20 #include "net/http/http_status_code.h"
21 #include "ui/app_list/app_list_features.h" 21 #include "ui/app_list/app_list_features.h"
22 #include "ui/app_list/app_list_model.h" 22 #include "ui/app_list/app_list_model.h"
23 #include "ui/app_list/search_box_model.h" 23 #include "ui/app_list/search_box_model.h"
24 #include "ui/views/controls/webview/web_contents_set_background_color.h"
25 #include "ui/views/controls/webview/webview.h" 24 #include "ui/views/controls/webview/webview.h"
26 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
27 26
28 namespace app_list { 27 namespace app_list {
29 28
30 namespace { 29 namespace {
31 30
32 enum class SearchAnswerRequestResult { 31 enum class SearchAnswerRequestResult {
33 REQUEST_RESULT_ANOTHER_REQUEST_STARTED = 0, 32 REQUEST_RESULT_ANOTHER_REQUEST_STARTED = 0,
34 REQUEST_RESULT_REQUEST_FAILED = 1, 33 REQUEST_RESULT_REQUEST_FAILED = 1,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); 98 web_contents_->GetRenderViewHost()->SyncRendererPrefs();
100 99
101 Observe(web_contents_.get()); 100 Observe(web_contents_.get());
102 web_contents_->SetDelegate(this); 101 web_contents_->SetDelegate(this);
103 web_view_->set_owned_by_client(); 102 web_view_->set_owned_by_client();
104 web_view_->SetWebContents(web_contents_.get()); 103 web_view_->SetWebContents(web_contents_.get());
105 if (features::IsAnswerCardDarkRunEnabled()) 104 if (features::IsAnswerCardDarkRunEnabled())
106 web_view_->SetFocusBehavior(views::View::FocusBehavior::NEVER); 105 web_view_->SetFocusBehavior(views::View::FocusBehavior::NEVER);
107 106
108 model->AddObserver(this); 107 model->AddObserver(this);
109
110 // Make the webview transparent since it's going to be shown on top of a
111 // highlightable button.
112 views::WebContentsSetBackgroundColor::CreateForWebContentsWithColor(
113 web_contents_.get(), SK_ColorTRANSPARENT);
114 } 108 }
115 109
116 SearchAnswerWebContentsDelegate::~SearchAnswerWebContentsDelegate() { 110 SearchAnswerWebContentsDelegate::~SearchAnswerWebContentsDelegate() {
117 RecordReceivedAnswerFinalResult(); 111 RecordReceivedAnswerFinalResult();
118 model_->RemoveObserver(this); 112 model_->RemoveObserver(this);
119 } 113 }
120 114
121 views::View* SearchAnswerWebContentsDelegate::web_view() { 115 views::View* SearchAnswerWebContentsDelegate::web_view() {
122 return web_view_.get(); 116 return web_view_.get();
123 } 117 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 web_contents_->GetRenderViewHost()->EnablePreferredSizeMode(); 161 web_contents_->GetRenderViewHost()->EnablePreferredSizeMode();
168 } 162 }
169 163
170 void SearchAnswerWebContentsDelegate::UpdatePreferredSize( 164 void SearchAnswerWebContentsDelegate::UpdatePreferredSize(
171 content::WebContents* web_contents, 165 content::WebContents* web_contents,
172 const gfx::Size& pref_size) { 166 const gfx::Size& pref_size) {
173 is_card_size_ok_ = 167 is_card_size_ok_ =
174 IsCardSizeOk(pref_size) || features::IsAnswerCardDarkRunEnabled(); 168 IsCardSizeOk(pref_size) || features::IsAnswerCardDarkRunEnabled();
175 model_->SetSearchAnswerAvailable(is_card_size_ok_ && received_answer_ && 169 model_->SetSearchAnswerAvailable(is_card_size_ok_ && received_answer_ &&
176 !web_contents_->IsLoading()); 170 !web_contents_->IsLoading());
177 web_view_->SetPreferredSize(pref_size); 171 if (!features::IsAnswerCardDarkRunEnabled())
172 web_view_->SetPreferredSize(pref_size);
178 if (!answer_loaded_time_.is_null()) { 173 if (!answer_loaded_time_.is_null()) {
179 UMA_HISTOGRAM_TIMES("SearchAnswer.ResizeAfterLoadTime", 174 UMA_HISTOGRAM_TIMES("SearchAnswer.ResizeAfterLoadTime",
180 base::TimeTicks::Now() - answer_loaded_time_); 175 base::TimeTicks::Now() - answer_loaded_time_);
181 } 176 }
182 } 177 }
183 178
184 content::WebContents* SearchAnswerWebContentsDelegate::OpenURLFromTab( 179 content::WebContents* SearchAnswerWebContentsDelegate::OpenURLFromTab(
185 content::WebContents* source, 180 content::WebContents* source,
186 const content::OpenURLParams& params) { 181 const content::OpenURLParams& params) {
187 if (!params.user_gesture) 182 if (!params.user_gesture)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 return; 276 return;
282 277
283 RecordRequestResult( 278 RecordRequestResult(
284 is_card_size_ok_ 279 is_card_size_ok_
285 ? SearchAnswerRequestResult::REQUEST_RESULT_RECEIVED_ANSWER 280 ? SearchAnswerRequestResult::REQUEST_RESULT_RECEIVED_ANSWER
286 : SearchAnswerRequestResult:: 281 : SearchAnswerRequestResult::
287 REQUEST_RESULT_RECEIVED_ANSWER_TOO_LARGE); 282 REQUEST_RESULT_RECEIVED_ANSWER_TOO_LARGE);
288 } 283 }
289 284
290 } // namespace app_list 285 } // namespace app_list
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/ui/webui_login_view.cc ('k') | ui/app_list/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698