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

Side by Side Diff: chrome/browser/ui/android/infobars/confirm_infobar.cc

Issue 889613003: Add support for passing bitmaps to Android infobars (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 5 years, 10 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/infobar/TranslateInfoBar.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/android/infobars/confirm_infobar.h" 5 #include "chrome/browser/ui/android/infobars/confirm_infobar.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/browser/android/resource_mapper.h" 10 #include "chrome/browser/android/resource_mapper.h"
11 #include "chrome/browser/infobars/infobar_service.h" 11 #include "chrome/browser/infobars/infobar_service.h"
12 #include "components/infobars/core/confirm_infobar_delegate.h" 12 #include "components/infobars/core/confirm_infobar_delegate.h"
13 #include "jni/ConfirmInfoBarDelegate_jni.h" 13 #include "jni/ConfirmInfoBarDelegate_jni.h"
14 #include "ui/gfx/android/java_bitmap.h"
15 #include "ui/gfx/image/image.h"
14 16
15 // InfoBarService ------------------------------------------------------------- 17 // InfoBarService -------------------------------------------------------------
16 18
17 scoped_ptr<infobars::InfoBar> InfoBarService::CreateConfirmInfoBar( 19 scoped_ptr<infobars::InfoBar> InfoBarService::CreateConfirmInfoBar(
18 scoped_ptr<ConfirmInfoBarDelegate> delegate) { 20 scoped_ptr<ConfirmInfoBarDelegate> delegate) {
19 return make_scoped_ptr(new ConfirmInfoBar(delegate.Pass())); 21 return make_scoped_ptr(new ConfirmInfoBar(delegate.Pass()));
20 } 22 }
21 23
22 24
23 // ConfirmInfoBar ------------------------------------------------------------- 25 // ConfirmInfoBar -------------------------------------------------------------
(...skipping 15 matching lines...) Expand all
39 base::android::ConvertUTF16ToJavaString( 41 base::android::ConvertUTF16ToJavaString(
40 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL)); 42 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL));
41 ConfirmInfoBarDelegate* delegate = GetDelegate(); 43 ConfirmInfoBarDelegate* delegate = GetDelegate();
42 base::android::ScopedJavaLocalRef<jstring> message_text = 44 base::android::ScopedJavaLocalRef<jstring> message_text =
43 base::android::ConvertUTF16ToJavaString( 45 base::android::ConvertUTF16ToJavaString(
44 env, delegate->GetMessageText()); 46 env, delegate->GetMessageText());
45 base::android::ScopedJavaLocalRef<jstring> link_text = 47 base::android::ScopedJavaLocalRef<jstring> link_text =
46 base::android::ConvertUTF16ToJavaString( 48 base::android::ConvertUTF16ToJavaString(
47 env, delegate->GetLinkText()); 49 env, delegate->GetLinkText());
48 50
51 ScopedJavaLocalRef<jobject> java_bitmap;
52 if (!delegate->GetIcon().IsEmpty()) {
53 java_bitmap = gfx::ConvertToJavaBitmap(delegate->GetIcon().ToSkBitmap());
54 }
55
49 return Java_ConfirmInfoBarDelegate_showConfirmInfoBar( 56 return Java_ConfirmInfoBarDelegate_showConfirmInfoBar(
50 env, java_confirm_delegate_.obj(), reinterpret_cast<intptr_t>(this), 57 env, java_confirm_delegate_.obj(), reinterpret_cast<intptr_t>(this),
51 GetEnumeratedIconId(), message_text.obj(), link_text.obj(), 58 GetEnumeratedIconId(), java_bitmap.obj(), message_text.obj(),
52 ok_button_text.obj(), cancel_button_text.obj()); 59 link_text.obj(), ok_button_text.obj(), cancel_button_text.obj());
53 } 60 }
54 61
55 void ConfirmInfoBar::OnLinkClicked(JNIEnv* env, jobject obj) { 62 void ConfirmInfoBar::OnLinkClicked(JNIEnv* env, jobject obj) {
56 if (!owner()) 63 if (!owner())
57 return; // We're closing; don't call anything, it might access the owner. 64 return; // We're closing; don't call anything, it might access the owner.
58 65
59 if (GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB)) 66 if (GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB))
60 RemoveSelf(); 67 RemoveSelf();
61 } 68 }
62 69
(...skipping 20 matching lines...) Expand all
83 return (delegate->GetButtons() & button) ? 90 return (delegate->GetButtons() & button) ?
84 delegate->GetButtonLabel(button) : base::string16(); 91 delegate->GetButtonLabel(button) : base::string16();
85 } 92 }
86 93
87 94
88 // Native JNI methods --------------------------------------------------------- 95 // Native JNI methods ---------------------------------------------------------
89 96
90 bool RegisterConfirmInfoBarDelegate(JNIEnv* env) { 97 bool RegisterConfirmInfoBarDelegate(JNIEnv* env) {
91 return RegisterNativesImpl(env); 98 return RegisterNativesImpl(env);
92 } 99 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/infobar/TranslateInfoBar.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698