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

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

Issue 792173002: 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 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 requesting_frame.GetOrigin(), 1971 requesting_frame.GetOrigin(),
1990 user_gesture, 1972 user_gesture,
1991 result_callback); 1973 result_callback);
1992 break; 1974 break;
1993 case content::PERMISSION_NUM: 1975 case content::PERMISSION_NUM:
1994 NOTREACHED() << "Invalid RequestPermission for " << permission; 1976 NOTREACHED() << "Invalid RequestPermission for " << permission;
1995 break; 1977 break;
1996 } 1978 }
1997 } 1979 }
1998 1980
1999 content::PermissionStatus ChromeContentBrowserClient::GetPermissionStatus(
2000 content::PermissionType permission,
2001 content::BrowserContext* browser_context,
2002 const GURL& requesting_origin,
2003 const GURL& embedding_origin) {
2004 DCHECK(browser_context);
2005 Profile* profile = Profile::FromBrowserContext(browser_context);
2006
2007 PermissionContextBase* context = nullptr;
2008 switch (permission) {
2009 case content::PERMISSION_MIDI_SYSEX:
2010 context = MidiPermissionContextFactory::GetForProfile(profile);
2011 break;
2012 case content::PERMISSION_NOTIFICATIONS:
2013 #if defined(ENABLE_NOTIFICATIONS)
2014 context = DesktopNotificationServiceFactory::GetForProfile(profile);
2015 #else
2016 NOTIMPLEMENTED();
2017 #endif
2018 break;
2019 case content::PERMISSION_GEOLOCATION:
2020 context = GeolocationPermissionContextFactory::GetForProfile(profile);
2021 break;
2022 case content::PERMISSION_PROTECTED_MEDIA:
2023 NOTIMPLEMENTED();
2024 break;
2025 case content::PERMISSION_PUSH_MESSAGING:
2026 context = gcm::PushMessagingPermissionContextFactory::GetForProfile(
2027 profile);
2028 break;
2029 case content::PERMISSION_NUM:
2030 NOTREACHED() << "Invalid RequestPermission for " << permission;
2031 break;
2032 }
2033
2034 ContentSetting result = context
2035 ? context->GetPermissionStatus(requesting_origin.GetOrigin(),
2036 embedding_origin.GetOrigin())
2037 : CONTENT_SETTING_DEFAULT;
2038
2039 return ContentSettingToPermissionStatus(result);
2040 }
2041
2042 void ChromeContentBrowserClient::CancelPermissionRequest( 1981 void ChromeContentBrowserClient::CancelPermissionRequest(
2043 content::PermissionType permission, 1982 content::PermissionType permission,
2044 content::WebContents* web_contents, 1983 content::WebContents* web_contents,
2045 int bridge_id, 1984 int bridge_id,
2046 const GURL& requesting_frame) { 1985 const GURL& requesting_frame) {
2047 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); 1986 int render_process_id = web_contents->GetRenderProcessHost()->GetID();
2048 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); 1987 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
2049 1988
2050 const PermissionRequestID request_id(render_process_id, 1989 const PermissionRequestID request_id(render_process_id,
2051 render_view_id, 1990 render_view_id,
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
2673 switches::kDisableWebRtcEncryption, 2612 switches::kDisableWebRtcEncryption,
2674 }; 2613 };
2675 to_command_line->CopySwitchesFrom(from_command_line, 2614 to_command_line->CopySwitchesFrom(from_command_line,
2676 kWebRtcDevSwitchNames, 2615 kWebRtcDevSwitchNames,
2677 arraysize(kWebRtcDevSwitchNames)); 2616 arraysize(kWebRtcDevSwitchNames));
2678 } 2617 }
2679 } 2618 }
2680 #endif // defined(ENABLE_WEBRTC) 2619 #endif // defined(ENABLE_WEBRTC)
2681 2620
2682 } // namespace chrome 2621 } // 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