Chromium Code Reviews| Index: chrome/browser/android/tab_android.cc |
| diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc |
| index 3c0c45072a573d8465d97a878f00facd646279ed..a28382b0b07e45824260463721867fda413a51e0 100644 |
| --- a/chrome/browser/android/tab_android.cc |
| +++ b/chrome/browser/android/tab_android.cc |
| @@ -30,6 +30,7 @@ |
| #include "chrome/browser/translate/translate_tab_helper.h" |
| #include "chrome/browser/ui/alternate_error_tab_observer.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" |
| #include "chrome/browser/ui/android/tab_model/tab_model.h" |
| #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
| @@ -44,6 +45,7 @@ |
| #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" |
| #include "components/autofill/content/browser/autofill_driver_impl.h" |
| #include "content/public/browser/android/content_view_core.h" |
| +#include "content/public/browser/android/download_controller_android.h" |
| #include "content/public/browser/navigation_entry.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/browser/web_contents.h" |
| @@ -89,6 +91,7 @@ void BrowserTabContents::AttachTabHelpers(content::WebContents* contents) { |
| g_browser_process->GetApplicationLocale(), |
| autofill::AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER); |
| BookmarkTabHelper::CreateForWebContents(contents); |
| + ContextMenuHelper::CreateForWebContents(contents); |
| CoreTabHelper::CreateForWebContents(contents); |
| extensions::TabHelper::CreateForWebContents(contents); |
| FaviconTabHelper::CreateForWebContents(contents); |
| @@ -288,7 +291,8 @@ void TabAndroid::InitWebContents(JNIEnv* env, |
| jobject obj, |
| jboolean incognito, |
| jobject jcontent_view_core, |
| - jobject jweb_contents_delegate) { |
| + jobject jweb_contents_delegate, |
| + jobject jcontext_menu_populator) { |
| content::ContentViewCore* content_view_core = |
| content::ContentViewCore::GetNativeContentViewCore(env, |
| jcontent_view_core); |
| @@ -300,6 +304,8 @@ void TabAndroid::InitWebContents(JNIEnv* env, |
| session_tab_id_.set_id( |
| SessionTabHelper::FromWebContents(web_contents())->session_id().id()); |
| + ContextMenuHelper::FromWebContents(web_contents())->SetPopulator( |
| + jcontext_menu_populator); |
| WindowAndroidHelper::FromWebContents(web_contents())-> |
| SetWindowAndroid(content_view_core->GetWindowAndroid()); |
| CoreTabHelper::FromWebContents(web_contents())->set_delegate(this); |
| @@ -399,6 +405,31 @@ void TabAndroid::SetActiveNavigationEntryTitleForUrl(JNIEnv* env, |
| entry->SetTitle(title); |
| } |
| +void TabAndroid::OnContextMenuDownload(JNIEnv* env, |
| + jobject obj, |
| + jstring jurl, |
| + jboolean jis_link) { |
| + if (!web_contents()) |
| + return; |
| + |
| + ContextMenuHelper* context_menu_helper = |
| + ContextMenuHelper::FromWebContents(web_contents()); |
|
Ted C
2013/11/19 02:44:03
Maybe this could just be moved to ContextMenuHelpe
|
| + |
| + if (!context_menu_helper) |
| + return; |
| + |
| + const GURL& url = jis_link ? |
| + context_menu_helper->GetCurrentContextMenuParams().link_url : |
| + context_menu_helper->GetCurrentContextMenuParams().src_url; |
| + |
| + DCHECK(!base::android::ConvertJavaStringToUTF8(env, jurl).compare( |
| + url.spec())); |
| + content::DownloadControllerAndroid::Get()->StartContextMenuDownload( |
| + context_menu_helper->GetCurrentContextMenuParams(), |
| + web_contents(), |
| + jis_link); |
| +} |
| + |
| bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
| return RegisterNativesImpl(env); |
| } |