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

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

Issue 819463002: Implement RevokePermission() method in PermissionService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, fix more comments, fix tests Created 5 years, 11 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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 return content::PERMISSION_STATUS_ASK; 612 return content::PERMISSION_STATUS_ASK;
613 case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT: 613 case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT:
614 case CONTENT_SETTING_DEFAULT: 614 case CONTENT_SETTING_DEFAULT:
615 case CONTENT_SETTING_NUM_SETTINGS: 615 case CONTENT_SETTING_NUM_SETTINGS:
616 break; 616 break;
617 } 617 }
618 NOTREACHED(); 618 NOTREACHED();
619 return content::PERMISSION_STATUS_DENIED; 619 return content::PERMISSION_STATUS_DENIED;
620 } 620 }
621 621
622 PermissionContextBase* GetPermissionContext(Profile* profile,
623 content::PermissionType permission) {
624 switch (permission) {
625 case content::PERMISSION_MIDI_SYSEX:
626 return MidiPermissionContextFactory::GetForProfile(profile);
627 case content::PERMISSION_NOTIFICATIONS:
628 #if defined(ENABLE_NOTIFICATIONS)
629 return DesktopNotificationServiceFactory::GetForProfile(profile);
630 #else
631 NOTIMPLEMENTED();
632 #endif
633 case content::PERMISSION_GEOLOCATION:
634 return GeolocationPermissionContextFactory::GetForProfile(profile);
635 case content::PERMISSION_PROTECTED_MEDIA:
636 NOTIMPLEMENTED();
637 break;
638 case content::PERMISSION_PUSH_MESSAGING:
639 return gcm::PushMessagingPermissionContextFactory::GetForProfile(profile);
640 case content::PERMISSION_NUM:
641 NOTREACHED() << "Invalid RequestPermission for " << permission;
642 break;
643 }
644 return nullptr;
645 }
646
622 } // namespace 647 } // namespace
623 648
624 namespace chrome { 649 namespace chrome {
625 650
626 ChromeContentBrowserClient::ChromeContentBrowserClient() 651 ChromeContentBrowserClient::ChromeContentBrowserClient()
627 : prerender_tracker_(NULL), 652 : prerender_tracker_(NULL),
628 weak_factory_(this) { 653 weak_factory_(this) {
629 #if defined(ENABLE_PLUGINS) 654 #if defined(ENABLE_PLUGINS)
630 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) 655 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i)
631 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); 656 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]);
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 } 1963 }
1939 } 1964 }
1940 1965
1941 content::PermissionStatus ChromeContentBrowserClient::GetPermissionStatus( 1966 content::PermissionStatus ChromeContentBrowserClient::GetPermissionStatus(
1942 content::PermissionType permission, 1967 content::PermissionType permission,
1943 content::BrowserContext* browser_context, 1968 content::BrowserContext* browser_context,
1944 const GURL& requesting_origin, 1969 const GURL& requesting_origin,
1945 const GURL& embedding_origin) { 1970 const GURL& embedding_origin) {
1946 DCHECK(browser_context); 1971 DCHECK(browser_context);
1947 Profile* profile = Profile::FromBrowserContext(browser_context); 1972 Profile* profile = Profile::FromBrowserContext(browser_context);
1973 PermissionContextBase* context = GetPermissionContext(profile, permission);
1948 1974
1949 PermissionContextBase* context = nullptr; 1975 if (!context)
1950 switch (permission) { 1976 return content::PERMISSION_STATUS_ASK;
1951 case content::PERMISSION_MIDI_SYSEX:
1952 context = MidiPermissionContextFactory::GetForProfile(profile);
1953 break;
1954 case content::PERMISSION_NOTIFICATIONS:
1955 #if defined(ENABLE_NOTIFICATIONS)
1956 context = DesktopNotificationServiceFactory::GetForProfile(profile);
1957 #else
1958 NOTIMPLEMENTED();
1959 #endif
1960 break;
1961 case content::PERMISSION_GEOLOCATION:
1962 context = GeolocationPermissionContextFactory::GetForProfile(profile);
1963 break;
1964 case content::PERMISSION_PROTECTED_MEDIA:
1965 NOTIMPLEMENTED();
1966 break;
1967 case content::PERMISSION_PUSH_MESSAGING:
1968 context = gcm::PushMessagingPermissionContextFactory::GetForProfile(
1969 profile);
1970 break;
1971 case content::PERMISSION_NUM:
1972 NOTREACHED() << "Invalid RequestPermission for " << permission;
1973 break;
1974 }
1975 1977
1976 ContentSetting result = context 1978 return ContentSettingToPermissionStatus(
1977 ? context->GetPermissionStatus(requesting_origin.GetOrigin(), 1979 context->GetPermissionStatus(requesting_origin.GetOrigin(),
1978 embedding_origin.GetOrigin()) 1980 embedding_origin.GetOrigin()));
1979 : CONTENT_SETTING_DEFAULT; 1981 }
1980 1982
1981 return ContentSettingToPermissionStatus(result); 1983 void ChromeContentBrowserClient::ResetPermission(
1984 content::PermissionType permission,
1985 content::BrowserContext* browser_context,
1986 const GURL& requesting_origin,
1987 const GURL& embedding_origin) {
1988 DCHECK(browser_context);
1989 Profile* profile = Profile::FromBrowserContext(browser_context);
1990 PermissionContextBase* context = GetPermissionContext(profile, permission);
1991
1992 if (!context)
1993 return;
1994
1995 context->ResetPermission(requesting_origin.GetOrigin(),
1996 embedding_origin.GetOrigin());
1982 } 1997 }
1983 1998
1984 void ChromeContentBrowserClient::CancelPermissionRequest( 1999 void ChromeContentBrowserClient::CancelPermissionRequest(
1985 content::PermissionType permission, 2000 content::PermissionType permission,
1986 content::WebContents* web_contents, 2001 content::WebContents* web_contents,
1987 int bridge_id, 2002 int bridge_id,
1988 const GURL& requesting_frame) { 2003 const GURL& requesting_frame) {
1989 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); 2004 int render_process_id = web_contents->GetRenderProcessHost()->GetID();
1990 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); 2005 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
1991 2006
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
2622 switches::kDisableWebRtcEncryption, 2637 switches::kDisableWebRtcEncryption,
2623 }; 2638 };
2624 to_command_line->CopySwitchesFrom(from_command_line, 2639 to_command_line->CopySwitchesFrom(from_command_line,
2625 kWebRtcDevSwitchNames, 2640 kWebRtcDevSwitchNames,
2626 arraysize(kWebRtcDevSwitchNames)); 2641 arraysize(kWebRtcDevSwitchNames));
2627 } 2642 }
2628 } 2643 }
2629 #endif // defined(ENABLE_WEBRTC) 2644 #endif // defined(ENABLE_WEBRTC)
2630 2645
2631 } // namespace chrome 2646 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698