summaryrefslogtreecommitdiffstats
path: root/chrome/browser/privacy_blacklist
diff options
context:
space:
mode:
authoridanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 16:52:59 +0000
committeridanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 16:52:59 +0000
commit3d40d3e4f87c891c285fed5bbe5091c71d8e8be5 (patch)
treeacf3d40269dae2bcae1d0b6827a4d3871c866b7a /chrome/browser/privacy_blacklist
parent1ca56e93029ed5763ac06e1e21c4ab7d4ab20c45 (diff)
downloadchromium_src-3d40d3e4f87c891c285fed5bbe5091c71d8e8be5.zip
chromium_src-3d40d3e4f87c891c285fed5bbe5091c71d8e8be5.tar.gz
chromium_src-3d40d3e4f87c891c285fed5bbe5091c71d8e8be5.tar.bz2
Blocked Resource Responses
Added resources used for replacing HTML elements when they are blocked. These were modeled after the malware response page. BUG=16932 TEST=none Review URL: http://codereview.chromium.org/164158 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23036 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/privacy_blacklist')
-rw-r--r--chrome/browser/privacy_blacklist/blocked_response.cc53
-rw-r--r--chrome/browser/privacy_blacklist/blocked_response.h29
2 files changed, 82 insertions, 0 deletions
diff --git a/chrome/browser/privacy_blacklist/blocked_response.cc b/chrome/browser/privacy_blacklist/blocked_response.cc
new file mode 100644
index 0000000..aacb344
--- /dev/null
+++ b/chrome/browser/privacy_blacklist/blocked_response.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2009 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 "chrome/browser/privacy_blacklist/blocked_response.h"
+
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "base/logging.h"
+#include "base/values.h"
+#include "chrome/browser/privacy_blacklist/blacklist.h"
+#include "chrome/common/jstemplate_builder.h"
+#include "grit/browser_resources.h"
+#include "grit/generated_resources.h"
+
+namespace BlockedResponse {
+
+std::string GetHTML(const Blacklist::Match* match) {
+ DictionaryValue strings;
+ strings.SetString(L"title", l10n_util::GetString(IDS_BLACKLIST_TITLE));
+ strings.SetString(L"message", l10n_util::GetString(IDS_BLACKLIST_MESSAGE));
+ strings.SetString(L"unblock", l10n_util::GetString(IDS_BLACKLIST_UNBLOCK));
+
+ // If kBlockAll is specified, assign blame to such an entry.
+ // Otherwise pick the first one.
+ const Blacklist::Entry* entry = NULL;
+ if (match->attributes() & Blacklist::kBlockAll) {
+ for (std::vector<const Blacklist::Entry*>::const_iterator i =
+ match->entries().begin(); i != match->entries().end(); ++i) {
+ if ((*i)->attributes() == Blacklist::kBlockAll) {
+ entry = *i;
+ break;
+ }
+ }
+ } else {
+ entry = match->entries().front();
+ }
+ DCHECK(entry);
+
+ strings.SetString(L"name", entry->provider()->name());
+ strings.SetString(L"url", entry->provider()->url());
+
+ const StringPiece html =
+ ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_BLACKLIST_HTML);
+ return jstemplate_builder::GetI18nTemplateHtml(html, &strings);
+}
+
+std::string GetImage(const Blacklist::Match*) {
+ return ResourceBundle::GetSharedInstance().
+ GetDataResource(IDR_BLACKLIST_IMAGE);
+}
+
+} // namespace BlockedResponse
diff --git a/chrome/browser/privacy_blacklist/blocked_response.h b/chrome/browser/privacy_blacklist/blocked_response.h
new file mode 100644
index 0000000..1a770e4
--- /dev/null
+++ b/chrome/browser/privacy_blacklist/blocked_response.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2009 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_PRIVACY_BLACKLIST_BLOCKED_RESPONSE_H_
+#define CHROME_BROWSER_PRIVACY_BLACKLIST_BLOCKED_RESPONSE_H_
+
+#include <string>
+
+#include "chrome/browser/privacy_blacklist/blacklist.h"
+
+// Generate localized responses to replace blacklisted resources.
+// Blacklisted resources such as frames and iframes are replaced
+// by HTML. Non visual resources such as Javascript and CSS are
+// simply be cancelled so there is no blocked response for them.
+
+namespace BlockedResponse {
+
+// Returns the HTML document used as substituted content for blacklisted
+// elements.
+std::string GetHTML(const Blacklist::Match* match);
+
+// Returns the image (as a string because that is what is expected by callers)
+// used as substituted content for blacklisted elements.
+std::string GetImage(const Blacklist::Match* match);
+
+} // namespace BlockedResponse
+
+#endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLOCKED_RESPONSE_H_