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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 571483002: Refactor content client to include a single Request/CancelPermission method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@geoloc_permission
Patch Set: Created 6 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 service->ShowDesktopNotification( 1915 service->ShowDesktopNotification(
1916 params, render_frame_host, delegate.Pass(), cancel_callback); 1916 params, render_frame_host, delegate.Pass(), cancel_callback);
1917 1917
1918 profile->GetHostContentSettingsMap()->UpdateLastUsage( 1918 profile->GetHostContentSettingsMap()->UpdateLastUsage(
1919 params.origin, params.origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 1919 params.origin, params.origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
1920 #else 1920 #else
1921 NOTIMPLEMENTED(); 1921 NOTIMPLEMENTED();
1922 #endif 1922 #endif
1923 } 1923 }
1924 1924
1925 void ChromeContentBrowserClient::RequestGeolocationPermission( 1925 void ChromeContentBrowserClient::RequestPermission(
1926 content::PermissionType permission,
1926 content::WebContents* web_contents, 1927 content::WebContents* web_contents,
1927 int bridge_id, 1928 int bridge_id,
1928 const GURL& requesting_frame, 1929 const GURL& requesting_frame,
1929 bool user_gesture, 1930 bool user_gesture,
1930 const base::Callback<void(bool)>& result_callback) { 1931 const base::Callback<void(bool)>& result_callback) {
1931 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); 1932 int render_process_id = web_contents->GetRenderProcessHost()->GetID();
1932 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); 1933 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
1933 1934
1934 const PermissionRequestID request_id(render_process_id, 1935 const PermissionRequestID request_id(render_process_id,
1935 render_view_id, 1936 render_view_id,
1936 bridge_id, 1937 bridge_id,
1937 requesting_frame); 1938 requesting_frame);
1938 GeolocationPermissionContextFactory::GetForProfile( 1939
1939 Profile::FromBrowserContext(web_contents->GetBrowserContext()))-> 1940 switch (permission) {
1940 RequestPermission(web_contents, request_id, 1941 case content::PERMISSION_MIDI_SYSEX:
1941 requesting_frame.GetOrigin(), user_gesture, 1942 MidiPermissionContextFactory::GetForProfile(
1942 result_callback); 1943 Profile::FromBrowserContext(web_contents->GetBrowserContext()))
1944 ->RequestPermission(web_contents, request_id, requesting_frame,
1945 user_gesture, result_callback);
1946 break;
1947 case content::PERMISSION_NOTIFICATIONS:
1948 // TODO(miguelg) implement notifications once the platform refactor
1949 // is finished.
1950 LOG(WARNING) << "Permission request not implemented for " << permission;
1951 break;
1952 case content::PERMISSION_GEOLOCATION:
1953 GeolocationPermissionContextFactory::GetForProfile(
1954 Profile::FromBrowserContext(web_contents->GetBrowserContext()))
1955 ->RequestPermission(web_contents, request_id,
1956 requesting_frame.GetOrigin(), user_gesture,
1957 result_callback);
1958 break;
1959 #if defined(OS_ANDROID)
1960 case content::PERMISSION_PROTECTED_MEDIA:
1961 ProtectedMediaIdentifierPermissionContextFactory::GetForProfile(
1962 Profile::FromBrowserContext(web_contents->GetBrowserContext()))
1963 ->RequestProtectedMediaIdentifierPermission(web_contents,
1964 requesting_frame,
1965 result_callback);
1966 break;
1967 #endif
1968 default:
1969 LOG(WARNING) << "Permission not available " << permission;
1970 }
1971
1943 } 1972 }
1944 1973
1945 void ChromeContentBrowserClient::CancelGeolocationPermissionRequest( 1974 void ChromeContentBrowserClient::CancelPermissionRequest(
1975 content::PermissionType permission,
1946 content::WebContents* web_contents, 1976 content::WebContents* web_contents,
1947 int bridge_id, 1977 int bridge_id,
1948 const GURL& requesting_frame) { 1978 const GURL& requesting_frame) {
1949 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); 1979 int render_process_id = web_contents->GetRenderProcessHost()->GetID();
1950 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); 1980 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
1951 1981
1952 const PermissionRequestID request_id(render_process_id, 1982 const PermissionRequestID request_id(render_process_id,
1953 render_view_id, 1983 render_view_id,
1954 bridge_id, 1984 bridge_id,
1955 requesting_frame); 1985 requesting_frame);
1956 GeolocationPermissionContextFactory::GetForProfile( 1986 switch (permission) {
1957 Profile::FromBrowserContext(web_contents->GetBrowserContext()))-> 1987 case content::PERMISSION_MIDI_SYSEX:
1958 CancelPermissionRequest(web_contents, request_id); 1988 MidiPermissionContextFactory::GetForProfile(
1989 Profile::FromBrowserContext(web_contents->GetBrowserContext()))
1990 ->CancelPermissionRequest(web_contents, request_id);
1991 break;
1992 case content::PERMISSION_NOTIFICATIONS:
1993 // TODO(miguelg) implement notifications once the platform refactor
1994 // is finished.
1995 LOG(WARNING) << "Cancel Permission request not implemented for "
1996 << permission;
1997 break;
1998 case content::PERMISSION_GEOLOCATION:
1999 GeolocationPermissionContextFactory::GetForProfile(
2000 Profile::FromBrowserContext(
2001 web_contents->GetBrowserContext()))
2002 ->CancelPermissionRequest(web_contents, request_id);
2003 break;
2004 #if defined(OS_ANDROID)
2005 case content::PERMISSION_PROTECTED_MEDIA:
2006 ProtectedMediaIdentifierPermissionContextFactory::GetForProfile(
2007 Profile::FromBrowserContext(web_contents->GetBrowserContext()))
2008 ->CancelProtectedMediaIdentifierPermissionRequests(
2009 render_process_id,
2010 render_view_id,
2011 requesting_frame);
2012 break;
2013 #endif
2014 default:
2015 LOG(WARNING) << "Permission not available " << permission;
2016 }
1959 } 2017 }
1960 2018
1961 void ChromeContentBrowserClient::RequestMidiSysExPermission(
1962 content::WebContents* web_contents,
1963 int bridge_id,
1964 const GURL& requesting_frame,
1965 bool user_gesture,
1966 base::Callback<void(bool)> result_callback,
1967 base::Closure* cancel_callback) {
1968 MidiPermissionContext* context =
1969 MidiPermissionContextFactory::GetForProfile(
1970 Profile::FromBrowserContext(web_contents->GetBrowserContext()));
1971 int renderer_id = web_contents->GetRenderProcessHost()->GetID();
1972 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
1973 const PermissionRequestID id(renderer_id, render_view_id, bridge_id, GURL());
1974
1975 context->RequestPermission(web_contents, id, requesting_frame,
1976 user_gesture, result_callback);
1977 }
1978 2019
1979 void ChromeContentBrowserClient::DidUseGeolocationPermission( 2020 void ChromeContentBrowserClient::DidUseGeolocationPermission(
1980 content::WebContents* web_contents, 2021 content::WebContents* web_contents,
1981 const GURL& frame_url, 2022 const GURL& frame_url,
1982 const GURL& main_frame_url) { 2023 const GURL& main_frame_url) {
1983 Profile::FromBrowserContext(web_contents->GetBrowserContext()) 2024 Profile::FromBrowserContext(web_contents->GetBrowserContext())
1984 ->GetHostContentSettingsMap() 2025 ->GetHostContentSettingsMap()
1985 ->UpdateLastUsage( 2026 ->UpdateLastUsage(
1986 frame_url, main_frame_url, CONTENT_SETTINGS_TYPE_GEOLOCATION); 2027 frame_url, main_frame_url, CONTENT_SETTINGS_TYPE_GEOLOCATION);
1987 } 2028 }
1988 2029
1989 void ChromeContentBrowserClient::RequestProtectedMediaIdentifierPermission(
1990 content::WebContents* web_contents,
1991 const GURL& origin,
1992 base::Callback<void(bool)> result_callback,
1993 base::Closure* cancel_callback) {
1994 #if defined(OS_ANDROID)
1995 ProtectedMediaIdentifierPermissionContext* context =
1996 ProtectedMediaIdentifierPermissionContextFactory::GetForProfile(
1997 Profile::FromBrowserContext(web_contents->GetBrowserContext()));
1998 context->RequestProtectedMediaIdentifierPermission(web_contents,
1999 origin,
2000 result_callback,
2001 cancel_callback);
2002 #else
2003 NOTIMPLEMENTED();
2004 result_callback.Run(false);
2005 #endif // defined(OS_ANDROID)
2006 }
2007
2008 bool ChromeContentBrowserClient::CanCreateWindow( 2030 bool ChromeContentBrowserClient::CanCreateWindow(
2009 const GURL& opener_url, 2031 const GURL& opener_url,
2010 const GURL& opener_top_level_frame_url, 2032 const GURL& opener_top_level_frame_url,
2011 const GURL& source_origin, 2033 const GURL& source_origin,
2012 WindowContainerType container_type, 2034 WindowContainerType container_type,
2013 const GURL& target_url, 2035 const GURL& target_url,
2014 const content::Referrer& referrer, 2036 const content::Referrer& referrer,
2015 WindowOpenDisposition disposition, 2037 WindowOpenDisposition disposition,
2016 const WebWindowFeatures& features, 2038 const WebWindowFeatures& features,
2017 bool user_gesture, 2039 bool user_gesture,
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
2613 switches::kDisableWebRtcEncryption, 2635 switches::kDisableWebRtcEncryption,
2614 }; 2636 };
2615 to_command_line->CopySwitchesFrom(from_command_line, 2637 to_command_line->CopySwitchesFrom(from_command_line,
2616 kWebRtcDevSwitchNames, 2638 kWebRtcDevSwitchNames,
2617 arraysize(kWebRtcDevSwitchNames)); 2639 arraysize(kWebRtcDevSwitchNames));
2618 } 2640 }
2619 } 2641 }
2620 #endif // defined(ENABLE_WEBRTC) 2642 #endif // defined(ENABLE_WEBRTC)
2621 2643
2622 } // namespace chrome 2644 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | chrome/browser/media/protected_media_identifier_permission_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698