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

Unified Diff: chrome/browser/ui/app_list/search/answer_card/answer_card_web_contents.cc

Issue 2947283002: Unit-testing AnswerCardSearchProvider. (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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/search/answer_card/answer_card_web_contents.cc
diff --git a/chrome/browser/ui/app_list/search/answer_card/answer_card_web_contents.cc b/chrome/browser/ui/app_list/search/answer_card/answer_card_web_contents.cc
index e8de4cb88f98e2c116765086ffd1ceb8929e24bf..442968fd01f03b9f085857cad6128a25d0cf29db 100644
--- a/chrome/browser/ui/app_list/search/answer_card/answer_card_web_contents.cc
+++ b/chrome/browser/ui/app_list/search/answer_card/answer_card_web_contents.cc
@@ -7,6 +7,9 @@
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser_navigator.h"
+#include "chrome/browser/ui/browser_navigator_params.h"
+#include "content/public/browser/page_navigator.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/web_contents.h"
@@ -59,7 +62,8 @@ AnswerCardWebContents::AnswerCardWebContents(Profile* profile)
profile,
content::SiteInstance::Create(profile)))),
mouse_event_callback_(base::Bind(&AnswerCardWebContents::HandleMouseEvent,
- base::Unretained(this))) {
+ base::Unretained(this))),
+ profile_(profile) {
content::RendererPreferences* renderer_prefs =
web_contents_->GetMutableRendererPrefs();
renderer_prefs->can_accept_load_drops = false;
@@ -116,7 +120,26 @@ content::WebContents* AnswerCardWebContents::OpenURLFromTab(
if (!params.user_gesture)
return WebContentsDelegate::OpenURLFromTab(source, params);
- return delegate()->OpenURLFromTab(params);
+ // Open the user-clicked link in the browser taking into account the requested
+ // disposition.
+ chrome::NavigateParams new_tab_params(profile_, params.url,
+ params.transition);
+
+ new_tab_params.disposition = params.disposition;
+
+ if (params.disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB) {
+ // When the user asks to open a link as a background tab, we show an
+ // activated window with the new activated tab after the user closes the
+ // launcher. So it's "background" relative to the launcher itself.
+ new_tab_params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
+ new_tab_params.window_action = chrome::NavigateParams::SHOW_WINDOW_INACTIVE;
+ }
+
+ chrome::Navigate(&new_tab_params);
+
+ base::RecordAction(base::UserMetricsAction("SearchAnswer_OpenedUrl"));
+
+ return new_tab_params.target_contents;
}
bool AnswerCardWebContents::HandleContextMenu(

Powered by Google App Engine
This is Rietveld 408576698