Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / components / content_settings / core / common / permission_request_id.cc
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/content_settings/core/common/permission_request_id.h"
6
7 #include "base/strings/stringprintf.h"
8
9 PermissionRequestID::PermissionRequestID(int render_process_id,
10                                          int render_view_id,
11                                          int bridge_id,
12                                          const GURL& origin)
13     : render_process_id_(render_process_id),
14       render_view_id_(render_view_id),
15       bridge_id_(bridge_id),
16       origin_(origin) {
17 }
18
19 PermissionRequestID::~PermissionRequestID() {
20 }
21
22 bool PermissionRequestID::Equals(const PermissionRequestID& other) const {
23   return IsForSameTabAs(other) && (bridge_id_ == other.bridge_id_) &&
24          (origin_ == other.origin());
25 }
26
27 bool PermissionRequestID::IsForSameTabAs(
28     const PermissionRequestID& other) const {
29   return (render_process_id_ == other.render_process_id_) &&
30          (render_view_id_ == other.render_view_id_);
31 }
32
33 std::string PermissionRequestID::ToString() const {
34   return base::StringPrintf("%d,%d,%d,%s",
35                             render_process_id_,
36                             render_view_id_,
37                             bridge_id_,
38                             origin_.spec().c_str());
39 }