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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 | 587 |
588 rules->script_rules.push_back( | 588 rules->script_rules.push_back( |
589 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), | 589 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), |
590 ContentSettingsPattern::Wildcard(), | 590 ContentSettingsPattern::Wildcard(), |
591 CONTENT_SETTING_ALLOW, | 591 CONTENT_SETTING_ALLOW, |
592 std::string(), | 592 std::string(), |
593 incognito)); | 593 incognito)); |
594 } | 594 } |
595 #endif // defined(ENALBE_EXTENSIONS) | 595 #endif // defined(ENALBE_EXTENSIONS) |
596 | 596 |
597 content::PermissionStatus | |
Tom Sepez
2014/12/01 18:42:38
nit: The style guide would say to put the function
| |
598 ContentSettingToPermissionStatus(ContentSetting setting) { | |
599 switch (setting) { | |
600 case CONTENT_SETTING_ALLOW: | |
601 case CONTENT_SETTING_SESSION_ONLY: | |
602 return content::PERMISSION_STATUS_GRANTED; | |
603 case CONTENT_SETTING_BLOCK: | |
604 return content::PERMISSION_STATUS_DENIED; | |
605 case CONTENT_SETTING_ASK: | |
606 return content::PERMISSION_STATUS_ASK; | |
607 case CONTENT_SETTING_DEFAULT: | |
608 case CONTENT_SETTING_NUM_SETTINGS: | |
609 break; | |
610 } | |
611 NOTREACHED(); | |
612 return content::PERMISSION_STATUS_DENIED; | |
613 } | |
614 | |
597 } // namespace | 615 } // namespace |
598 | 616 |
599 namespace chrome { | 617 namespace chrome { |
600 | 618 |
601 ChromeContentBrowserClient::ChromeContentBrowserClient() | 619 ChromeContentBrowserClient::ChromeContentBrowserClient() |
602 : prerender_tracker_(NULL), | 620 : prerender_tracker_(NULL), |
603 weak_factory_(this) { | 621 weak_factory_(this) { |
604 #if defined(ENABLE_PLUGINS) | 622 #if defined(ENABLE_PLUGINS) |
605 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) | 623 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) |
606 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); | 624 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); |
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1966 requesting_frame.GetOrigin(), | 1984 requesting_frame.GetOrigin(), |
1967 user_gesture, | 1985 user_gesture, |
1968 result_callback); | 1986 result_callback); |
1969 break; | 1987 break; |
1970 case content::PERMISSION_NUM: | 1988 case content::PERMISSION_NUM: |
1971 NOTREACHED() << "Invalid RequestPermission for " << permission; | 1989 NOTREACHED() << "Invalid RequestPermission for " << permission; |
1972 break; | 1990 break; |
1973 } | 1991 } |
1974 } | 1992 } |
1975 | 1993 |
1994 content::PermissionStatus ChromeContentBrowserClient::GetPermissionStatus( | |
1995 content::PermissionType permission, | |
1996 content::BrowserContext* browser_context, | |
1997 const GURL& requesting_origin, | |
1998 const GURL& embedding_origin) { | |
1999 DCHECK(browser_context); | |
2000 Profile* profile = Profile::FromBrowserContext(browser_context); | |
2001 | |
2002 PermissionContextBase* context = nullptr; | |
2003 switch (permission) { | |
2004 case content::PERMISSION_MIDI_SYSEX: | |
2005 context = MidiPermissionContextFactory::GetForProfile(profile); | |
2006 break; | |
2007 case content::PERMISSION_NOTIFICATIONS: | |
2008 #if defined(ENABLE_NOTIFICATIONS) | |
2009 context = DesktopNotificationServiceFactory::GetForProfile(profile); | |
2010 #else | |
2011 NOTIMPLEMENTED(); | |
2012 #endif | |
2013 break; | |
2014 case content::PERMISSION_GEOLOCATION: | |
2015 context = GeolocationPermissionContextFactory::GetForProfile(profile); | |
2016 break; | |
2017 case content::PERMISSION_PROTECTED_MEDIA: | |
2018 NOTIMPLEMENTED(); | |
2019 break; | |
2020 case content::PERMISSION_PUSH_MESSAGING: | |
2021 context = gcm::PushMessagingPermissionContextFactory::GetForProfile( | |
2022 profile); | |
2023 break; | |
2024 case content::PERMISSION_NUM: | |
2025 NOTREACHED() << "Invalid RequestPermission for " << permission; | |
2026 break; | |
2027 } | |
2028 | |
2029 ContentSetting result = context | |
2030 ? context->GetPermissionStatus(requesting_origin.GetOrigin(), | |
Tom Sepez
2014/12/01 18:42:38
nit: ? and : prior to line break.
| |
2031 embedding_origin.GetOrigin()) | |
2032 : CONTENT_SETTING_DEFAULT; | |
2033 | |
2034 return ContentSettingToPermissionStatus(result); | |
2035 } | |
2036 | |
1976 void ChromeContentBrowserClient::CancelPermissionRequest( | 2037 void ChromeContentBrowserClient::CancelPermissionRequest( |
1977 content::PermissionType permission, | 2038 content::PermissionType permission, |
1978 content::WebContents* web_contents, | 2039 content::WebContents* web_contents, |
1979 int bridge_id, | 2040 int bridge_id, |
1980 const GURL& requesting_frame) { | 2041 const GURL& requesting_frame) { |
1981 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); | 2042 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); |
1982 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); | 2043 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
1983 | 2044 |
1984 const PermissionRequestID request_id(render_process_id, | 2045 const PermissionRequestID request_id(render_process_id, |
1985 render_view_id, | 2046 render_view_id, |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2675 switches::kDisableWebRtcEncryption, | 2736 switches::kDisableWebRtcEncryption, |
2676 }; | 2737 }; |
2677 to_command_line->CopySwitchesFrom(from_command_line, | 2738 to_command_line->CopySwitchesFrom(from_command_line, |
2678 kWebRtcDevSwitchNames, | 2739 kWebRtcDevSwitchNames, |
2679 arraysize(kWebRtcDevSwitchNames)); | 2740 arraysize(kWebRtcDevSwitchNames)); |
2680 } | 2741 } |
2681 } | 2742 } |
2682 #endif // defined(ENABLE_WEBRTC) | 2743 #endif // defined(ENABLE_WEBRTC) |
2683 | 2744 |
2684 } // namespace chrome | 2745 } // namespace chrome |
OLD | NEW |