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

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

Issue 1441143006: Disable Notifications in Incognito (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@innoinherit
Patch Set: Address nits Created 5 years 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
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 <vector> 7 #include <vector>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
11 #include "base/android/jni_string.h" 11 #include "base/android/jni_string.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "chrome/browser/android/resource_mapper.h" 13 #include "chrome/browser/android/resource_mapper.h"
14 #include "chrome/browser/infobars/infobar_service.h" 14 #include "chrome/browser/infobars/infobar_service.h"
15 #include "chrome/browser/media/media_stream_infobar_delegate_android.h"
15 #include "chrome/browser/permissions/permission_infobar_delegate.h" 16 #include "chrome/browser/permissions/permission_infobar_delegate.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 "components/infobars/core/confirm_infobar_delegate.h" 18 #include "components/infobars/core/confirm_infobar_delegate.h"
18 #include "content/public/browser/android/content_view_core.h" 19 #include "content/public/browser/android/content_view_core.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
20 #include "jni/ConfirmInfoBarDelegate_jni.h" 21 #include "jni/ConfirmInfoBarDelegate_jni.h"
21 #include "ui/android/window_android.h" 22 #include "ui/android/window_android.h"
22 #include "ui/gfx/android/java_bitmap.h" 23 #include "ui/gfx/android/java_bitmap.h"
23 #include "ui/gfx/image/image.h" 24 #include "ui/gfx/image/image.h"
24 25
25 #if defined(OS_ANDROID)
26 #include "chrome/browser/media/media_stream_infobar_delegate_android.h"
27 #endif
28
29 // InfoBarService ------------------------------------------------------------- 26 // InfoBarService -------------------------------------------------------------
30 27
31 scoped_ptr<infobars::InfoBar> InfoBarService::CreateConfirmInfoBar( 28 scoped_ptr<infobars::InfoBar> InfoBarService::CreateConfirmInfoBar(
32 scoped_ptr<ConfirmInfoBarDelegate> delegate) { 29 scoped_ptr<ConfirmInfoBarDelegate> delegate) {
33 return make_scoped_ptr(new ConfirmInfoBar(delegate.Pass())); 30 return make_scoped_ptr(new ConfirmInfoBar(delegate.Pass()));
34 } 31 }
35 32
36 33
37 // ConfirmInfoBar ------------------------------------------------------------- 34 // ConfirmInfoBar -------------------------------------------------------------
38 35
(...skipping 24 matching lines...) Expand all
63 ScopedJavaLocalRef<jobject> java_bitmap; 60 ScopedJavaLocalRef<jobject> java_bitmap;
64 if (delegate->GetIconId() == infobars::InfoBarDelegate::kNoIconID && 61 if (delegate->GetIconId() == infobars::InfoBarDelegate::kNoIconID &&
65 !delegate->GetIcon().IsEmpty()) { 62 !delegate->GetIcon().IsEmpty()) {
66 java_bitmap = gfx::ConvertToJavaBitmap(delegate->GetIcon().ToSkBitmap()); 63 java_bitmap = gfx::ConvertToJavaBitmap(delegate->GetIcon().ToSkBitmap());
67 } 64 }
68 65
69 std::vector<int> content_settings; 66 std::vector<int> content_settings;
70 if (delegate->AsPermissionInfobarDelegate()) { 67 if (delegate->AsPermissionInfobarDelegate()) {
71 content_settings.push_back( 68 content_settings.push_back(
72 delegate->AsPermissionInfobarDelegate()->content_setting()); 69 delegate->AsPermissionInfobarDelegate()->content_setting());
73 #if defined(OS_ANDROID)
74 } else if (delegate->AsMediaStreamInfoBarDelegateAndroid()) { 70 } else if (delegate->AsMediaStreamInfoBarDelegateAndroid()) {
75 MediaStreamInfoBarDelegateAndroid* media_delegate = 71 MediaStreamInfoBarDelegateAndroid* media_delegate =
76 delegate->AsMediaStreamInfoBarDelegateAndroid(); 72 delegate->AsMediaStreamInfoBarDelegateAndroid();
77 if (media_delegate->IsRequestingVideoAccess()) { 73 if (media_delegate->IsRequestingVideoAccess()) {
78 content_settings.push_back( 74 content_settings.push_back(
79 ContentSettingsType::CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 75 ContentSettingsType::CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
80 } 76 }
81 if (media_delegate->IsRequestingMicrophoneAccess()) { 77 if (media_delegate->IsRequestingMicrophoneAccess()) {
82 content_settings.push_back( 78 content_settings.push_back(
83 ContentSettingsType::CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); 79 ContentSettingsType::CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
84 } 80 }
85 #endif
86 } 81 }
87 82
88 content::WebContents* web_contents = 83 content::WebContents* web_contents =
89 InfoBarService::WebContentsFromInfoBar(this); 84 InfoBarService::WebContentsFromInfoBar(this);
90 DCHECK(web_contents); 85 DCHECK(web_contents);
91 content::ContentViewCore* cvc = 86 content::ContentViewCore* cvc =
92 content::ContentViewCore::FromWebContents(web_contents); 87 content::ContentViewCore::FromWebContents(web_contents);
93 DCHECK(cvc); 88 DCHECK(cvc);
94 base::android::ScopedJavaLocalRef<jobject> jwindow_android = 89 base::android::ScopedJavaLocalRef<jobject> jwindow_android =
95 cvc->GetWindowAndroid()->GetJavaObject(); 90 cvc->GetWindowAndroid()->GetJavaObject();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 return (delegate->GetButtons() & button) ? 128 return (delegate->GetButtons() & button) ?
134 delegate->GetButtonLabel(button) : base::string16(); 129 delegate->GetButtonLabel(button) : base::string16();
135 } 130 }
136 131
137 132
138 // Native JNI methods --------------------------------------------------------- 133 // Native JNI methods ---------------------------------------------------------
139 134
140 bool RegisterConfirmInfoBarDelegate(JNIEnv* env) { 135 bool RegisterConfirmInfoBarDelegate(JNIEnv* env) {
141 return RegisterNativesImpl(env); 136 return RegisterNativesImpl(env);
142 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698