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

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

Issue 2493013002: Replace the use of WindowAndroid with Tab in permissions code. (Closed)
Patch Set: Comments Created 4 years, 1 month 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/browser/ui/android/infobars/grouped_permission_infobar.cc ('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 2016 The Chromium Authors. All rights reserved. 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 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/permission_infobar.h" 5 #include "chrome/browser/ui/android/infobars/permission_infobar.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/android/jni_array.h" 11 #include "base/android/jni_array.h"
12 #include "base/android/jni_string.h" 12 #include "base/android/jni_string.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "chrome/browser/android/tab_android.h"
14 #include "chrome/browser/permissions/permission_infobar_delegate.h" 15 #include "chrome/browser/permissions/permission_infobar_delegate.h"
15 #include "chrome/browser/ui/android/infobars/confirm_infobar.h" 16 #include "chrome/browser/ui/android/infobars/confirm_infobar.h"
16 #include "components/content_settings/core/common/content_settings_types.h" 17 #include "components/content_settings/core/common/content_settings_types.h"
17 #include "jni/PermissionInfoBar_jni.h" 18 #include "jni/PermissionInfoBar_jni.h"
18 #include "ui/gfx/android/java_bitmap.h" 19 #include "ui/gfx/android/java_bitmap.h"
19 #include "ui/gfx/image/image.h" 20 #include "ui/gfx/image/image.h"
20 21
21 using base::android::ScopedJavaLocalRef; 22 using base::android::ScopedJavaLocalRef;
22 23
23 std::unique_ptr<infobars::InfoBar> CreatePermissionInfoBar( 24 std::unique_ptr<infobars::InfoBar> CreatePermissionInfoBar(
(...skipping 24 matching lines...) Expand all
48 base::android::ConvertUTF16ToJavaString(env, delegate->GetMessageText()); 49 base::android::ConvertUTF16ToJavaString(env, delegate->GetMessageText());
49 ScopedJavaLocalRef<jstring> link_text = 50 ScopedJavaLocalRef<jstring> link_text =
50 base::android::ConvertUTF16ToJavaString(env, delegate->GetLinkText()); 51 base::android::ConvertUTF16ToJavaString(env, delegate->GetLinkText());
51 52
52 ScopedJavaLocalRef<jobject> java_bitmap; 53 ScopedJavaLocalRef<jobject> java_bitmap;
53 if (delegate->GetIconId() == infobars::InfoBarDelegate::kNoIconID && 54 if (delegate->GetIconId() == infobars::InfoBarDelegate::kNoIconID &&
54 !delegate->GetIcon().IsEmpty()) { 55 !delegate->GetIcon().IsEmpty()) {
55 java_bitmap = gfx::ConvertToJavaBitmap(delegate->GetIcon().ToSkBitmap()); 56 java_bitmap = gfx::ConvertToJavaBitmap(delegate->GetIcon().ToSkBitmap());
56 } 57 }
57 58
58 std::vector<int> content_settings{delegate->content_settings()}; 59 std::vector<int> content_settings{delegate->content_settings_types()};
59 60
60 return Java_PermissionInfoBar_create( 61 return Java_PermissionInfoBar_create(
61 env, GetWindowAndroid().obj(), GetEnumeratedIconId(), java_bitmap.obj(), 62 env, GetTab()->GetJavaObject(), GetEnumeratedIconId(), java_bitmap.obj(),
62 message_text.obj(), link_text.obj(), ok_button_text.obj(), 63 message_text.obj(), link_text.obj(), ok_button_text.obj(),
63 cancel_button_text.obj(), 64 cancel_button_text.obj(),
64 base::android::ToJavaIntArray(env, content_settings).obj(), 65 base::android::ToJavaIntArray(env, content_settings).obj(),
65 delegate->ShouldShowPersistenceToggle()); 66 delegate->ShouldShowPersistenceToggle());
66 } 67 }
67 68
68 void PermissionInfoBar::ProcessButton(int action) { 69 void PermissionInfoBar::ProcessButton(int action) {
69 // Check if the delegate asked us to display a persistence toggle. If so, 70 // Check if the delegate asked us to display a persistence toggle. If so,
70 // inform it of the toggle state. 71 // inform it of the toggle state.
71 PermissionInfoBarDelegate* delegate = GetDelegate(); 72 PermissionInfoBarDelegate* delegate = GetDelegate();
72 if (delegate->ShouldShowPersistenceToggle()) { 73 if (delegate->ShouldShowPersistenceToggle()) {
73 delegate->set_persist(Java_PermissionInfoBar_isPersistSwitchOn( 74 delegate->set_persist(Java_PermissionInfoBar_isPersistSwitchOn(
74 base::android::AttachCurrentThread(), GetJavaInfoBar())); 75 base::android::AttachCurrentThread(), GetJavaInfoBar()));
75 } 76 }
76 77
77 ConfirmInfoBar::ProcessButton(action); 78 ConfirmInfoBar::ProcessButton(action);
78 } 79 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/infobars/grouped_permission_infobar.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698