OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/permissions/permission_update_infobar_delegate_android.
h" | 5 #include "chrome/browser/permissions/permission_update_infobar_delegate_android.
h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 infobar()->RemoveSelf(); | 80 infobar()->RemoveSelf(); |
81 } | 81 } |
82 | 82 |
83 PermissionUpdateInfoBarDelegate::PermissionUpdateInfoBarDelegate( | 83 PermissionUpdateInfoBarDelegate::PermissionUpdateInfoBarDelegate( |
84 content::WebContents* web_contents, | 84 content::WebContents* web_contents, |
85 const std::vector<ContentSettingsType>& content_settings_types, | 85 const std::vector<ContentSettingsType>& content_settings_types, |
86 const PermissionUpdatedCallback& callback) | 86 const PermissionUpdatedCallback& callback) |
87 : ConfirmInfoBarDelegate(), | 87 : ConfirmInfoBarDelegate(), |
88 content_settings_types_(content_settings_types), | 88 content_settings_types_(content_settings_types), |
89 callback_(callback) { | 89 callback_(callback) { |
| 90 #if !defined(USE_AURA) |
90 std::vector<int> content_settings_type_values; | 91 std::vector<int> content_settings_type_values; |
91 for (ContentSettingsType type : content_settings_types) | 92 for (ContentSettingsType type : content_settings_types) |
92 content_settings_type_values.push_back(type); | 93 content_settings_type_values.push_back(type); |
93 | 94 |
94 JNIEnv* env = base::android::AttachCurrentThread(); | 95 JNIEnv* env = base::android::AttachCurrentThread(); |
95 java_delegate_.Reset(Java_PermissionUpdateInfoBarDelegate_create( | 96 java_delegate_.Reset(Java_PermissionUpdateInfoBarDelegate_create( |
96 env, | 97 env, |
97 reinterpret_cast<intptr_t>(this), | 98 reinterpret_cast<intptr_t>(this), |
98 web_contents->GetJavaWebContents().obj(), | 99 web_contents->GetJavaWebContents().obj(), |
99 base::android::ToJavaIntArray(env, content_settings_type_values).obj())); | 100 base::android::ToJavaIntArray(env, content_settings_type_values).obj())); |
100 | 101 |
101 content::ContentViewCore* cvc = | 102 content::ContentViewCore* cvc = |
102 content::ContentViewCore::FromWebContents(web_contents); | 103 content::ContentViewCore::FromWebContents(web_contents); |
103 window_android_ = cvc->GetWindowAndroid(); | 104 window_android_ = cvc->GetWindowAndroid(); |
| 105 #endif |
104 } | 106 } |
105 | 107 |
106 PermissionUpdateInfoBarDelegate::~PermissionUpdateInfoBarDelegate() { | 108 PermissionUpdateInfoBarDelegate::~PermissionUpdateInfoBarDelegate() { |
107 Java_PermissionUpdateInfoBarDelegate_onNativeDestroyed( | 109 Java_PermissionUpdateInfoBarDelegate_onNativeDestroyed( |
108 base::android::AttachCurrentThread(), java_delegate_.obj()); | 110 base::android::AttachCurrentThread(), java_delegate_.obj()); |
109 } | 111 } |
110 | 112 |
111 int PermissionUpdateInfoBarDelegate::GetIconID() const { | 113 int PermissionUpdateInfoBarDelegate::GetIconID() const { |
112 return IDR_INFOBAR_WARNING; | 114 return IDR_INFOBAR_WARNING; |
113 } | 115 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 bool PermissionUpdateInfoBarDelegate::Accept() { | 165 bool PermissionUpdateInfoBarDelegate::Accept() { |
164 Java_PermissionUpdateInfoBarDelegate_requestPermissions( | 166 Java_PermissionUpdateInfoBarDelegate_requestPermissions( |
165 base::android::AttachCurrentThread(), java_delegate_.obj()); | 167 base::android::AttachCurrentThread(), java_delegate_.obj()); |
166 return false; | 168 return false; |
167 } | 169 } |
168 | 170 |
169 bool PermissionUpdateInfoBarDelegate::Cancel() { | 171 bool PermissionUpdateInfoBarDelegate::Cancel() { |
170 callback_.Run(false); | 172 callback_.Run(false); |
171 return true; | 173 return true; |
172 } | 174 } |
OLD | NEW |