| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "extensions/browser/api/web_request/web_request_event_details.h" | 5 #include "extensions/browser/api/web_request/web_request_event_details.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 dict_.SetBoolean(keys::kFromCache, request->was_cached()); | 146 dict_.SetBoolean(keys::kFromCache, request->was_cached()); |
| 147 const std::string response_ip = request->GetSocketAddress().host(); | 147 const std::string response_ip = request->GetSocketAddress().host(); |
| 148 if (!response_ip.empty()) | 148 if (!response_ip.empty()) |
| 149 dict_.SetString(keys::kIpKey, response_ip); | 149 dict_.SetString(keys::kIpKey, response_ip); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void WebRequestEventDetails::DetermineFrameIdOnUI() { | 152 void WebRequestEventDetails::DetermineFrameIdOnUI() { |
| 153 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 153 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 154 content::RenderFrameHost* rfh = | 154 content::RenderFrameHost* rfh = |
| 155 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 155 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
| 156 int tab_id = -1; |
| 157 int window_id = -1; |
| 158 ExtensionApiFrameIdMap::GetTabAndWindowId(rfh, &tab_id, &window_id); |
| 159 |
| 160 dict_.SetInteger(keys::kTabIdKey, tab_id); |
| 156 dict_.SetInteger(keys::kFrameIdKey, ExtensionApiFrameIdMap::GetFrameId(rfh)); | 161 dict_.SetInteger(keys::kFrameIdKey, ExtensionApiFrameIdMap::GetFrameId(rfh)); |
| 157 dict_.SetInteger(keys::kParentFrameIdKey, | 162 dict_.SetInteger(keys::kParentFrameIdKey, |
| 158 ExtensionApiFrameIdMap::GetParentFrameId(rfh)); | 163 ExtensionApiFrameIdMap::GetParentFrameId(rfh)); |
| 159 } | 164 } |
| 160 | 165 |
| 161 void WebRequestEventDetails::DetermineFrameIdOnIO( | 166 void WebRequestEventDetails::DetermineFrameIdOnIO( |
| 162 const DeterminedFrameIdCallback& callback) { | 167 const DeterminedFrameIdCallback& callback) { |
| 163 std::unique_ptr<WebRequestEventDetails> self(this); | 168 std::unique_ptr<WebRequestEventDetails> self(this); |
| 164 ExtensionApiFrameIdMap::Get()->GetFrameDataOnIO( | 169 ExtensionApiFrameIdMap::Get()->GetFrameDataOnIO( |
| 165 render_process_id_, render_frame_id_, | 170 render_process_id_, render_frame_id_, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 183 WebRequestEventDetails::GetAndClearDict() { | 188 WebRequestEventDetails::GetAndClearDict() { |
| 184 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); | 189 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); |
| 185 dict_.Swap(result.get()); | 190 dict_.Swap(result.get()); |
| 186 return result; | 191 return result; |
| 187 } | 192 } |
| 188 | 193 |
| 189 void WebRequestEventDetails::OnDeterminedFrameId( | 194 void WebRequestEventDetails::OnDeterminedFrameId( |
| 190 std::unique_ptr<WebRequestEventDetails> self, | 195 std::unique_ptr<WebRequestEventDetails> self, |
| 191 const DeterminedFrameIdCallback& callback, | 196 const DeterminedFrameIdCallback& callback, |
| 192 const ExtensionApiFrameIdMap::FrameData& frame_data) { | 197 const ExtensionApiFrameIdMap::FrameData& frame_data) { |
| 198 dict_.SetInteger(keys::kTabIdKey, frame_data.tab_id); |
| 193 dict_.SetInteger(keys::kFrameIdKey, frame_data.frame_id); | 199 dict_.SetInteger(keys::kFrameIdKey, frame_data.frame_id); |
| 194 dict_.SetInteger(keys::kParentFrameIdKey, frame_data.parent_frame_id); | 200 dict_.SetInteger(keys::kParentFrameIdKey, frame_data.parent_frame_id); |
| 195 callback.Run(std::move(self)); | 201 callback.Run(std::move(self)); |
| 196 } | 202 } |
| 197 | 203 |
| 198 } // namespace extensions | 204 } // namespace extensions |
| OLD | NEW |