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

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

Issue 750633003: Implement HasPermission() method in PermissionService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add dependencies to content_app, content_child and content_ppapi_plugin 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
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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 592
593 rules->script_rules.push_back( 593 rules->script_rules.push_back(
594 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), 594 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(),
595 ContentSettingsPattern::Wildcard(), 595 ContentSettingsPattern::Wildcard(),
596 CONTENT_SETTING_ALLOW, 596 CONTENT_SETTING_ALLOW,
597 std::string(), 597 std::string(),
598 incognito)); 598 incognito));
599 } 599 }
600 #endif // defined(ENALBE_EXTENSIONS) 600 #endif // defined(ENALBE_EXTENSIONS)
601 601
602 content::PermissionStatus
603 ContentSettingToPermissionStatus(ContentSetting setting) {
604 switch (setting) {
605 case CONTENT_SETTING_ALLOW:
606 case CONTENT_SETTING_SESSION_ONLY:
607 return content::PERMISSION_STATUS_GRANTED;
608 case CONTENT_SETTING_BLOCK:
609 return content::PERMISSION_STATUS_DENIED;
610 case CONTENT_SETTING_ASK:
611 return content::PERMISSION_STATUS_ASK;
612 case CONTENT_SETTING_DEFAULT:
613 case CONTENT_SETTING_NUM_SETTINGS:
614 break;
615 }
616 NOTREACHED();
617 return content::PERMISSION_STATUS_DENIED;
618 }
619
602 } // namespace 620 } // namespace
603 621
604 namespace chrome { 622 namespace chrome {
605 623
606 ChromeContentBrowserClient::ChromeContentBrowserClient() 624 ChromeContentBrowserClient::ChromeContentBrowserClient()
607 : prerender_tracker_(NULL), 625 : prerender_tracker_(NULL),
608 weak_factory_(this) { 626 weak_factory_(this) {
609 #if defined(ENABLE_PLUGINS) 627 #if defined(ENABLE_PLUGINS)
610 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) 628 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i)
611 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); 629 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]);
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 requesting_frame.GetOrigin(), 1928 requesting_frame.GetOrigin(),
1911 user_gesture, 1929 user_gesture,
1912 result_callback); 1930 result_callback);
1913 break; 1931 break;
1914 case content::PERMISSION_NUM: 1932 case content::PERMISSION_NUM:
1915 NOTREACHED() << "Invalid RequestPermission for " << permission; 1933 NOTREACHED() << "Invalid RequestPermission for " << permission;
1916 break; 1934 break;
1917 } 1935 }
1918 } 1936 }
1919 1937
1938 content::PermissionStatus ChromeContentBrowserClient::GetPermissionStatus(
1939 content::PermissionType permission,
1940 content::BrowserContext* browser_context,
1941 const GURL& requesting_origin,
1942 const GURL& embedding_origin) {
1943 DCHECK(browser_context);
1944 Profile* profile = Profile::FromBrowserContext(browser_context);
1945
1946 PermissionContextBase* context = nullptr;
1947 switch (permission) {
1948 case content::PERMISSION_MIDI_SYSEX:
1949 context = MidiPermissionContextFactory::GetForProfile(profile);
1950 break;
1951 case content::PERMISSION_NOTIFICATIONS:
1952 #if defined(ENABLE_NOTIFICATIONS)
1953 context = DesktopNotificationServiceFactory::GetForProfile(profile);
1954 #else
1955 NOTIMPLEMENTED();
1956 #endif
1957 break;
1958 case content::PERMISSION_GEOLOCATION:
1959 context = GeolocationPermissionContextFactory::GetForProfile(profile);
1960 break;
1961 case content::PERMISSION_PROTECTED_MEDIA:
1962 NOTIMPLEMENTED();
1963 break;
1964 case content::PERMISSION_PUSH_MESSAGING:
1965 context = gcm::PushMessagingPermissionContextFactory::GetForProfile(
1966 profile);
1967 break;
1968 case content::PERMISSION_NUM:
1969 NOTREACHED() << "Invalid RequestPermission for " << permission;
1970 break;
1971 }
1972
1973 ContentSetting result = context
1974 ? context->GetPermissionStatus(requesting_origin.GetOrigin(),
1975 embedding_origin.GetOrigin())
1976 : CONTENT_SETTING_DEFAULT;
1977
1978 return ContentSettingToPermissionStatus(result);
1979 }
1980
1920 void ChromeContentBrowserClient::CancelPermissionRequest( 1981 void ChromeContentBrowserClient::CancelPermissionRequest(
1921 content::PermissionType permission, 1982 content::PermissionType permission,
1922 content::WebContents* web_contents, 1983 content::WebContents* web_contents,
1923 int bridge_id, 1984 int bridge_id,
1924 const GURL& requesting_frame) { 1985 const GURL& requesting_frame) {
1925 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); 1986 int render_process_id = web_contents->GetRenderProcessHost()->GetID();
1926 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); 1987 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
1927 1988
1928 const PermissionRequestID request_id(render_process_id, 1989 const PermissionRequestID request_id(render_process_id,
1929 render_view_id, 1990 render_view_id,
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
2551 switches::kDisableWebRtcEncryption, 2612 switches::kDisableWebRtcEncryption,
2552 }; 2613 };
2553 to_command_line->CopySwitchesFrom(from_command_line, 2614 to_command_line->CopySwitchesFrom(from_command_line,
2554 kWebRtcDevSwitchNames, 2615 kWebRtcDevSwitchNames,
2555 arraysize(kWebRtcDevSwitchNames)); 2616 arraysize(kWebRtcDevSwitchNames));
2556 } 2617 }
2557 } 2618 }
2558 #endif // defined(ENABLE_WEBRTC) 2619 #endif // defined(ENABLE_WEBRTC)
2559 2620
2560 } // namespace chrome 2621 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698