OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/pepper/plugin_power_saver_helper.h" | 5 #include "content/renderer/pepper/plugin_power_saver_helper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 bool PluginPowerSaverHelper::OnMessageReceived(const IPC::Message& message) { | 59 bool PluginPowerSaverHelper::OnMessageReceived(const IPC::Message& message) { |
60 bool handled = true; | 60 bool handled = true; |
61 IPC_BEGIN_MESSAGE_MAP(PluginPowerSaverHelper, message) | 61 IPC_BEGIN_MESSAGE_MAP(PluginPowerSaverHelper, message) |
62 IPC_MESSAGE_HANDLER(FrameMsg_UpdatePluginContentOriginWhitelist, | 62 IPC_MESSAGE_HANDLER(FrameMsg_UpdatePluginContentOriginWhitelist, |
63 OnUpdatePluginContentOriginWhitelist) | 63 OnUpdatePluginContentOriginWhitelist) |
64 IPC_MESSAGE_UNHANDLED(handled = false) | 64 IPC_MESSAGE_UNHANDLED(handled = false) |
65 IPC_END_MESSAGE_MAP() | 65 IPC_END_MESSAGE_MAP() |
66 return handled; | 66 return handled; |
67 } | 67 } |
68 | 68 |
| 69 void PluginPowerSaverHelper::OnDestruct() { |
| 70 delete this; |
| 71 } |
| 72 |
69 void PluginPowerSaverHelper::OnUpdatePluginContentOriginWhitelist( | 73 void PluginPowerSaverHelper::OnUpdatePluginContentOriginWhitelist( |
70 const std::set<url::Origin>& origin_whitelist) { | 74 const std::set<url::Origin>& origin_whitelist) { |
71 origin_whitelist_ = origin_whitelist; | 75 origin_whitelist_ = origin_whitelist; |
72 | 76 |
73 // Check throttled plugin instances to see if any can be unthrottled. | 77 // Check throttled plugin instances to see if any can be unthrottled. |
74 auto it = peripheral_plugins_.begin(); | 78 auto it = peripheral_plugins_.begin(); |
75 while (it != peripheral_plugins_.end()) { | 79 while (it != peripheral_plugins_.end()) { |
76 if (origin_whitelist.count(it->content_origin)) { | 80 if (origin_whitelist.count(it->content_origin)) { |
77 // Because the unthrottle callback may register another peripheral plugin | 81 // Because the unthrottle callback may register another peripheral plugin |
78 // and invalidate our iterator, we cannot run it synchronously. | 82 // and invalidate our iterator, we cannot run it synchronously. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 122 |
119 void PluginPowerSaverHelper::WhitelistContentOrigin( | 123 void PluginPowerSaverHelper::WhitelistContentOrigin( |
120 const url::Origin& content_origin) { | 124 const url::Origin& content_origin) { |
121 if (origin_whitelist_.insert(content_origin).second) { | 125 if (origin_whitelist_.insert(content_origin).second) { |
122 Send(new FrameHostMsg_PluginContentOriginAllowed( | 126 Send(new FrameHostMsg_PluginContentOriginAllowed( |
123 render_frame()->GetRoutingID(), content_origin)); | 127 render_frame()->GetRoutingID(), content_origin)); |
124 } | 128 } |
125 } | 129 } |
126 | 130 |
127 } // namespace content | 131 } // namespace content |
OLD | NEW |