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

Side by Side Diff: chrome/browser/permissions/permission_dialog_delegate.cc

Issue 2811913002: Pull code associated with a Media PermissionRequest out of MediaStreamDevicesController (Closed)
Patch Set: MediaRequest Created 3 years, 8 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
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/permissions/permission_dialog_delegate.h" 5 #include "chrome/browser/permissions/permission_dialog_delegate.h"
6 6
7 #include <utility> 7 #include <utility>
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/feature_list.h" 12 #include "base/feature_list.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/android/resource_mapper.h" 14 #include "chrome/browser/android/resource_mapper.h"
15 #include "chrome/browser/android/tab_android.h" 15 #include "chrome/browser/android/tab_android.h"
16 #include "chrome/browser/geolocation/geolocation_infobar_delegate_android.h" 16 #include "chrome/browser/geolocation/geolocation_infobar_delegate_android.h"
17 #include "chrome/browser/media/midi_permission_infobar_delegate_android.h" 17 #include "chrome/browser/media/midi_permission_infobar_delegate_android.h"
18 #include "chrome/browser/media/protected_media_identifier_infobar_delegate_andro id.h" 18 #include "chrome/browser/media/protected_media_identifier_infobar_delegate_andro id.h"
19 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h"
20 #include "chrome/browser/media/webrtc/media_stream_infobar_delegate_android.h" 19 #include "chrome/browser/media/webrtc/media_stream_infobar_delegate_android.h"
21 #include "chrome/browser/notifications/notification_permission_infobar_delegate. h" 20 #include "chrome/browser/notifications/notification_permission_infobar_delegate. h"
22 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/common/chrome_features.h" 22 #include "chrome/common/chrome_features.h"
24 #include "components/variations/variations_associated_data.h" 23 #include "components/variations/variations_associated_data.h"
25 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
26 #include "jni/PermissionDialogController_jni.h" 25 #include "jni/PermissionDialogController_jni.h"
27 #include "jni/PermissionDialogDelegate_jni.h" 26 #include "jni/PermissionDialogDelegate_jni.h"
28 #include "ui/android/window_android.h" 27 #include "ui/android/window_android.h"
29 #include "ui/base/window_open_disposition.h" 28 #include "ui/base/window_open_disposition.h"
(...skipping 27 matching lines...) Expand all
57 // Dispatch the dialog to Java, which manages the lifetime of this object. 56 // Dispatch the dialog to Java, which manages the lifetime of this object.
58 new PermissionDialogDelegate( 57 new PermissionDialogDelegate(
59 tab, PermissionInfoBarDelegate::CreateDelegate( 58 tab, PermissionInfoBarDelegate::CreateDelegate(
60 type, requesting_frame, user_gesture, profile, callback)); 59 type, requesting_frame, user_gesture, profile, callback));
61 } 60 }
62 61
63 // static 62 // static
64 void PermissionDialogDelegate::CreateMediaStreamDialog( 63 void PermissionDialogDelegate::CreateMediaStreamDialog(
65 content::WebContents* web_contents, 64 content::WebContents* web_contents,
66 bool user_gesture, 65 bool user_gesture,
67 std::unique_ptr<MediaStreamDevicesController> controller) { 66 std::unique_ptr<MediaStreamDevicesController::Request> request) {
68 DCHECK(web_contents); 67 DCHECK(web_contents);
69 68
70 // If we don't have a tab, just act as though the prompt was dismissed. 69 // If we don't have a tab, just act as though the prompt was dismissed.
71 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); 70 TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
72 if (!tab) { 71 if (!tab) {
73 controller->Cancelled(); 72 request->Cancelled();
74 return; 73 return;
75 } 74 }
76 75
77 // Called this way because the infobar delegate has a private destructor. 76 // Called this way because the infobar delegate has a private destructor.
78 std::unique_ptr<PermissionInfoBarDelegate> infobar_delegate; 77 std::unique_ptr<PermissionInfoBarDelegate> infobar_delegate;
79 infobar_delegate.reset(new MediaStreamInfoBarDelegateAndroid( 78 infobar_delegate.reset(new MediaStreamInfoBarDelegateAndroid(
80 Profile::FromBrowserContext(web_contents->GetBrowserContext()), 79 Profile::FromBrowserContext(web_contents->GetBrowserContext()),
81 user_gesture, 80 user_gesture, std::move(request)));
82 std::move(controller)));
83 81
84 // Dispatch the dialog to Java, which manages the lifetime of this object. 82 // Dispatch the dialog to Java, which manages the lifetime of this object.
85 new PermissionDialogDelegate(tab, std::move(infobar_delegate)); 83 new PermissionDialogDelegate(tab, std::move(infobar_delegate));
86 } 84 }
87 85
88 // static 86 // static
89 bool PermissionDialogDelegate::ShouldShowDialog(bool has_user_gesture) { 87 bool PermissionDialogDelegate::ShouldShowDialog(bool has_user_gesture) {
90 if (!base::FeatureList::IsEnabled(features::kModalPermissionPrompts)) 88 if (!base::FeatureList::IsEnabled(features::kModalPermissionPrompts))
91 return false; 89 return false;
92 90
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 base::android::ScopedJavaLocalRef<jobject> j_delegate = 173 base::android::ScopedJavaLocalRef<jobject> j_delegate =
176 CreateJavaDelegate(env); 174 CreateJavaDelegate(env);
177 175
178 // Send the Java delegate to the Java PermissionDialogController for display. 176 // Send the Java delegate to the Java PermissionDialogController for display.
179 // The controller takes over lifetime management; when the Java delegate is no 177 // The controller takes over lifetime management; when the Java delegate is no
180 // longer needed it will in turn free the native delegate. 178 // longer needed it will in turn free the native delegate.
181 Java_PermissionDialogController_createDialog(env, j_delegate.obj()); 179 Java_PermissionDialogController_createDialog(env, j_delegate.obj());
182 } 180 }
183 181
184 PermissionDialogDelegate::~PermissionDialogDelegate() {} 182 PermissionDialogDelegate::~PermissionDialogDelegate() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698