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

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

Issue 786063002: Revert of Implement HasPermission() method in PermissionService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | content/browser/permissions/OWNERS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 593
594 rules->script_rules.push_back( 594 rules->script_rules.push_back(
595 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), 595 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(),
596 ContentSettingsPattern::Wildcard(), 596 ContentSettingsPattern::Wildcard(),
597 CONTENT_SETTING_ALLOW, 597 CONTENT_SETTING_ALLOW,
598 std::string(), 598 std::string(),
599 incognito)); 599 incognito));
600 } 600 }
601 #endif // defined(ENALBE_EXTENSIONS) 601 #endif // defined(ENALBE_EXTENSIONS)
602 602
603 content::PermissionStatus
604 ContentSettingToPermissionStatus(ContentSetting setting) {
605 switch (setting) {
606 case CONTENT_SETTING_ALLOW:
607 case CONTENT_SETTING_SESSION_ONLY:
608 return content::PERMISSION_STATUS_GRANTED;
609 case CONTENT_SETTING_BLOCK:
610 return content::PERMISSION_STATUS_DENIED;
611 case CONTENT_SETTING_ASK:
612 return content::PERMISSION_STATUS_ASK;
613 case CONTENT_SETTING_DEFAULT:
614 case CONTENT_SETTING_NUM_SETTINGS:
615 break;
616 }
617 NOTREACHED();
618 return content::PERMISSION_STATUS_DENIED;
619 }
620
621 } // namespace 603 } // namespace
622 604
623 namespace chrome { 605 namespace chrome {
624 606
625 ChromeContentBrowserClient::ChromeContentBrowserClient() 607 ChromeContentBrowserClient::ChromeContentBrowserClient()
626 : prerender_tracker_(NULL), 608 : prerender_tracker_(NULL),
627 weak_factory_(this) { 609 weak_factory_(this) {
628 #if defined(ENABLE_PLUGINS) 610 #if defined(ENABLE_PLUGINS)
629 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) 611 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i)
630 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); 612 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]);
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1991 requesting_frame.GetOrigin(), 1973 requesting_frame.GetOrigin(),
1992 user_gesture, 1974 user_gesture,
1993 result_callback); 1975 result_callback);
1994 break; 1976 break;
1995 case content::PERMISSION_NUM: 1977 case content::PERMISSION_NUM:
1996 NOTREACHED() << "Invalid RequestPermission for " << permission; 1978 NOTREACHED() << "Invalid RequestPermission for " << permission;
1997 break; 1979 break;
1998 } 1980 }
1999 } 1981 }
2000 1982
2001 content::PermissionStatus ChromeContentBrowserClient::GetPermissionStatus(
2002 content::PermissionType permission,
2003 content::BrowserContext* browser_context,
2004 const GURL& requesting_origin,
2005 const GURL& embedding_origin) {
2006 DCHECK(browser_context);
2007 Profile* profile = Profile::FromBrowserContext(browser_context);
2008
2009 PermissionContextBase* context = nullptr;
2010 switch (permission) {
2011 case content::PERMISSION_MIDI_SYSEX:
2012 context = MidiPermissionContextFactory::GetForProfile(profile);
2013 break;
2014 case content::PERMISSION_NOTIFICATIONS:
2015 #if defined(ENABLE_NOTIFICATIONS)
2016 context = DesktopNotificationServiceFactory::GetForProfile(profile);
2017 #else
2018 NOTIMPLEMENTED();
2019 #endif
2020 break;
2021 case content::PERMISSION_GEOLOCATION:
2022 context = GeolocationPermissionContextFactory::GetForProfile(profile);
2023 break;
2024 case content::PERMISSION_PROTECTED_MEDIA:
2025 NOTIMPLEMENTED();
2026 break;
2027 case content::PERMISSION_PUSH_MESSAGING:
2028 context = gcm::PushMessagingPermissionContextFactory::GetForProfile(
2029 profile);
2030 break;
2031 case content::PERMISSION_NUM:
2032 NOTREACHED() << "Invalid RequestPermission for " << permission;
2033 break;
2034 }
2035
2036 ContentSetting result = context
2037 ? context->GetPermissionStatus(requesting_origin.GetOrigin(),
2038 embedding_origin.GetOrigin())
2039 : CONTENT_SETTING_DEFAULT;
2040
2041 return ContentSettingToPermissionStatus(result);
2042 }
2043
2044 void ChromeContentBrowserClient::CancelPermissionRequest( 1983 void ChromeContentBrowserClient::CancelPermissionRequest(
2045 content::PermissionType permission, 1984 content::PermissionType permission,
2046 content::WebContents* web_contents, 1985 content::WebContents* web_contents,
2047 int bridge_id, 1986 int bridge_id,
2048 const GURL& requesting_frame) { 1987 const GURL& requesting_frame) {
2049 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); 1988 int render_process_id = web_contents->GetRenderProcessHost()->GetID();
2050 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); 1989 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
2051 1990
2052 const PermissionRequestID request_id(render_process_id, 1991 const PermissionRequestID request_id(render_process_id,
2053 render_view_id, 1992 render_view_id,
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
2675 switches::kDisableWebRtcEncryption, 2614 switches::kDisableWebRtcEncryption,
2676 }; 2615 };
2677 to_command_line->CopySwitchesFrom(from_command_line, 2616 to_command_line->CopySwitchesFrom(from_command_line,
2678 kWebRtcDevSwitchNames, 2617 kWebRtcDevSwitchNames,
2679 arraysize(kWebRtcDevSwitchNames)); 2618 arraysize(kWebRtcDevSwitchNames));
2680 } 2619 }
2681 } 2620 }
2682 #endif // defined(ENABLE_WEBRTC) 2621 #endif // defined(ENABLE_WEBRTC)
2683 2622
2684 } // namespace chrome 2623 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | content/browser/permissions/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698