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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/net/spdyproxy/data_reduction_promo_infobar_delegate_and roid.h"
6
7 #include "chrome/browser/android/android_theme_resources.h"
8 #include "chrome/browser/infobars/infobar_service.h"
9 #include "components/infobars/core/infobar.h"
10 #include "components/infobars/core/infobar_delegate.h"
11 #include "content/public/browser/web_contents.h"
12 #include "grit/components_strings.h"
13 #include "jni/DataReductionPromoInfoBarDelegate_jni.h"
14 #include "ui/base/l10n/l10n_util.h"
15
16 // static
17 void DataReductionPromoInfoBarDelegateAndroid::Create(
18 content::WebContents* web_contents) {
19 InfoBarService* infobar_service =
20 InfoBarService::FromWebContents(web_contents);
21 infobar_service->AddInfoBar(
22 DataReductionPromoInfoBarDelegateAndroid::CreateInfoBar(
23 infobar_service,
24 std::unique_ptr<DataReductionPromoInfoBarDelegateAndroid>(
Peter Kasting 2016/06/29 06:44:43 Nit: Prefer base::MakeUnique()
megjablon 2016/06/29 17:01:52 Done.
25 new DataReductionPromoInfoBarDelegateAndroid())));
26 }
27
28 DataReductionPromoInfoBarDelegateAndroid::
29 DataReductionPromoInfoBarDelegateAndroid()
30 : ConfirmInfoBarDelegate(),
31 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.
32
33 DataReductionPromoInfoBarDelegateAndroid::
34 ~DataReductionPromoInfoBarDelegateAndroid() {
35 JNIEnv* env = base::android::AttachCurrentThread();
36 Java_DataReductionPromoInfoBarDelegate_destroy(env);
37 }
38
39 // static
40 bool DataReductionPromoInfoBarDelegateAndroid::Register(JNIEnv* env) {
41 return RegisterNativesImpl(env);
42 }
43
44 // static
45 void DataReductionPromoInfoBarDelegateAndroid::Launch(
46 JNIEnv* env, jclass, jobject jweb_contents) {
47 content::WebContents* web_contents =
48 content::WebContents::FromJavaWebContents(jweb_contents);
49 DCHECK(web_contents);
50 Create(web_contents);
51 }
52
53 base::android::ScopedJavaLocalRef<jobject>
54 DataReductionPromoInfoBarDelegateAndroid::CreateRenderInfoBar(JNIEnv* env) {
55 java_data_reduction_promo_delegate_.Reset(
56 Java_DataReductionPromoInfoBarDelegate_create(env));
57
58 return Java_DataReductionPromoInfoBarDelegate_showPromoInfoBar(
59 env, java_data_reduction_promo_delegate_.obj());
60 }
61
62 infobars::InfoBarDelegate::InfoBarIdentifier
63 DataReductionPromoInfoBarDelegateAndroid::GetIdentifier() const {
64 return DATA_REDUCTION_PROMO_INFOBAR_DELEGATE_ANDROID;
65 }
66
67 bool DataReductionPromoInfoBarDelegateAndroid::Accept() {
68 JNIEnv* env = base::android::AttachCurrentThread();
69 Java_DataReductionPromoInfoBarDelegate_accept(env);
70 return true;
71 }
72
73 base::string16 DataReductionPromoInfoBarDelegateAndroid::GetMessageText()
74 const {
75 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.
76 }
77
78 // JNI for DataReductionPromoInfoBarDelegate.
79 void Launch(JNIEnv* env,
80 const JavaParamRef<jclass>& clazz,
81 const JavaParamRef<jobject>& jweb_contents) {
82 DataReductionPromoInfoBarDelegateAndroid::Launch(env, clazz, jweb_contents);
83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698