Chromium Code Reviews| Index: chrome/browser/chrome_content_browser_client.cc |
| diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc |
| index 4f58d2fba0344ebf080b42057b37b3dc1c8a5d6a..ca625e31016572df24247dae82b7977760e7d1cf 100644 |
| --- a/chrome/browser/chrome_content_browser_client.cc |
| +++ b/chrome/browser/chrome_content_browser_client.cc |
| @@ -594,6 +594,24 @@ void GetGuestViewDefaultContentSettingRules( |
| } |
| #endif // defined(ENALBE_EXTENSIONS) |
| +content::PermissionStatus |
|
Tom Sepez
2014/12/01 18:42:38
nit: The style guide would say to put the function
|
| +ContentSettingToPermissionStatus(ContentSetting setting) { |
| + switch (setting) { |
| + case CONTENT_SETTING_ALLOW: |
| + case CONTENT_SETTING_SESSION_ONLY: |
| + return content::PERMISSION_STATUS_GRANTED; |
| + case CONTENT_SETTING_BLOCK: |
| + return content::PERMISSION_STATUS_DENIED; |
| + case CONTENT_SETTING_ASK: |
| + return content::PERMISSION_STATUS_ASK; |
| + case CONTENT_SETTING_DEFAULT: |
| + case CONTENT_SETTING_NUM_SETTINGS: |
| + break; |
| + } |
| + NOTREACHED(); |
| + return content::PERMISSION_STATUS_DENIED; |
| +} |
| + |
| } // namespace |
| namespace chrome { |
| @@ -1973,6 +1991,49 @@ void ChromeContentBrowserClient::RequestPermission( |
| } |
| } |
| +content::PermissionStatus ChromeContentBrowserClient::GetPermissionStatus( |
| + content::PermissionType permission, |
| + content::BrowserContext* browser_context, |
| + const GURL& requesting_origin, |
| + const GURL& embedding_origin) { |
| + DCHECK(browser_context); |
| + Profile* profile = Profile::FromBrowserContext(browser_context); |
| + |
| + PermissionContextBase* context = nullptr; |
| + switch (permission) { |
| + case content::PERMISSION_MIDI_SYSEX: |
| + context = MidiPermissionContextFactory::GetForProfile(profile); |
| + break; |
| + case content::PERMISSION_NOTIFICATIONS: |
| +#if defined(ENABLE_NOTIFICATIONS) |
| + context = DesktopNotificationServiceFactory::GetForProfile(profile); |
| +#else |
| + NOTIMPLEMENTED(); |
| +#endif |
| + break; |
| + case content::PERMISSION_GEOLOCATION: |
| + context = GeolocationPermissionContextFactory::GetForProfile(profile); |
| + break; |
| + case content::PERMISSION_PROTECTED_MEDIA: |
| + NOTIMPLEMENTED(); |
| + break; |
| + case content::PERMISSION_PUSH_MESSAGING: |
| + context = gcm::PushMessagingPermissionContextFactory::GetForProfile( |
| + profile); |
| + break; |
| + case content::PERMISSION_NUM: |
| + NOTREACHED() << "Invalid RequestPermission for " << permission; |
| + break; |
| + } |
| + |
| + ContentSetting result = context |
| + ? context->GetPermissionStatus(requesting_origin.GetOrigin(), |
|
Tom Sepez
2014/12/01 18:42:38
nit: ? and : prior to line break.
|
| + embedding_origin.GetOrigin()) |
| + : CONTENT_SETTING_DEFAULT; |
| + |
| + return ContentSettingToPermissionStatus(result); |
| +} |
| + |
| void ChromeContentBrowserClient::CancelPermissionRequest( |
| content::PermissionType permission, |
| content::WebContents* web_contents, |