Chromium Code Reviews| 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/public/browser/browser_thread.h" | 5 #include "content/public/browser/browser_thread.h" |
| 6 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" | 6 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" |
| 7 | 7 |
| 8 using content::BrowserThread; | 8 using content::BrowserThread; |
| 9 | 9 |
| 10 namespace extensions { | 10 namespace extensions { |
| 11 | 11 |
| 12 WebViewRendererState::WebViewInfo::WebViewInfo() { | |
| 13 } | |
| 14 | |
| 15 WebViewRendererState::WebViewInfo::~WebViewInfo() { | |
| 16 } | |
| 17 | |
| 12 // static | 18 // static |
| 13 WebViewRendererState* WebViewRendererState::GetInstance() { | 19 WebViewRendererState* WebViewRendererState::GetInstance() { |
| 14 return Singleton<WebViewRendererState>::get(); | 20 return Singleton<WebViewRendererState>::get(); |
| 15 } | 21 } |
| 16 | 22 |
| 17 WebViewRendererState::WebViewRendererState() { | 23 WebViewRendererState::WebViewRendererState() { |
| 18 } | 24 } |
| 19 | 25 |
| 20 WebViewRendererState::~WebViewRendererState() { | 26 WebViewRendererState::~WebViewRendererState() { |
| 21 } | 27 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 102 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 97 | 103 |
| 98 auto iter = web_view_partition_id_map_.find(guest_process_id); | 104 auto iter = web_view_partition_id_map_.find(guest_process_id); |
| 99 if (iter != web_view_partition_id_map_.end()){ | 105 if (iter != web_view_partition_id_map_.end()){ |
| 100 *partition_id = iter->second.partition_id; | 106 *partition_id = iter->second.partition_id; |
| 101 return true; | 107 return true; |
| 102 } | 108 } |
| 103 return false; | 109 return false; |
| 104 } | 110 } |
| 105 | 111 |
| 112 void WebViewRendererState::AddContentScriptIDs(int embedder_process_id, | |
| 113 int guest_view_instance_id, | |
| 114 std::set<int> script_ids) { | |
| 115 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 116 | |
| 117 for (auto& x : web_view_info_map_) { | |
|
Fady Samuel
2015/03/31 23:40:12
const auto& render_id_info : web_view_info_map_
Xi Han
2015/04/01 22:14:41
It cannot be const, since we insert ids to the inf
| |
| 118 WebViewInfo& info = x.second; | |
|
Fady Samuel
2015/03/31 23:40:12
const WebViewInfo&
Xi Han
2015/04/01 22:14:41
Same as above.
| |
| 119 if (info.embedder_process_id == embedder_process_id && | |
| 120 info.instance_id == guest_view_instance_id) { | |
| 121 for (int id : script_ids) { | |
| 122 info.content_script_ids.insert(id); | |
| 123 } | |
| 124 return; | |
| 125 } | |
| 126 } | |
| 127 } | |
| 128 | |
| 129 void WebViewRendererState::RemoveContentScriptIDs(int embedder_process_id, | |
| 130 int guest_view_instance_id, | |
| 131 std::set<int> script_ids) { | |
|
Fady Samuel
2015/03/31 23:40:12
const std::set<int>&
Xi Han
2015/04/01 22:14:41
Done.
| |
| 132 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 133 | |
| 134 for (auto& x : web_view_info_map_) { | |
| 135 WebViewInfo& info = x.second; | |
| 136 if (info.embedder_process_id == embedder_process_id && | |
| 137 info.instance_id == guest_view_instance_id) { | |
| 138 for (int id : script_ids) | |
| 139 info.content_script_ids.erase(id); | |
| 140 return; | |
| 141 } | |
| 142 } | |
| 143 } | |
| 144 | |
| 106 } // namespace extensions | 145 } // namespace extensions |
| OLD | NEW |