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

Unified Diff: chrome/browser/net/spdyproxy/data_reduction_promo_infobar_delegate_android.cc

Issue 2022313002: UI for the Data Saver InfoBar Promo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@infobarPromo
Patch Set: dfalcantara comments Created 4 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/net/spdyproxy/data_reduction_promo_infobar_delegate_android.cc
diff --git a/chrome/browser/net/spdyproxy/data_reduction_promo_infobar_delegate_android.cc b/chrome/browser/net/spdyproxy/data_reduction_promo_infobar_delegate_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f779b4503e3e64d26edb745c6355984e91cdce7f
--- /dev/null
+++ b/chrome/browser/net/spdyproxy/data_reduction_promo_infobar_delegate_android.cc
@@ -0,0 +1,83 @@
+// Copyright 2016 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/net/spdyproxy/data_reduction_promo_infobar_delegate_android.h"
+
+#include "chrome/browser/android/android_theme_resources.h"
+#include "chrome/browser/infobars/infobar_service.h"
+#include "components/infobars/core/infobar.h"
+#include "components/infobars/core/infobar_delegate.h"
+#include "content/public/browser/web_contents.h"
+#include "grit/components_strings.h"
+#include "jni/DataReductionPromoInfoBarDelegate_jni.h"
+#include "ui/base/l10n/l10n_util.h"
+
+// static
+void DataReductionPromoInfoBarDelegateAndroid::Create(
+ content::WebContents* web_contents) {
+ InfoBarService* infobar_service =
+ InfoBarService::FromWebContents(web_contents);
+ infobar_service->AddInfoBar(
+ DataReductionPromoInfoBarDelegateAndroid::CreateInfoBar(
+ infobar_service,
+ std::unique_ptr<DataReductionPromoInfoBarDelegateAndroid>(
Peter Kasting 2016/06/29 06:44:43 Nit: Prefer base::MakeUnique()
megjablon 2016/06/29 17:01:52 Done.
+ new DataReductionPromoInfoBarDelegateAndroid())));
+}
+
+DataReductionPromoInfoBarDelegateAndroid::
+ DataReductionPromoInfoBarDelegateAndroid()
+ : ConfirmInfoBarDelegate(),
+ java_data_reduction_promo_delegate_() {}
Peter Kasting 2016/06/29 06:44:43 Nit: Don't explicitly write out base class or memb
megjablon 2016/06/29 17:01:52 Done.
+
+DataReductionPromoInfoBarDelegateAndroid::
+ ~DataReductionPromoInfoBarDelegateAndroid() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_DataReductionPromoInfoBarDelegate_destroy(env);
+}
+
+// static
+bool DataReductionPromoInfoBarDelegateAndroid::Register(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+// static
+void DataReductionPromoInfoBarDelegateAndroid::Launch(
+ JNIEnv* env, jclass, jobject jweb_contents) {
+ content::WebContents* web_contents =
+ content::WebContents::FromJavaWebContents(jweb_contents);
+ DCHECK(web_contents);
+ Create(web_contents);
+}
+
+base::android::ScopedJavaLocalRef<jobject>
+DataReductionPromoInfoBarDelegateAndroid::CreateRenderInfoBar(JNIEnv* env) {
+ java_data_reduction_promo_delegate_.Reset(
+ Java_DataReductionPromoInfoBarDelegate_create(env));
+
+ return Java_DataReductionPromoInfoBarDelegate_showPromoInfoBar(
+ env, java_data_reduction_promo_delegate_.obj());
+}
+
+infobars::InfoBarDelegate::InfoBarIdentifier
+DataReductionPromoInfoBarDelegateAndroid::GetIdentifier() const {
+ return DATA_REDUCTION_PROMO_INFOBAR_DELEGATE_ANDROID;
+}
+
+bool DataReductionPromoInfoBarDelegateAndroid::Accept() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_DataReductionPromoInfoBarDelegate_accept(env);
+ return true;
+}
+
+base::string16 DataReductionPromoInfoBarDelegateAndroid::GetMessageText()
+ const {
+ return base::string16();
Peter Kasting 2016/06/29 06:44:43 Wow, really? Seems odd
megjablon 2016/06/29 17:01:52 Strings are all assigned in Java in the same locat
Peter Kasting 2016/06/29 20:48:29 Ah, might be worth a comment.
+}
+
+// JNI for DataReductionPromoInfoBarDelegate.
+void Launch(JNIEnv* env,
+ const JavaParamRef<jclass>& clazz,
+ const JavaParamRef<jobject>& jweb_contents) {
+ DataReductionPromoInfoBarDelegateAndroid::Launch(env, clazz, jweb_contents);
+}

Powered by Google App Engine
This is Rietveld 408576698