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

Unified Diff: chrome/browser/android/tab_android.cc

Issue 368983004: Implemented HandlePopupNavigation from tab_android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove "BUG=" from commit msg Created 6 years, 5 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
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/tab_android.cc
diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc
index 4b1a8762b9090705d026b1fa8c153ba9d59ed6d3..270b63a1aeafc66b53883696787bba4e24a71062 100644
--- a/chrome/browser/android/tab_android.cc
+++ b/chrome/browser/android/tab_android.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/search/search.h"
#include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/browser/sync/glue/synced_tab_delegate_android.h"
+#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/ui/android/content_settings/popup_blocked_infobar_delegate.h"
#include "chrome/browser/ui/android/context_menu_helper.h"
#include "chrome/browser/ui/android/infobars/infobar_container_android.h"
@@ -48,6 +49,37 @@
#include "jni/Tab_jni.h"
#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
+using content::GlobalRequestID;
+using content::NavigationController;
+using content::WebContents;
+
+namespace {
+
+WebContents* CreateTargetContents(const chrome::NavigateParams& params,
+ const GURL& url) {
+ WebContents::CreateParams create_params(
+ params.initiating_profile,
David Trainor- moved to gerrit 2014/07/15 20:34:35 Is this the right profile? What if we're opening
Jitu( very slow this week) 2014/07/16 14:17:49 We are assuming that params.initiating_profile giv
+ tab_util::GetSiteInstanceForNewTab(params.initiating_profile, url));
+ if (params.source_contents) {
+ create_params.initial_size =
+ params.source_contents->GetContainerBounds().size();
+ if (params.should_set_opener)
+ create_params.opener = params.source_contents;
+ }
+ if (params.disposition == NEW_BACKGROUND_TAB)
+ create_params.initially_hidden = true;
+
+ WebContents* target_contents = WebContents::Create(create_params);
+
+ // New tabs can have WebUI URLs that will make calls back to arbitrary
+ // tab helpers, so the entire set of tab helpers needs to be set up
+ // immediately.
+ TabAndroid::AttachTabHelpers(target_contents);
David Trainor- moved to gerrit 2014/07/15 20:34:35 ChromeWebContentsDelegateAndroid::AddNewContents()
Jitu( very slow this week) 2014/07/16 14:17:49 Done.
+ return target_contents;
+}
+
+} // namespace
+
TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) {
CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents);
if (!core_tab_helper)
@@ -170,7 +202,22 @@ void TabAndroid::SetSyncId(int sync_id) {
}
void TabAndroid::HandlePopupNavigation(chrome::NavigateParams* params) {
David Trainor- moved to gerrit 2014/07/15 20:34:35 Should we check disposition here? There are some
Jitu( very slow this week) 2014/07/16 14:17:49 Done. PTAL
- NOTIMPLEMENTED();
+ if (!params->url.is_empty()) {
+ bool was_blocked = false;
+ GURL url = params->url;
David Trainor- moved to gerrit 2014/07/15 20:34:35 GURL url(params->url)?
Jitu( very slow this week) 2014/07/16 14:17:49 Done.
+ params->target_contents = CreateTargetContents(*params, url);
+ NavigationController::LoadURLParams load_url_params(url);
+ MakeLoadURLParams(params, &load_url_params);
+ params->target_contents->GetController().LoadURLWithParams(load_url_params);
+ web_contents_delegate_->AddNewContents(params->source_contents,
+ params->target_contents,
+ params->disposition,
+ params->window_bounds,
+ params->user_gesture,
+ &was_blocked);
+ if (was_blocked)
+ params->target_contents = NULL;
+ }
}
bool TabAndroid::ShouldWelcomePageLinkToTermsOfService() {
@@ -197,6 +244,34 @@ bool TabAndroid::HasPrerenderedUrl(GURL gurl) {
return false;
}
+void TabAndroid::MakeLoadURLParams(
+ chrome::NavigateParams* params,
+ NavigationController::LoadURLParams* load_url_params) {
+ load_url_params->referrer = params->referrer;
+ load_url_params->frame_tree_node_id = params->frame_tree_node_id;
+ load_url_params->redirect_chain = params->redirect_chain;
+ load_url_params->transition_type = params->transition;
+ load_url_params->extra_headers = params->extra_headers;
+ load_url_params->should_replace_current_entry =
+ params->should_replace_current_entry;
+
+ if (params->transferred_global_request_id != GlobalRequestID()) {
+ load_url_params->is_renderer_initiated = params->is_renderer_initiated;
David Trainor- moved to gerrit 2014/07/15 20:34:35 Can we just pull this line out of the if block? W
Jitu( very slow this week) 2014/07/16 14:17:49 Done.
+ load_url_params->transferred_global_request_id =
+ params->transferred_global_request_id;
+ } else if (params->is_renderer_initiated) {
+ load_url_params->is_renderer_initiated = true;
+ }
+
+ // Only allows the browser-initiated navigation to use POST.
+ if (params->uses_post && !params->is_renderer_initiated) {
+ load_url_params->load_type =
+ NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
+ load_url_params->browser_initiated_post_data =
+ params->browser_initiated_post_data;
+ }
+}
+
void TabAndroid::SwapTabContents(content::WebContents* old_contents,
content::WebContents* new_contents,
bool did_start_load,
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698