OLD | NEW |
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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 return content::PERMISSION_STATUS_ASK; | 613 return content::PERMISSION_STATUS_ASK; |
614 case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT: | 614 case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT: |
615 case CONTENT_SETTING_DEFAULT: | 615 case CONTENT_SETTING_DEFAULT: |
616 case CONTENT_SETTING_NUM_SETTINGS: | 616 case CONTENT_SETTING_NUM_SETTINGS: |
617 break; | 617 break; |
618 } | 618 } |
619 NOTREACHED(); | 619 NOTREACHED(); |
620 return content::PERMISSION_STATUS_DENIED; | 620 return content::PERMISSION_STATUS_DENIED; |
621 } | 621 } |
622 | 622 |
| 623 PermissionContextBase* GetPermissionContext(Profile* profile, |
| 624 content::PermissionType permission) { |
| 625 switch (permission) { |
| 626 case content::PERMISSION_MIDI_SYSEX: |
| 627 return MidiPermissionContextFactory::GetForProfile(profile); |
| 628 case content::PERMISSION_NOTIFICATIONS: |
| 629 #if defined(ENABLE_NOTIFICATIONS) |
| 630 return DesktopNotificationServiceFactory::GetForProfile(profile); |
| 631 #else |
| 632 NOTIMPLEMENTED(); |
| 633 #endif |
| 634 case content::PERMISSION_GEOLOCATION: |
| 635 return GeolocationPermissionContextFactory::GetForProfile(profile); |
| 636 case content::PERMISSION_PROTECTED_MEDIA_IDENTIFIER: |
| 637 #if defined(OS_ANDROID) |
| 638 return ProtectedMediaIdentifierPermissionContextFactory::GetForProfile( |
| 639 profile); |
| 640 #else |
| 641 NOTIMPLEMENTED(); |
| 642 break; |
| 643 #endif |
| 644 case content::PERMISSION_PUSH_MESSAGING: |
| 645 return gcm::PushMessagingPermissionContextFactory::GetForProfile(profile); |
| 646 case content::PERMISSION_NUM: |
| 647 NOTREACHED() << "Invalid RequestPermission for " << permission; |
| 648 break; |
| 649 } |
| 650 return nullptr; |
| 651 } |
| 652 |
623 } // namespace | 653 } // namespace |
624 | 654 |
625 namespace chrome { | 655 namespace chrome { |
626 | 656 |
627 ChromeContentBrowserClient::ChromeContentBrowserClient() | 657 ChromeContentBrowserClient::ChromeContentBrowserClient() |
628 : prerender_tracker_(NULL), | 658 : prerender_tracker_(NULL), |
629 weak_factory_(this) { | 659 weak_factory_(this) { |
630 #if defined(ENABLE_PLUGINS) | 660 #if defined(ENABLE_PLUGINS) |
631 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) | 661 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) |
632 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); | 662 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); |
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 } | 1969 } |
1940 } | 1970 } |
1941 | 1971 |
1942 content::PermissionStatus ChromeContentBrowserClient::GetPermissionStatus( | 1972 content::PermissionStatus ChromeContentBrowserClient::GetPermissionStatus( |
1943 content::PermissionType permission, | 1973 content::PermissionType permission, |
1944 content::BrowserContext* browser_context, | 1974 content::BrowserContext* browser_context, |
1945 const GURL& requesting_origin, | 1975 const GURL& requesting_origin, |
1946 const GURL& embedding_origin) { | 1976 const GURL& embedding_origin) { |
1947 DCHECK(browser_context); | 1977 DCHECK(browser_context); |
1948 Profile* profile = Profile::FromBrowserContext(browser_context); | 1978 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 1979 PermissionContextBase* context = GetPermissionContext(profile, permission); |
1949 | 1980 |
1950 PermissionContextBase* context = nullptr; | 1981 if (!context) |
1951 switch (permission) { | 1982 return content::PERMISSION_STATUS_ASK; |
1952 case content::PERMISSION_MIDI_SYSEX: | |
1953 context = MidiPermissionContextFactory::GetForProfile(profile); | |
1954 break; | |
1955 case content::PERMISSION_NOTIFICATIONS: | |
1956 #if defined(ENABLE_NOTIFICATIONS) | |
1957 context = DesktopNotificationServiceFactory::GetForProfile(profile); | |
1958 #else | |
1959 NOTIMPLEMENTED(); | |
1960 #endif | |
1961 break; | |
1962 case content::PERMISSION_GEOLOCATION: | |
1963 context = GeolocationPermissionContextFactory::GetForProfile(profile); | |
1964 break; | |
1965 case content::PERMISSION_PROTECTED_MEDIA_IDENTIFIER: | |
1966 #if defined(OS_ANDROID) | |
1967 context = ProtectedMediaIdentifierPermissionContextFactory::GetForProfile( | |
1968 profile); | |
1969 #else | |
1970 NOTIMPLEMENTED(); | |
1971 #endif | |
1972 break; | |
1973 case content::PERMISSION_PUSH_MESSAGING: | |
1974 context = gcm::PushMessagingPermissionContextFactory::GetForProfile( | |
1975 profile); | |
1976 break; | |
1977 case content::PERMISSION_NUM: | |
1978 NOTREACHED() << "Invalid RequestPermission for " << permission; | |
1979 break; | |
1980 } | |
1981 | 1983 |
1982 ContentSetting result = context | 1984 return ContentSettingToPermissionStatus( |
1983 ? context->GetPermissionStatus(requesting_origin.GetOrigin(), | 1985 context->GetPermissionStatus(requesting_origin.GetOrigin(), |
1984 embedding_origin.GetOrigin()) | 1986 embedding_origin.GetOrigin())); |
1985 : CONTENT_SETTING_DEFAULT; | 1987 } |
1986 | 1988 |
1987 return ContentSettingToPermissionStatus(result); | 1989 void ChromeContentBrowserClient::ResetPermission( |
| 1990 content::PermissionType permission, |
| 1991 content::BrowserContext* browser_context, |
| 1992 const GURL& requesting_origin, |
| 1993 const GURL& embedding_origin) { |
| 1994 DCHECK(browser_context); |
| 1995 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 1996 PermissionContextBase* context = GetPermissionContext(profile, permission); |
| 1997 |
| 1998 if (!context) |
| 1999 return; |
| 2000 |
| 2001 context->ResetPermission(requesting_origin.GetOrigin(), |
| 2002 embedding_origin.GetOrigin()); |
1988 } | 2003 } |
1989 | 2004 |
1990 void ChromeContentBrowserClient::CancelPermissionRequest( | 2005 void ChromeContentBrowserClient::CancelPermissionRequest( |
1991 content::PermissionType permission, | 2006 content::PermissionType permission, |
1992 content::WebContents* web_contents, | 2007 content::WebContents* web_contents, |
1993 int bridge_id, | 2008 int bridge_id, |
1994 const GURL& requesting_frame) { | 2009 const GURL& requesting_frame) { |
1995 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); | 2010 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); |
1996 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); | 2011 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
1997 | 2012 |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2647 switches::kDisableWebRtcEncryption, | 2662 switches::kDisableWebRtcEncryption, |
2648 }; | 2663 }; |
2649 to_command_line->CopySwitchesFrom(from_command_line, | 2664 to_command_line->CopySwitchesFrom(from_command_line, |
2650 kWebRtcDevSwitchNames, | 2665 kWebRtcDevSwitchNames, |
2651 arraysize(kWebRtcDevSwitchNames)); | 2666 arraysize(kWebRtcDevSwitchNames)); |
2652 } | 2667 } |
2653 } | 2668 } |
2654 #endif // defined(ENABLE_WEBRTC) | 2669 #endif // defined(ENABLE_WEBRTC) |
2655 | 2670 |
2656 } // namespace chrome | 2671 } // namespace chrome |
OLD | NEW |