Chromium Code Reviews| 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 | |
| 598 ContentSettingToPermissionStatus(ContentSetting setting) { | |
| 599 switch (setting) { | |
| 600 case CONTENT_SETTING_ALLOW: | |
| 601 return content::PERMISSION_STATUS_GRANTED; | |
|
mlamouri (slow - plz ping)
2014/11/24 19:06:01
nit: CONTENT_SETTING_SESSION_ONLY should also link
timvolodine
2014/11/27 17:53:42
Done.
| |
| 602 case CONTENT_SETTING_BLOCK: | |
| 603 return content::PERMISSION_STATUS_DENIED; | |
| 604 case CONTENT_SETTING_ASK: | |
| 605 return content::PERMISSION_STATUS_ASK; | |
| 606 default: | |
| 607 return content::PERMISSION_STATUS_ASK; | |
|
mlamouri (slow - plz ping)
2014/11/24 19:06:01
I think it would be better to not have a |default|
timvolodine
2014/11/27 17:53:42
Done.
| |
| 608 } | |
| 609 } | |
| 610 | |
| 597 } // namespace | 611 } // namespace |
| 598 | 612 |
| 599 namespace chrome { | 613 namespace chrome { |
| 600 | 614 |
| 601 ChromeContentBrowserClient::ChromeContentBrowserClient() | 615 ChromeContentBrowserClient::ChromeContentBrowserClient() |
| 602 : prerender_tracker_(NULL), | 616 : prerender_tracker_(NULL), |
| 603 weak_factory_(this) { | 617 weak_factory_(this) { |
| 604 #if defined(ENABLE_PLUGINS) | 618 #if defined(ENABLE_PLUGINS) |
| 605 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) | 619 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) |
| 606 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); | 620 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); |
| (...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1964 requesting_frame.GetOrigin(), | 1978 requesting_frame.GetOrigin(), |
| 1965 user_gesture, | 1979 user_gesture, |
| 1966 result_callback); | 1980 result_callback); |
| 1967 break; | 1981 break; |
| 1968 case content::PERMISSION_NUM: | 1982 case content::PERMISSION_NUM: |
| 1969 NOTREACHED() << "Invalid RequestPermission for " << permission; | 1983 NOTREACHED() << "Invalid RequestPermission for " << permission; |
| 1970 break; | 1984 break; |
| 1971 } | 1985 } |
| 1972 } | 1986 } |
| 1973 | 1987 |
| 1988 void ChromeContentBrowserClient::HasPermission( | |
| 1989 content::PermissionType permission, | |
| 1990 content::BrowserContext* browser_context, | |
| 1991 const GURL& requesting_origin, | |
| 1992 const GURL& embedding_origin, | |
| 1993 const content::PermissionStatusCallback& result_callback) { | |
| 1994 DCHECK(browser_context); | |
| 1995 Profile* profile = Profile::FromBrowserContext(browser_context); | |
| 1996 | |
| 1997 PermissionContextBase* context = nullptr; | |
| 1998 switch (permission) { | |
| 1999 case content::PERMISSION_MIDI_SYSEX: | |
| 2000 context = MidiPermissionContextFactory::GetForProfile(profile); | |
| 2001 break; | |
| 2002 case content::PERMISSION_NOTIFICATIONS: | |
| 2003 #if defined(ENABLE_NOTIFICATIONS) | |
| 2004 context = DesktopNotificationServiceFactory::GetForProfile(profile); | |
| 2005 #else | |
| 2006 NOTIMPLEMENTED(); | |
| 2007 #endif | |
| 2008 break; | |
| 2009 case content::PERMISSION_GEOLOCATION: | |
| 2010 context = GeolocationPermissionContextFactory::GetForProfile(profile); | |
| 2011 break; | |
| 2012 case content::PERMISSION_PROTECTED_MEDIA: | |
| 2013 NOTIMPLEMENTED(); | |
| 2014 break; | |
| 2015 case content::PERMISSION_PUSH_MESSAGING: | |
| 2016 context = gcm::PushMessagingPermissionContextFactory::GetForProfile( | |
| 2017 profile); | |
| 2018 break; | |
| 2019 case content::PERMISSION_NUM: | |
| 2020 NOTREACHED() << "Invalid RequestPermission for " << permission; | |
| 2021 break; | |
| 2022 } | |
| 2023 | |
| 2024 ContentSetting result = context | |
| 2025 ? context->GetPermissionStatus(requesting_origin.GetOrigin(), | |
| 2026 embedding_origin.GetOrigin()) | |
| 2027 : CONTENT_SETTING_DEFAULT; | |
| 2028 | |
| 2029 result_callback.Run(ContentSettingToPermissionStatus(result)); | |
|
mlamouri (slow - plz ping)
2014/11/24 19:06:01
Why do you use a callback instead of returning dir
timvolodine
2014/11/27 17:53:42
Done.
| |
| 2030 } | |
| 2031 | |
| 1974 void ChromeContentBrowserClient::CancelPermissionRequest( | 2032 void ChromeContentBrowserClient::CancelPermissionRequest( |
| 1975 content::PermissionType permission, | 2033 content::PermissionType permission, |
| 1976 content::WebContents* web_contents, | 2034 content::WebContents* web_contents, |
| 1977 int bridge_id, | 2035 int bridge_id, |
| 1978 const GURL& requesting_frame) { | 2036 const GURL& requesting_frame) { |
| 1979 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); | 2037 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); |
| 1980 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); | 2038 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
| 1981 | 2039 |
| 1982 const PermissionRequestID request_id(render_process_id, | 2040 const PermissionRequestID request_id(render_process_id, |
| 1983 render_view_id, | 2041 render_view_id, |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2673 switches::kDisableWebRtcEncryption, | 2731 switches::kDisableWebRtcEncryption, |
| 2674 }; | 2732 }; |
| 2675 to_command_line->CopySwitchesFrom(from_command_line, | 2733 to_command_line->CopySwitchesFrom(from_command_line, |
| 2676 kWebRtcDevSwitchNames, | 2734 kWebRtcDevSwitchNames, |
| 2677 arraysize(kWebRtcDevSwitchNames)); | 2735 arraysize(kWebRtcDevSwitchNames)); |
| 2678 } | 2736 } |
| 2679 } | 2737 } |
| 2680 #endif // defined(ENABLE_WEBRTC) | 2738 #endif // defined(ENABLE_WEBRTC) |
| 2681 | 2739 |
| 2682 } // namespace chrome | 2740 } // namespace chrome |
| OLD | NEW |