OLD | NEW |
---|---|
(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/android/instantapps/instant_apps_infobar_delegate.h" | |
6 | |
7 #include "base/android/jni_android.h" | |
8 #include "base/android/jni_string.h" | |
9 #include "base/memory/ptr_util.h" | |
10 #include "chrome/browser/infobars/infobar_service.h" | |
11 #include "chrome/browser/ui/android/infobars/instant_apps_infobar.h" | |
12 #include "components/infobars/core/infobar_delegate.h" | |
13 #include "content/public/browser/web_contents.h" | |
14 #include "jni/InstantAppsInfoBarDelegate_jni.h" | |
15 | |
16 InstantAppsInfoBarDelegate::~InstantAppsInfoBarDelegate() {} | |
17 | |
18 // static | |
19 void InstantAppsInfoBarDelegate::Create(InfoBarService* infobar_service, | |
20 jobject jdata) { | |
21 std::unique_ptr<InstantAppsInfoBarDelegate> delegate( | |
22 new InstantAppsInfoBarDelegate(jdata)); | |
23 infobar_service->AddInfoBar(base::MakeUnique<InstantAppsInfoBar>( | |
24 std::move(delegate))); | |
Peter Kasting
2016/08/24 04:04:06
Nit: Optional shorter version:
infobar_service-
Maria
2016/08/24 17:53:49
Done.
| |
25 } | |
26 | |
27 InstantAppsInfoBarDelegate::InstantAppsInfoBarDelegate(jobject jdata) { | |
28 JNIEnv* env = base::android::AttachCurrentThread(); | |
29 data_.Reset(env, jdata); | |
30 java_delegate_.Reset(Java_InstantAppsInfoBarDelegate_create(env)); | |
Peter Kasting
2016/08/24 04:04:06
Nit: I suggest keeping the init order here and the
Maria
2016/08/24 17:53:49
Done.
| |
31 } | |
32 | |
33 infobars::InfoBarDelegate::InfoBarIdentifier | |
34 InstantAppsInfoBarDelegate::GetIdentifier() const { | |
35 return INSTANT_APPS_INFOBAR_DELEGATE_ANDROID; | |
36 } | |
37 | |
38 base::string16 InstantAppsInfoBarDelegate::GetMessageText() const { | |
39 // Message is set in InstantAppInfobar.java | |
40 return base::string16(); | |
Peter Kasting
2016/08/24 04:04:06
OK, returning string16() here is fine, but this re
Maria
2016/08/24 17:53:49
Done.
| |
41 } | |
42 | |
43 bool InstantAppsInfoBarDelegate::Accept() { | |
44 JNIEnv* env = base::android::AttachCurrentThread(); | |
45 Java_InstantAppsInfoBarDelegate_openInstantApp(env, java_delegate_.obj()); | |
46 return true; | |
47 } | |
48 | |
49 void Launch(JNIEnv* env, | |
50 const base::android::JavaParamRef<jclass>& clazz, | |
51 const base::android::JavaParamRef<jobject>& jweb_contents, | |
52 const base::android::JavaParamRef<jobject>& jdata) { | |
53 content::WebContents* web_contents = | |
54 content::WebContents::FromJavaWebContents(jweb_contents); | |
55 InfoBarService* infobar_service = | |
56 InfoBarService::FromWebContents(web_contents); | |
Peter Kasting
2016/08/24 04:04:06
Nit: I'd probably inline this statement into the n
Maria
2016/08/24 17:53:49
Done.
| |
57 InstantAppsInfoBarDelegate::Create(infobar_service, jdata); | |
58 } | |
59 | |
60 bool RegisterInstantAppsInfoBarDelegate(JNIEnv* env) { | |
61 return RegisterNativesImpl(env); | |
62 } | |
OLD | NEW |