| OLD | NEW |
| 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/renderer/extensions/chrome_v8_context_set.h" | 5 #include "chrome/renderer/extensions/chrome_v8_context_set.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/tracked_objects.h" | 9 #include "base/tracked_objects.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 return calling.IsEmpty() ? NULL : GetByV8Context(calling); | 69 return calling.IsEmpty() ? NULL : GetByV8Context(calling); |
| 70 } | 70 } |
| 71 | 71 |
| 72 ChromeV8Context* ChromeV8ContextSet::GetByV8Context( | 72 ChromeV8Context* ChromeV8ContextSet::GetByV8Context( |
| 73 v8::Handle<v8::Context> v8_context) const { | 73 v8::Handle<v8::Context> v8_context) const { |
| 74 for (ContextSet::const_iterator iter = contexts_.begin(); | 74 for (ContextSet::const_iterator iter = contexts_.begin(); |
| 75 iter != contexts_.end(); ++iter) { | 75 iter != contexts_.end(); ++iter) { |
| 76 if ((*iter)->v8_context() == v8_context) | 76 if ((*iter)->v8_context() == v8_context) |
| 77 return *iter; | 77 return *iter; |
| 78 } | 78 } |
| 79 | |
| 80 return NULL; | 79 return NULL; |
| 81 } | 80 } |
| 82 | 81 |
| 82 ChromeV8Context* ChromeV8ContextSet::GetByWebFrame( |
| 83 WebKit::WebFrame* web_frame) const { |
| 84 for (ContextSet::const_iterator iter = contexts_.begin(); |
| 85 iter != contexts_.end(); ++iter) { |
| 86 if ((*iter)->web_frame() == web_frame) |
| 87 return *iter; |
| 88 } |
| 89 return NULL; |
| 90 } |
| 91 |
| 83 void ChromeV8ContextSet::ForEach( | 92 void ChromeV8ContextSet::ForEach( |
| 84 const std::string& extension_id, | 93 const std::string& extension_id, |
| 85 content::RenderView* render_view, | 94 content::RenderView* render_view, |
| 86 const base::Callback<void(ChromeV8Context*)>& callback) const { | 95 const base::Callback<void(ChromeV8Context*)>& callback) const { |
| 87 // We copy the context list, because calling into javascript may modify it | 96 // We copy the context list, because calling into javascript may modify it |
| 88 // out from under us. | 97 // out from under us. |
| 89 ContextSet contexts = GetAll(); | 98 ContextSet contexts = GetAll(); |
| 90 | 99 |
| 91 for (ContextSet::iterator it = contexts.begin(); it != contexts.end(); | 100 for (ContextSet::iterator it = contexts.begin(); it != contexts.end(); |
| 92 ++it) { | 101 ++it) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 (*it)->DispatchOnUnloadEvent(); | 136 (*it)->DispatchOnUnloadEvent(); |
| 128 removed.insert(*it); | 137 removed.insert(*it); |
| 129 Remove(*it); | 138 Remove(*it); |
| 130 } | 139 } |
| 131 } | 140 } |
| 132 | 141 |
| 133 return removed; | 142 return removed; |
| 134 } | 143 } |
| 135 | 144 |
| 136 } // namespace extensions | 145 } // namespace extensions |
| OLD | NEW |