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

Side by Side Diff: chrome/browser/extensions/api/web_request/chrome_extra_request_params.cc

Issue 568583002: Introduce WebRequestEventRouterDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hide tab_id and window_id from extensions. Created 6 years, 3 months 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
(Empty)
1 // Copyright (c) 2014 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 "chrome/browser/extensions/api/web_request/chrome_extra_request_params. h"
6
7 #include "chrome/browser/extensions/extension_renderer_state.h"
8 #include "content/public/browser/resource_request_info.h"
9 #include "net/url_request/url_request.h"
10
11 ChromeExtraRequestParams::ChromeExtraRequestParams()
12 : tab_id_(-1), window_id_(-1) {
13 }
14
15 ChromeExtraRequestParams::ChromeExtraRequestParams(
16 const ChromeExtraRequestParams& params)
17 : tab_id_(params.tab_id()), window_id_(params.window_id()) {
18 }
19
20 ChromeExtraRequestParams::~ChromeExtraRequestParams() {
21 }
22
23 bool ChromeExtraRequestParams::OnInitFromValueCheck(
24 const base::DictionaryValue& value) {
25 for (base::DictionaryValue::Iterator it(value); !it.IsAtEnd(); it.Advance()) {
26 if (it.key() == "tabId") {
27 if (!it.value().GetAsInteger(&tab_id_))
28 return false;
29 } else if (it.key() == "windowId") {
30 if (!it.value().GetAsInteger(&window_id_))
31 return false;
32 } else {
33 return false;
34 }
35 }
36 return true;
37 }
38
39 bool ChromeExtraRequestParams::OnGetMatchingListenersImplCheck(
40 net:: URLRequest* request) const {
41 if (!request->GetUserData(NULL))
42 return false;
43
44 int tab_id = -1;
45 int window_id = -1;
46 const content::ResourceRequestInfo* info =
47 content::ResourceRequestInfo::ForRequest(request);
48 ExtensionRendererState::GetInstance()->GetTabAndWindowId(
49 info, &tab_id, &window_id);
50 return (tab_id_ != -1 && tab_id_ != tab_id) ||
51 (window_id_ != -1 && window_id_ != window_id) ? true : false;
52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698