diff options
29 files changed, 107 insertions, 97 deletions
diff --git a/chrome/browser/chromeos/attestation/platform_verification_flow.cc b/chrome/browser/chromeos/attestation/platform_verification_flow.cc index 03170f4..cb39766 100644 --- a/chrome/browser/chromeos/attestation/platform_verification_flow.cc +++ b/chrome/browser/chromeos/attestation/platform_verification_flow.cc @@ -24,7 +24,6 @@ #include "chromeos/dbus/dbus_thread_manager.h" #include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/common/content_settings_pattern.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "components/user_manager/user.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" diff --git a/chrome/browser/content_settings/permission_bubble_request_impl.h b/chrome/browser/content_settings/permission_bubble_request_impl.h index 985c9d0..2df8111 100644 --- a/chrome/browser/content_settings/permission_bubble_request_impl.h +++ b/chrome/browser/content_settings/permission_bubble_request_impl.h @@ -6,10 +6,10 @@ #define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_BUBBLE_REQUEST_IMPL_H_ #include "base/callback.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/browser/ui/website_settings/permission_bubble_request.h" #include "components/content_settings/core/common/content_settings.h" #include "components/content_settings/core/common/content_settings_types.h" -#include "components/content_settings/core/common/permission_request_id.h" class GURL; diff --git a/chrome/browser/content_settings/permission_context_base.cc b/chrome/browser/content_settings/permission_context_base.cc index d80f3d4..8be0b7d 100644 --- a/chrome/browser/content_settings/permission_context_base.cc +++ b/chrome/browser/content_settings/permission_context_base.cc @@ -9,12 +9,12 @@ #include "chrome/browser/content_settings/permission_bubble_request_impl.h" #include "chrome/browser/content_settings/permission_context_uma_util.h" #include "chrome/browser/content_settings/permission_queue_controller.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" #include "chrome/common/pref_names.h" #include "components/content_settings/core/browser/content_settings_utils.h" #include "components/content_settings/core/browser/host_content_settings_map.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" #include "content/public/common/origin_util.h" diff --git a/chrome/browser/content_settings/permission_context_base_unittest.cc b/chrome/browser/content_settings/permission_context_base_unittest.cc index 35f361a..86b153b 100644 --- a/chrome/browser/content_settings/permission_context_base_unittest.cc +++ b/chrome/browser/content_settings/permission_context_base_unittest.cc @@ -8,6 +8,7 @@ #include "base/command_line.h" #include "chrome/browser/content_settings/permission_queue_controller.h" #include "chrome/browser/infobars/infobar_service.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" @@ -15,7 +16,6 @@ #include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/common/content_settings.h" #include "components/content_settings/core/common/content_settings_types.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "content/public/test/mock_render_process_host.h" diff --git a/chrome/browser/content_settings/permission_infobar_delegate.h b/chrome/browser/content_settings/permission_infobar_delegate.h index 2f238b8..25bb0b4 100644 --- a/chrome/browser/content_settings/permission_infobar_delegate.h +++ b/chrome/browser/content_settings/permission_infobar_delegate.h @@ -6,8 +6,8 @@ #define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_INFOBAR_DELEGATE_H_ #include "chrome/browser/infobars/infobar_service.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "components/content_settings/core/common/content_settings_types.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "components/infobars/core/confirm_infobar_delegate.h" #include "content/public/browser/web_contents.h" diff --git a/chrome/browser/content_settings/permission_queue_controller.cc b/chrome/browser/content_settings/permission_queue_controller.cc index 10cf79b..dab4a8a 100644 --- a/chrome/browser/content_settings/permission_queue_controller.cc +++ b/chrome/browser/content_settings/permission_queue_controller.cc @@ -181,7 +181,7 @@ void PermissionQueueController::CancelInfoBarRequest( for (PendingInfobarRequests::iterator i(pending_infobar_requests_.begin()); i != pending_infobar_requests_.end(); ++i) { - if (!i->id().Equals(id)) + if (id != i->id()) continue; InfoBarService* infobar_service = GetInfoBarService(id); @@ -229,7 +229,7 @@ void PermissionQueueController::OnPermissionSet( pending_requests_to_remove.push_back(i); continue; } - if (i->id().Equals(id)) { + if (id == i->id()) { // The infobar that called us is i->infobar(), and its delegate is // currently in either Accept() or Cancel(). This means that // RemoveInfoBar() will be called later on, and that will trigger a diff --git a/chrome/browser/content_settings/permission_queue_controller_unittest.cc b/chrome/browser/content_settings/permission_queue_controller_unittest.cc index d49dc2a..aae2004 100644 --- a/chrome/browser/content_settings/permission_queue_controller_unittest.cc +++ b/chrome/browser/content_settings/permission_queue_controller_unittest.cc @@ -7,10 +7,10 @@ #include "base/synchronization/waitable_event.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/infobars/infobar_service.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" #include "components/content_settings/core/common/content_settings_types.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "content/public/test/mock_render_process_host.h" diff --git a/chrome/browser/geolocation/geolocation_permission_context.cc b/chrome/browser/geolocation/geolocation_permission_context.cc index 06f0511..df90856 100644 --- a/chrome/browser/geolocation/geolocation_permission_context.cc +++ b/chrome/browser/geolocation/geolocation_permission_context.cc @@ -6,8 +6,8 @@ #include "base/bind.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/browser/profiles/profile.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/geolocation_provider.h" #include "content/public/browser/render_frame_host.h" @@ -34,7 +34,7 @@ void GeolocationPermissionContext::RequestPermission( bool permission_set; bool new_permission; if (extensions_context_.RequestPermission( - web_contents, id, id.bridge_id(), requesting_frame_origin, user_gesture, + web_contents, id, id.request_id(), requesting_frame_origin, user_gesture, callback, &permission_set, &new_permission)) { if (permission_set) { ContentSetting content_setting = @@ -60,7 +60,7 @@ void GeolocationPermissionContext::CancelPermissionRequest( const PermissionRequestID& id) { if (extensions_context_.CancelPermissionRequest( - web_contents, id.bridge_id())) + web_contents, id.request_id())) return; PermissionContextBase::CancelPermissionRequest(web_contents, id); } diff --git a/chrome/browser/geolocation/geolocation_permission_context_android.cc b/chrome/browser/geolocation/geolocation_permission_context_android.cc index 3a38c25..6b33983 100644 --- a/chrome/browser/geolocation/geolocation_permission_context_android.cc +++ b/chrome/browser/geolocation/geolocation_permission_context_android.cc @@ -6,7 +6,7 @@ #include "chrome/browser/android/location_settings.h" #include "chrome/browser/android/location_settings_impl.h" -#include "components/content_settings/core/common/permission_request_id.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "content/public/browser/web_contents.h" #include "url/gurl.h" diff --git a/chrome/browser/geolocation/geolocation_permission_context_extensions.cc b/chrome/browser/geolocation/geolocation_permission_context_extensions.cc index 15a3209..3b10998 100644 --- a/chrome/browser/geolocation/geolocation_permission_context_extensions.cc +++ b/chrome/browser/geolocation/geolocation_permission_context_extensions.cc @@ -7,8 +7,8 @@ #include "base/callback.h" #if defined(ENABLE_EXTENSIONS) +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/browser/profiles/profile.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "extensions/browser/extension_registry.h" #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" #include "extensions/browser/process_map.h" diff --git a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc index 70d13d5..3017c8a 100644 --- a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc +++ b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc @@ -20,6 +20,7 @@ #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" #include "chrome/browser/infobars/infobar_service.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/browser/ui/website_settings/mock_permission_bubble_view.h" #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" #include "chrome/browser/ui/website_settings/permission_bubble_request.h" @@ -27,7 +28,6 @@ #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" #include "components/content_settings/core/browser/host_content_settings_map.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "components/infobars/core/confirm_infobar_delegate.h" #include "components/infobars/core/infobar.h" #include "content/public/browser/browser_thread.h" @@ -116,8 +116,8 @@ class GeolocationPermissionContextTests void SetUp() override; void TearDown() override; - PermissionRequestID RequestID(int bridge_id); - PermissionRequestID RequestIDForTab(int tab, int bridge_id); + PermissionRequestID RequestID(int request_id); + PermissionRequestID RequestIDForTab(int tab, int request_id); InfoBarService* infobar_service() { return InfoBarService::FromWebContents(web_contents()); } @@ -132,10 +132,10 @@ class GeolocationPermissionContextTests void PermissionResponse(const PermissionRequestID& id, ContentSetting content_setting); - void CheckPermissionMessageSent(int bridge_id, bool allowed); - void CheckPermissionMessageSentForTab(int tab, int bridge_id, bool allowed); + void CheckPermissionMessageSent(int request_id, bool allowed); + void CheckPermissionMessageSentForTab(int tab, int request_id, bool allowed); void CheckPermissionMessageSentInternal(MockRenderProcessHost* process, - int bridge_id, + int request_id, bool allowed); void AddNewTab(const GURL& url); void CheckTabContentsState(const GURL& requesting_frame, @@ -160,21 +160,21 @@ class GeolocationPermissionContextTests }; PermissionRequestID GeolocationPermissionContextTests::RequestID( - int bridge_id) { + int request_id) { return PermissionRequestID( web_contents()->GetRenderProcessHost()->GetID(), web_contents()->GetMainFrame()->GetRoutingID(), - bridge_id, + request_id, GURL()); } PermissionRequestID GeolocationPermissionContextTests::RequestIDForTab( int tab, - int bridge_id) { + int request_id) { return PermissionRequestID( extra_tabs_[tab]->GetRenderProcessHost()->GetID(), extra_tabs_[tab]->GetMainFrame()->GetRoutingID(), - bridge_id, + request_id, GURL()); } @@ -194,30 +194,30 @@ void GeolocationPermissionContextTests::PermissionResponse( const PermissionRequestID& id, ContentSetting content_setting) { responses_[id.render_process_id()] = - std::make_pair(id.bridge_id(), content_setting == CONTENT_SETTING_ALLOW); + std::make_pair(id.request_id(), content_setting == CONTENT_SETTING_ALLOW); } void GeolocationPermissionContextTests::CheckPermissionMessageSent( - int bridge_id, + int request_id, bool allowed) { - CheckPermissionMessageSentInternal(process(), bridge_id, allowed); + CheckPermissionMessageSentInternal(process(), request_id, allowed); } void GeolocationPermissionContextTests::CheckPermissionMessageSentForTab( int tab, - int bridge_id, + int request_id, bool allowed) { CheckPermissionMessageSentInternal(static_cast<MockRenderProcessHost*>( extra_tabs_[tab]->GetRenderProcessHost()), - bridge_id, allowed); + request_id, allowed); } void GeolocationPermissionContextTests::CheckPermissionMessageSentInternal( MockRenderProcessHost* process, - int bridge_id, + int request_id, bool allowed) { ASSERT_EQ(responses_.count(process->GetID()), 1U); - EXPECT_EQ(bridge_id, responses_[process->GetID()].first); + EXPECT_EQ(request_id, responses_[process->GetID()].first); EXPECT_EQ(allowed, responses_[process->GetID()].second); responses_.erase(process->GetID()); } diff --git a/chrome/browser/guest_view/web_view/chrome_web_view_permission_helper_delegate.cc b/chrome/browser/guest_view/web_view/chrome_web_view_permission_helper_delegate.cc index 94a8ae6..b48c13f 100644 --- a/chrome/browser/guest_view/web_view/chrome_web_view_permission_helper_delegate.cc +++ b/chrome/browser/guest_view/web_view/chrome_web_view_permission_helper_delegate.cc @@ -7,11 +7,11 @@ #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/geolocation/geolocation_permission_context.h" #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/browser/plugins/chrome_plugin_service_filter.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/render_messages.h" #include "components/content_settings/content/common/content_settings_messages.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" diff --git a/chrome/browser/media/midi_permission_context.cc b/chrome/browser/media/midi_permission_context.cc index 7d2b2e0..d2162e7 100644 --- a/chrome/browser/media/midi_permission_context.cc +++ b/chrome/browser/media/midi_permission_context.cc @@ -5,7 +5,7 @@ #include "chrome/browser/media/midi_permission_context.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" -#include "components/content_settings/core/common/permission_request_id.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "content/public/browser/child_process_security_policy.h" #include "url/gurl.h" diff --git a/chrome/browser/media/midi_permission_context_unittest.cc b/chrome/browser/media/midi_permission_context_unittest.cc index c908198..3a33b35 100644 --- a/chrome/browser/media/midi_permission_context_unittest.cc +++ b/chrome/browser/media/midi_permission_context_unittest.cc @@ -7,13 +7,13 @@ #include "base/bind.h" #include "chrome/browser/content_settings/permission_queue_controller.h" #include "chrome/browser/infobars/infobar_service.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" #include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/common/content_settings.h" #include "components/content_settings/core/common/content_settings_types.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "content/public/browser/web_contents.h" #include "content/public/test/mock_render_process_host.h" #include "content/public/test/web_contents_tester.h" diff --git a/chrome/browser/media/protected_media_identifier_infobar_delegate.cc b/chrome/browser/media/protected_media_identifier_infobar_delegate.cc index c155968..ae1637d 100644 --- a/chrome/browser/media/protected_media_identifier_infobar_delegate.cc +++ b/chrome/browser/media/protected_media_identifier_infobar_delegate.cc @@ -6,6 +6,7 @@ #include "chrome/browser/content_settings/permission_queue_controller.h" #include "chrome/browser/infobars/infobar_service.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/common/url_constants.h" #include "chrome/grit/generated_resources.h" #include "components/infobars/core/infobar.h" diff --git a/chrome/browser/media/protected_media_identifier_infobar_delegate.h b/chrome/browser/media/protected_media_identifier_infobar_delegate.h index 1681da8..4d1459d 100644 --- a/chrome/browser/media/protected_media_identifier_infobar_delegate.h +++ b/chrome/browser/media/protected_media_identifier_infobar_delegate.h @@ -7,7 +7,7 @@ #include <string> -#include "components/content_settings/core/common/permission_request_id.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "components/infobars/core/confirm_infobar_delegate.h" #include "url/gurl.h" diff --git a/chrome/browser/media/protected_media_identifier_permission_context.cc b/chrome/browser/media/protected_media_identifier_permission_context.cc index ba3b064..b419eb9 100644 --- a/chrome/browser/media/protected_media_identifier_permission_context.cc +++ b/chrome/browser/media/protected_media_identifier_permission_context.cc @@ -9,7 +9,6 @@ #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents.h" @@ -139,7 +138,7 @@ void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( #if defined(OS_CHROMEOS) PendingRequestMap::iterator request = pending_requests_.find(web_contents); - if (request == pending_requests_.end() || !request->second.second.Equals(id)) + if (request == pending_requests_.end() || (request->second.second != id)) return; views::Widget* widget = request->second.first; @@ -227,7 +226,7 @@ void ProtectedMediaIdentifierPermissionContext:: if (request == pending_requests_.end()) return; - DCHECK(request->second.second.Equals(id)); + DCHECK(request->second.second == id); pending_requests_.erase(request); ContentSetting content_setting = CONTENT_SETTING_ASK; diff --git a/chrome/browser/media/protected_media_identifier_permission_context.h b/chrome/browser/media/protected_media_identifier_permission_context.h index f18f521..42d4004 100644 --- a/chrome/browser/media/protected_media_identifier_permission_context.h +++ b/chrome/browser/media/protected_media_identifier_permission_context.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_ #include "chrome/browser/content_settings/permission_context_base.h" -#include "components/content_settings/core/common/permission_request_id.h" +#include "chrome/browser/permissions/permission_request_id.h" #if defined(OS_CHROMEOS) #include <map> diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index 8ef6cc9..78e9b9e 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -14,10 +14,10 @@ #include "chrome/browser/notifications/notification.h" #include "chrome/browser/notifications/notification_object_proxy.h" #include "chrome/browser/notifications/notification_ui_manager.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/pref_names.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "components/pref_registry/pref_registry_syncable.h" #include "content/public/browser/browser_thread.h" #include "ui/base/webui/web_ui_util.h" diff --git a/chrome/browser/permissions/permission_manager.cc b/chrome/browser/permissions/permission_manager.cc index 858f5b2..e96e68e 100644 --- a/chrome/browser/permissions/permission_manager.cc +++ b/chrome/browser/permissions/permission_manager.cc @@ -7,9 +7,9 @@ #include "base/callback.h" #include "chrome/browser/content_settings/permission_context_base.h" #include "chrome/browser/permissions/permission_context.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/browser/profiles/profile.h" #include "components/content_settings/core/browser/host_content_settings_map.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "content/public/browser/permission_type.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" diff --git a/components/content_settings/core/common/permission_request_id.cc b/chrome/browser/permissions/permission_request_id.cc index 7d7eccb..c78bb10 100644 --- a/components/content_settings/core/common/permission_request_id.cc +++ b/chrome/browser/permissions/permission_request_id.cc @@ -1,35 +1,39 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/content_settings/core/common/permission_request_id.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "base/strings/stringprintf.h" PermissionRequestID::PermissionRequestID(int render_process_id, int render_frame_id, - int bridge_id, + int request_id, const GURL& origin) : render_process_id_(render_process_id), render_frame_id_(render_frame_id), - bridge_id_(bridge_id), + request_id_(request_id), origin_(origin) { } PermissionRequestID::~PermissionRequestID() { } -bool PermissionRequestID::Equals(const PermissionRequestID& other) const { +bool PermissionRequestID::operator==(const PermissionRequestID& other) const { return render_process_id_ == other.render_process_id_ && render_frame_id_ == other.render_frame_id_ && - bridge_id_ == other.bridge_id_ && + request_id_ == other.request_id_ && origin_ == other.origin_; } +bool PermissionRequestID::operator!=(const PermissionRequestID& other) const { + return !operator==(other); +} + std::string PermissionRequestID::ToString() const { return base::StringPrintf("%d,%d,%d,%s", render_process_id_, render_frame_id_, - bridge_id_, + request_id_, origin_.spec().c_str()); } diff --git a/chrome/browser/permissions/permission_request_id.h b/chrome/browser/permissions/permission_request_id.h new file mode 100644 index 0000000..4b567a7 --- /dev/null +++ b/chrome/browser/permissions/permission_request_id.h @@ -0,0 +1,48 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_ID_H_ +#define CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_ID_H_ + +#include <string> + +#include "url/gurl.h" + +// Uniquely identifies a particular permission request. +// None of the different attribute (render_process_id, render_frame_id, +// request_id or origin) is enough to compare two requests. In order to check if +// a request is the same as another one, consumers of this class should use +// the operator== or operator!=. +class PermissionRequestID { + public: + PermissionRequestID(int render_process_id, + int render_frame_id, + int request_id, + const GURL& origin); + ~PermissionRequestID(); + + PermissionRequestID(const PermissionRequestID&) = default; + PermissionRequestID& operator=(const PermissionRequestID&) = default; + + int render_process_id() const { return render_process_id_; } + int render_frame_id() const { return render_frame_id_; } + int request_id() const { return request_id_; } + GURL origin() const { return origin_; } + + bool operator==(const PermissionRequestID& other) const; + bool operator!=(const PermissionRequestID& other) const; + + std::string ToString() const; + + private: + int render_process_id_; + int render_frame_id_; + int request_id_; + + // Needed for permission checks that are based on origin. It can be an empty + // GURL is the request isn't checking origin. + GURL origin_; +}; + +#endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_ID_H_ diff --git a/chrome/browser/push_messaging/push_messaging_permission_context.cc b/chrome/browser/push_messaging/push_messaging_permission_context.cc index 9a7530f..d29f5c3 100644 --- a/chrome/browser/push_messaging/push_messaging_permission_context.cc +++ b/chrome/browser/push_messaging/push_messaging_permission_context.cc @@ -7,9 +7,9 @@ #include "chrome/browser/content_settings/permission_context_uma_util.h" #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/notifications/desktop_notification_service_factory.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/browser/profiles/profile.h" #include "components/content_settings/core/browser/host_content_settings_map.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_delegate.h" diff --git a/chrome/browser/push_messaging/push_messaging_permission_context_unittest.cc b/chrome/browser/push_messaging/push_messaging_permission_context_unittest.cc index 57e9372..8c351c2 100644 --- a/chrome/browser/push_messaging/push_messaging_permission_context_unittest.cc +++ b/chrome/browser/push_messaging/push_messaging_permission_context_unittest.cc @@ -3,11 +3,12 @@ // found in the LICENSE file. #include "chrome/browser/push_messaging/push_messaging_permission_context.h" + +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/test/base/testing_profile.h" #include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/common/content_settings.h" #include "components/content_settings/core/common/content_settings_types.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/push_messaging/push_messaging_service_impl.cc b/chrome/browser/push_messaging/push_messaging_service_impl.cc index bf03560..2844864 100644 --- a/chrome/browser/push_messaging/push_messaging_service_impl.cc +++ b/chrome/browser/push_messaging/push_messaging_service_impl.cc @@ -14,6 +14,7 @@ #include "base/metrics/histogram.h" #include "base/prefs/pref_service.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/permissions/permission_request_id.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" #include "chrome/browser/push_messaging/push_messaging_constants.h" @@ -25,7 +26,6 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "components/content_settings/core/browser/host_content_settings_map.h" -#include "components/content_settings/core/common/permission_request_id.h" #include "components/gcm_driver/gcm_driver.h" #include "components/pref_registry/pref_registry_syncable.h" #include "components/rappor/rappor_utils.h" @@ -349,9 +349,10 @@ void PushMessagingServiceImpl::SubscribeFromDocument( // TODO(miguelg) need to send this over IPC when bubble support is // implemented. - int bridge_id = -1; + int request_id = -1; - const PermissionRequestID id(renderer_id, render_frame_id, bridge_id, GURL()); + const PermissionRequestID id( + renderer_id, render_frame_id, request_id, GURL()); PushMessagingPermissionContext* permission_context = PushMessagingPermissionContextFactory::GetForProfile(profile_); diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 7541dc4..97645e8 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2036,6 +2036,8 @@ 'browser/permissions/permission_manager.h', 'browser/permissions/permission_manager_factory.cc', 'browser/permissions/permission_manager_factory.h', + 'browser/permissions/permission_request_id.cc', + 'browser/permissions/permission_request_id.h', ], # See also the plugin_installation_sources list below. 'chrome_browser_plugins_sources': [ diff --git a/components/content_settings.gypi b/components/content_settings.gypi index d0218fe..984b454 100644 --- a/components/content_settings.gypi +++ b/components/content_settings.gypi @@ -81,8 +81,6 @@ 'content_settings/core/common/content_settings_pattern_parser.cc', 'content_settings/core/common/content_settings_pattern_parser.h', 'content_settings/core/common/content_settings_types.h', - 'content_settings/core/common/permission_request_id.cc', - 'content_settings/core/common/permission_request_id.h', 'content_settings/core/common/pref_names.cc', 'content_settings/core/common/pref_names.h', ], diff --git a/components/content_settings/core/common/BUILD.gn b/components/content_settings/core/common/BUILD.gn index 3784bc6..0570be8 100644 --- a/components/content_settings/core/common/BUILD.gn +++ b/components/content_settings/core/common/BUILD.gn @@ -11,8 +11,6 @@ static_library("common") { "content_settings_pattern_parser.cc", "content_settings_pattern_parser.h", "content_settings_types.h", - "permission_request_id.cc", - "permission_request_id.h", "pref_names.cc", "pref_names.h", ] diff --git a/components/content_settings/core/common/permission_request_id.h b/components/content_settings/core/common/permission_request_id.h deleted file mode 100644 index 6b798d4..0000000 --- a/components/content_settings/core/common/permission_request_id.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_PERMISSION_REQUEST_ID_H_ -#define COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_PERMISSION_REQUEST_ID_H_ - -#include <string> - -#include "url/gurl.h" - -// Uniquely identifies a particular permission request. -class PermissionRequestID { - public: - PermissionRequestID(int render_process_id, - int render_frame_id, - int bridge_id, - const GURL& origin); - ~PermissionRequestID(); - - int render_process_id() const { return render_process_id_; } - int render_frame_id() const { return render_frame_id_; } - int bridge_id() const { return bridge_id_; } - GURL origin() const { return origin_; } - - bool Equals(const PermissionRequestID& other) const; - std::string ToString() const; - - private: - int render_process_id_; - int render_frame_id_; - // Id unique to this instance. - int bridge_id_; - // Needed for permission checks that are based on origin. - // If you don't use origin to check permission request, pass an empty GURL. - GURL origin_; - - // Purposefully do not disable copying, as this is stored in STL containers. -}; - -#endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_PERMISSION_REQUEST_ID_H_ |