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

Unified Diff: content/browser/plugin_content_origin_whitelist.cc

Issue 680193002: Plugin Power Saver: Implement size-based heuristic for peripheral content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/plugin_content_origin_whitelist.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/plugin_content_origin_whitelist.cc
diff --git a/content/browser/plugin_content_origin_whitelist.cc b/content/browser/plugin_content_origin_whitelist.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d10e703f1170a58f0c566dd261246e5b64f208c3
--- /dev/null
+++ b/content/browser/plugin_content_origin_whitelist.cc
@@ -0,0 +1,61 @@
+// Copyright 2014 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 "content/browser/plugin_content_origin_whitelist.h"
+
+#include "content/common/frame_messages.h"
+#include "content/public/browser/navigation_details.h"
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/web_contents.h"
+
+namespace content {
+
+PluginContentOriginWhitelist::PluginContentOriginWhitelist(
+ WebContents* web_contents)
+ : WebContentsObserver(web_contents) {
+}
+
+PluginContentOriginWhitelist::~PluginContentOriginWhitelist() {
+}
+
+void PluginContentOriginWhitelist::RenderFrameCreated(
+ RenderFrameHost* render_frame_host) {
+ if (!whitelist_.empty()) {
+ Send(new FrameMsg_UpdatePluginContentOriginWhitelist(
+ render_frame_host->GetRoutingID(), whitelist_));
+ }
+}
+
+bool PluginContentOriginWhitelist::OnMessageReceived(
+ const IPC::Message& message,
+ RenderFrameHost* render_frame_host) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(PluginContentOriginWhitelist, message)
+ IPC_MESSAGE_HANDLER(FrameHostMsg_PluginContentOriginAllowed,
+ OnPluginContentOriginAllowed)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+
+ return handled;
+}
+
+void PluginContentOriginWhitelist::DidNavigateMainFrame(
+ const LoadCommittedDetails& details,
+ const FrameNavigateParams& params) {
+ if (details.is_navigation_to_different_page()) {
+ // We expect RenderFrames to clear their replicated whitelist independently.
+ whitelist_.clear();
+ }
+}
+
+void PluginContentOriginWhitelist::OnPluginContentOriginAllowed(
+ const GURL& content_origin) {
+ whitelist_.insert(content_origin);
+
+ web_contents()->SendToAllFrames(
+ new FrameMsg_UpdatePluginContentOriginWhitelist(
+ MSG_ROUTING_NONE, whitelist_));
+}
+
+} // namespace content
« no previous file with comments | « content/browser/plugin_content_origin_whitelist.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698