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

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

Issue 10649003: Move each permission classes to its own files in extensions/permissions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase on HEAD Created 8 years, 6 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
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/extensions/api/web_request/web_request_api.h" 5 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "grit/generated_resources.h" 44 #include "grit/generated_resources.h"
45 #include "net/base/auth.h" 45 #include "net/base/auth.h"
46 #include "net/base/net_errors.h" 46 #include "net/base/net_errors.h"
47 #include "net/http/http_response_headers.h" 47 #include "net/http/http_response_headers.h"
48 #include "net/url_request/url_request.h" 48 #include "net/url_request/url_request.h"
49 #include "ui/base/l10n/l10n_util.h" 49 #include "ui/base/l10n/l10n_util.h"
50 50
51 using content::BrowserMessageFilter; 51 using content::BrowserMessageFilter;
52 using content::BrowserThread; 52 using content::BrowserThread;
53 using content::ResourceRequestInfo; 53 using content::ResourceRequestInfo;
54 using extensions::APIPermission;
54 using extensions::Extension; 55 using extensions::Extension;
55 56
56 namespace helpers = extension_web_request_api_helpers; 57 namespace helpers = extension_web_request_api_helpers;
57 namespace keys = extension_web_request_api_constants; 58 namespace keys = extension_web_request_api_constants;
58 59
59 namespace { 60 namespace {
60 61
61 // List of all the webRequest events. 62 // List of all the webRequest events.
62 static const char* const kWebRequestEvents[] = { 63 static const char* const kWebRequestEvents[] = {
63 keys::kOnBeforeRedirect, 64 keys::kOnBeforeRedirect,
(...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 extension_info_map()->extensions().GetByID(extension_id()); 1569 extension_info_map()->extensions().GetByID(extension_id());
1569 std::string extension_name = extension ? extension->name() : extension_id(); 1570 std::string extension_name = extension ? extension->name() : extension_id();
1570 1571
1571 // We check automatically whether the extension has the 'webRequest' 1572 // We check automatically whether the extension has the 'webRequest'
1572 // permission. For blocking calls we require the additional permission 1573 // permission. For blocking calls we require the additional permission
1573 // 'webRequestBlocking'. 1574 // 'webRequestBlocking'.
1574 if ((extra_info_spec & 1575 if ((extra_info_spec &
1575 (ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING | 1576 (ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING |
1576 ExtensionWebRequestEventRouter::ExtraInfoSpec::ASYNC_BLOCKING)) && 1577 ExtensionWebRequestEventRouter::ExtraInfoSpec::ASYNC_BLOCKING)) &&
1577 !extension->HasAPIPermission( 1578 !extension->HasAPIPermission(
1578 ExtensionAPIPermission::kWebRequestBlocking)) { 1579 APIPermission::kWebRequestBlocking)) {
1579 error_ = keys::kBlockingPermissionRequired; 1580 error_ = keys::kBlockingPermissionRequired;
1580 return false; 1581 return false;
1581 } 1582 }
1582 1583
1583 // We allow to subscribe to patterns that are broader than the host 1584 // We allow to subscribe to patterns that are broader than the host
1584 // permissions. E.g., we could subscribe to http://www.example.com/* 1585 // permissions. E.g., we could subscribe to http://www.example.com/*
1585 // while having host permissions for http://www.example.com/foo/* and 1586 // while having host permissions for http://www.example.com/foo/* and
1586 // http://www.example.com/bar/*. 1587 // http://www.example.com/bar/*.
1587 // For this reason we do only a coarse check here to warn the extension 1588 // For this reason we do only a coarse check here to warn the extension
1588 // developer if he does something obviously wrong. 1589 // developer if he does something obviously wrong.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 } else if ((*it)->name().find("AdBlock") != std::string::npos) { 1770 } else if ((*it)->name().find("AdBlock") != std::string::npos) {
1770 adblock = true; 1771 adblock = true;
1771 } else { 1772 } else {
1772 other = true; 1773 other = true;
1773 } 1774 }
1774 } 1775 }
1775 } 1776 }
1776 1777
1777 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); 1778 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other));
1778 } 1779 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698