summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfelipeg@chromium.org <felipeg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-23 13:34:41 +0000
committerfelipeg@chromium.org <felipeg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-23 13:34:41 +0000
commitb019ec4224fa1358cc97b737cd3e40125ea39fa9 (patch)
treebef12ea31785577c7aeb10eb9104627472d30d5f
parentbe1464c45a0150a684b7d8ffdff959804f8a8a2a (diff)
downloadchromium_src-b019ec4224fa1358cc97b737cd3e40125ea39fa9.zip
chromium_src-b019ec4224fa1358cc97b737cd3e40125ea39fa9.tar.gz
chromium_src-b019ec4224fa1358cc97b737cd3e40125ea39fa9.tar.bz2
Upstream TabAndroid abstract class.
Together with TabAndroid I am also upstreaming part of the chrome_web_contents_view_delegate_android.cc so that we can include tab_android.h and compile it. I am using the target "browser" to check that it compiles. BUG=136075,137008 TEST=compiled with "make browser" Review URL: https://chromiumcodereview.appspot.com/10803010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147849 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/android/tab_android.cc11
-rw-r--r--chrome/browser/android/tab_android.h77
-rw-r--r--chrome/browser/android/tab_android_test_stubs.cc18
-rw-r--r--chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc41
-rw-r--r--chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.h39
-rw-r--r--chrome/chrome_browser.gypi3
-rw-r--r--chrome/chrome_tests.gypi1
7 files changed, 184 insertions, 6 deletions
diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc
new file mode 100644
index 0000000..1b9345a
--- /dev/null
+++ b/chrome/browser/android/tab_android.cc
@@ -0,0 +1,11 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/tab_android.h"
+
+TabAndroid::TabAndroid() : tab_id_(-1) {
+}
+
+TabAndroid::~TabAndroid() {
+}
diff --git a/chrome/browser/android/tab_android.h b/chrome/browser/android/tab_android.h
new file mode 100644
index 0000000..403514e
--- /dev/null
+++ b/chrome/browser/android/tab_android.h
@@ -0,0 +1,77 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_ANDROID_TAB_ANDROID_H_
+#define CHROME_BROWSER_ANDROID_TAB_ANDROID_H_
+
+#include <jni.h>
+
+#include "base/android/jni_helper.h"
+#include "base/android/scoped_java_ref.h"
+#include "base/string16.h"
+
+class GURL;
+class OnContextMenuItemSelectedCallBack;
+class SkBitmap;
+
+namespace browser_sync {
+class SyncedTabDelegate;
+}
+
+namespace content {
+struct ContextMenuParams;
+class WebContents;
+}
+
+class TabAndroid {
+ public:
+ TabAndroid();
+
+ // Convenience method to retrieve the Tab associated with the passed
+ // WebContents. Can return NULL.
+ static TabAndroid* FromWebContents(content::WebContents* web_contents);
+
+ static TabAndroid* GetNativeTab(JNIEnv* env, jobject obj);
+
+ virtual browser_sync::SyncedTabDelegate* GetSyncedTabDelegate() = 0;
+
+ int id() const {
+ return tab_id_;
+ }
+
+ // Called to show the regular context menu that is triggered by a long press.
+ virtual void ShowContextMenu(const content::ContextMenuParams& params) = 0;
+
+ // Called to show a custom context menu. Used by the NTP.
+ virtual void ShowCustomContextMenu(
+ const content::ContextMenuParams& params,
+ OnContextMenuItemSelectedCallBack* callback) = 0;
+
+ virtual void ShowSelectFileDialog(
+ const base::android::ScopedJavaLocalRef<jobject>& select_file) = 0;
+
+ // --------------------------------------------------------------------------
+ // Public methods that call to Java via JNI
+ // --------------------------------------------------------------------------
+ // Called when context menu option to create the bookmark shortcut on
+ // homescreen is called.
+ virtual void AddShortcutToBookmark(
+ const GURL& url, const string16& title, const SkBitmap& skbitmap,
+ int r_value, int g_value, int b_value) = 0;
+
+ // TODO(felipeg,tedchoc): Remove this when possible.
+ // http://crbug.com/138216
+ // Called when the mobile promo action asks to send email.
+ virtual void PromoSendEmail(const string16& data_email,
+ const string16& data_subj,
+ const string16& data_body,
+ const string16& data_inv) = 0;
+
+ protected:
+ virtual ~TabAndroid();
+
+ int tab_id_;
+};
+
+#endif // CHROME_BROWSER_ANDROID_TAB_ANDROID_H_
diff --git a/chrome/browser/android/tab_android_test_stubs.cc b/chrome/browser/android/tab_android_test_stubs.cc
new file mode 100644
index 0000000..edfd4cd
--- /dev/null
+++ b/chrome/browser/android/tab_android_test_stubs.cc
@@ -0,0 +1,18 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file contains stubs for some Chrome for Android specific code that is
+// needed to compile some tests.
+
+#include "chrome/browser/android/tab_android.h"
+
+// static
+TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) {
+ return NULL;
+}
+
+// static
+TabAndroid* TabAndroid::GetNativeTab(JNIEnv* env, jobject obj) {
+ return NULL;
+}
diff --git a/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc b/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc
index c692500..e8cdc29 100644
--- a/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc
+++ b/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc
@@ -2,20 +2,49 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.h"
+
#include "base/logging.h"
+#include "chrome/browser/android/tab_android.h"
#include "content/public/browser/web_contents_view_delegate.h"
+#include "content/public/common/context_menu_params.h"
+
+ChromeWebContentsViewDelegateAndroid::ChromeWebContentsViewDelegateAndroid(
+ content::WebContents* web_contents)
+ : web_contents_(web_contents) {
+}
+
+ChromeWebContentsViewDelegateAndroid::~ChromeWebContentsViewDelegateAndroid() {
+}
-namespace content {
-class WebContents;
-} // namespace content
+content::WebDragDestDelegate*
+ChromeWebContentsViewDelegateAndroid::GetDragDestDelegate() {
+ // GetDragDestDelegate is a pure virtual method from WebContentsViewDelegate
+ // and must have an implementation although android doesn't use it.
+ NOTREACHED();
+ return NULL;
+}
+
+void ChromeWebContentsViewDelegateAndroid::ShowContextMenu(
+ const content::ContextMenuParams& params) {
+ // http://crbug.com/136075
+ NOTIMPLEMENTED();
+ // Still lacking some code here that depends on
+ // content/public/browser/android/content_view_core.h
+
+ TabAndroid* tab = TabAndroid::FromWebContents(web_contents_);
+ // We may not have a Tab if we're running in Android WebView mode.
+ // TODO: The long term plan is to factor out the context menu code into
+ // a shared class and have WebView use a separate delegate.
+ if (tab)
+ tab->ShowContextMenu(params);
+}
namespace chrome {
content::WebContentsViewDelegate* CreateWebContentsViewDelegate(
content::WebContents* web_contents) {
- // http://crbug.com/136075
- NOTIMPLEMENTED();
- return NULL;
+ return new ChromeWebContentsViewDelegateAndroid(web_contents);
}
} // namespace chrome
diff --git a/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.h b/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.h
new file mode 100644
index 0000000..04314cb
--- /dev/null
+++ b/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.h
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_ANDROID_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_ANDROID_H_
+#define CHROME_BROWSER_UI_ANDROID_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_ANDROID_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "content/public/browser/web_contents_view_delegate.h"
+
+namespace content {
+class WebContents;
+}
+
+// A Chrome specific class that extends WebContentsViewAndroid with features
+// like context menus.
+class ChromeWebContentsViewDelegateAndroid
+ : public content::WebContentsViewDelegate {
+ public:
+ explicit ChromeWebContentsViewDelegateAndroid(
+ content::WebContents* web_contents);
+ virtual ~ChromeWebContentsViewDelegateAndroid();
+
+ // WebContentsViewDelegate:
+ virtual void ShowContextMenu(
+ const content::ContextMenuParams& params) OVERRIDE;
+
+ // WebContentsViewDelegate:
+ virtual content::WebDragDestDelegate* GetDragDestDelegate() OVERRIDE;
+
+ private:
+ // The WebContents that owns the view and this delegate transitively.
+ content::WebContents* web_contents_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeWebContentsViewDelegateAndroid);
+};
+
+#endif // CHROME_BROWSER_UI_ANDROID_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_ANDROID_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 2fa17ad..8160138 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -108,6 +108,8 @@
'browser/android/chrome_startup_flags.h',
'browser/android/process_utils.cc',
'browser/android/process_utils.h',
+ 'browser/android/tab_android.cc',
+ 'browser/android/tab_android.h',
'browser/alternate_nav_url_fetcher.cc',
'browser/alternate_nav_url_fetcher.h',
'browser/app_controller_mac.h',
@@ -2382,6 +2384,7 @@
'browser/ui/android/simple_message_box_android.cc',
'browser/ui/android/ssl_client_certificate_selector.cc',
'browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc',
+ 'browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.h',
'browser/ui/android/tab_restore_service_delegate_android.cc',
'browser/ui/app_modal_dialogs/app_modal_dialog.cc',
'browser/ui/app_modal_dialogs/app_modal_dialog.h',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 4781889..b57218b 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -79,6 +79,7 @@
'app/breakpad_mac_stubs.mm',
'app/chrome_main_delegate.cc',
'app/chrome_main_delegate.h',
+ 'browser/android/tab_android_test_stubs.cc',
'browser/autofill/autofill_common_test.cc',
'browser/autofill/autofill_common_test.h',
'browser/autofill/data_driven_test.cc',