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

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

Issue 2943983003: chrome/blink: Add functionality for in-product help for media elements. (Closed)
Patch Set: nyquist comments Created 3 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
Index: chrome/browser/android/tab_android.cc
diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc
index 005669d1972a18eecc865d99ba76532548b442e1..a8e1e09740039f41f9122560a5e3651b0b715af9 100644
--- a/chrome/browser/android/tab_android.cc
+++ b/chrome/browser/android/tab_android.cc
@@ -54,6 +54,8 @@
#include "components/bookmarks/managed/managed_bookmark_service.h"
#include "components/dom_distiller/core/url_utils.h"
#include "components/favicon/content/content_favicon_driver.h"
+#include "components/feature_engagement_tracker/public/feature_constants.h"
+#include "components/feature_engagement_tracker/public/feature_list.h"
#include "components/navigation_interception/intercept_navigation_delegate.h"
#include "components/navigation_interception/navigation_params.h"
#include "components/sessions/content/content_live_tab.h"
@@ -78,6 +80,7 @@
#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
#include "ui/android/view_android.h"
#include "ui/android/window_android.h"
+#include "ui/base/layout.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/window_open_disposition.h"
#include "ui/display/display.h"
@@ -380,6 +383,12 @@ void TabAndroid::InitWebContents(
GetProfile());
}
content_layer_->InsertChild(web_contents_->GetNativeView()->GetLayer(), 0);
+
+ if (base::FeatureList::IsEnabled(
+ feature_engagement_tracker::kIPHMediaDownloadFeature)) {
+ media_iph_manager_ =
+ base::MakeUnique<MediaInProductHelpManager>(web_contents_.get(), this);
+ }
}
void TabAndroid::UpdateDelegates(
@@ -420,6 +429,7 @@ void TabAndroid::DestroyWebContents(JNIEnv* env,
favicon_driver->RemoveObserver(this);
web_contents()->SetDelegate(NULL);
+ media_iph_manager_.reset();
if (delete_native) {
// Terminate the renderer process if this is the last tab.
@@ -801,6 +811,39 @@ void TabAndroid::AttachToTabContentManager(
tab_content_manager_->AttachLiveLayer(GetAndroidId(), GetContentLayer());
}
+void TabAndroid::ShowMediaDownloadInProductHelp(
+ const gfx::Rect& rect_in_frame) {
+ DCHECK(web_contents_);
+
+ // We need to account for the browser controls offset to get the location for
+ // the widget in the view.
+ float content_offset = web_contents_->GetNativeView()->content_offset();
+ gfx::Rect rect_in_view(rect_in_frame.x(), rect_in_frame.y() + content_offset,
+ rect_in_frame.width(), rect_in_frame.height());
+ gfx::Rect rect_in_view_scaled = gfx::ScaleToEnclosingRectSafe(
+ rect_in_view,
+ ui::GetScaleFactorForNativeView(web_contents_->GetNativeView()));
+
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_Tab_showMediaDownloadInProductHelp(
+ env, weak_java_tab_.get(env), rect_in_view_scaled.x(),
+ rect_in_view_scaled.y(), rect_in_view_scaled.width(),
+ rect_in_view_scaled.height());
+}
+
+void TabAndroid::DismissMediaDownloadInProductHelp() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_Tab_hideMediaDownloadInProductHelp(env, weak_java_tab_.get(env));
+}
+
+void TabAndroid::DownloadMediaInProductHelpDismissed(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& obj) {
+ DCHECK(media_iph_manager_);
+
+ media_iph_manager_->WidgetDismissed();
+}
+
scoped_refptr<content::DevToolsAgentHost> TabAndroid::GetDevToolsAgentHost() {
return devtools_host_;
}

Powered by Google App Engine
This is Rietveld 408576698