| 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 "extensions/renderer/extension_helper.h" | 5 #include "extensions/renderer/extension_helper.h" | 
| 6 | 6 | 
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" | 
| 8 #include "content/public/renderer/render_view.h" | 8 #include "content/public/renderer/render_view.h" | 
| 9 #include "content/public/renderer/render_view_visitor.h" | 9 #include "content/public/renderer/render_view_visitor.h" | 
| 10 #include "extensions/common/api/messaging/message.h" | 10 #include "extensions/common/api/messaging/message.h" | 
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 151                         OnExtensionDispatchOnDisconnect) | 151                         OnExtensionDispatchOnDisconnect) | 
| 152     IPC_MESSAGE_HANDLER(ExtensionMsg_ExecuteCode, OnExecuteCode) | 152     IPC_MESSAGE_HANDLER(ExtensionMsg_ExecuteCode, OnExecuteCode) | 
| 153     IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabId, OnSetTabId) | 153     IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabId, OnSetTabId) | 
| 154     IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateBrowserWindowId, | 154     IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateBrowserWindowId, | 
| 155                         OnUpdateBrowserWindowId) | 155                         OnUpdateBrowserWindowId) | 
| 156     IPC_MESSAGE_HANDLER(ExtensionMsg_NotifyRenderViewType, | 156     IPC_MESSAGE_HANDLER(ExtensionMsg_NotifyRenderViewType, | 
| 157                         OnNotifyRendererViewType) | 157                         OnNotifyRendererViewType) | 
| 158     IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole, | 158     IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole, | 
| 159                         OnAddMessageToConsole) | 159                         OnAddMessageToConsole) | 
| 160     IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed, | 160     IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed, | 
| 161                         OnAppWindowClosed); | 161                         OnAppWindowClosed) | 
|  | 162     IPC_MESSAGE_HANDLER(ExtensionMsg_GrantContentScriptPermission, | 
|  | 163                         OnGrantContentScriptPermission) | 
| 162     IPC_MESSAGE_UNHANDLED(handled = false) | 164     IPC_MESSAGE_UNHANDLED(handled = false) | 
| 163   IPC_END_MESSAGE_MAP() | 165   IPC_END_MESSAGE_MAP() | 
| 164   return handled; | 166   return handled; | 
| 165 } | 167 } | 
| 166 | 168 | 
| 167 void ExtensionHelper::DidFinishDocumentLoad(WebLocalFrame* frame) { | 169 void ExtensionHelper::DidFinishDocumentLoad(WebLocalFrame* frame) { | 
| 168   dispatcher_->user_script_slave()->InjectScripts( | 170   dispatcher_->user_script_slave()->InjectScripts( | 
| 169       frame, UserScript::DOCUMENT_END); | 171       frame, UserScript::DOCUMENT_END); | 
| 170 | 172 | 
| 171   SchedulerMap::iterator i = g_schedulers.Get().find(frame); | 173   SchedulerMap::iterator i = g_schedulers.Get().find(frame); | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 210 | 212 | 
| 211 void ExtensionHelper::FrameDetached(WebFrame* frame) { | 213 void ExtensionHelper::FrameDetached(WebFrame* frame) { | 
| 212   // This could be called before DidCreateDataSource, in which case the frame | 214   // This could be called before DidCreateDataSource, in which case the frame | 
| 213   // won't be in the map. | 215   // won't be in the map. | 
| 214   SchedulerMap::iterator i = g_schedulers.Get().find(frame); | 216   SchedulerMap::iterator i = g_schedulers.Get().find(frame); | 
| 215   if (i == g_schedulers.Get().end()) | 217   if (i == g_schedulers.Get().end()) | 
| 216     return; | 218     return; | 
| 217 | 219 | 
| 218   delete i->second; | 220   delete i->second; | 
| 219   g_schedulers.Get().erase(i); | 221   g_schedulers.Get().erase(i); | 
|  | 222 | 
|  | 223   dispatcher_->user_script_slave()->FrameDetached(frame); | 
| 220 } | 224 } | 
| 221 | 225 | 
| 222 void ExtensionHelper::DidMatchCSS( | 226 void ExtensionHelper::DidMatchCSS( | 
| 223     blink::WebLocalFrame* frame, | 227     blink::WebLocalFrame* frame, | 
| 224     const blink::WebVector<blink::WebString>& newly_matching_selectors, | 228     const blink::WebVector<blink::WebString>& newly_matching_selectors, | 
| 225     const blink::WebVector<blink::WebString>& stopped_matching_selectors) { | 229     const blink::WebVector<blink::WebString>& stopped_matching_selectors) { | 
| 226   dispatcher_->DidMatchCSS( | 230   dispatcher_->DidMatchCSS( | 
| 227       frame, newly_matching_selectors, stopped_matching_selectors); | 231       frame, newly_matching_selectors, stopped_matching_selectors); | 
| 228 } | 232 } | 
| 229 | 233 | 
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 339   v8::Handle<v8::Context> v8_context = | 343   v8::Handle<v8::Context> v8_context = | 
| 340       render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); | 344       render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); | 
| 341   ScriptContext* script_context = | 345   ScriptContext* script_context = | 
| 342       dispatcher_->script_context_set().GetByV8Context(v8_context); | 346       dispatcher_->script_context_set().GetByV8Context(v8_context); | 
| 343   if (!script_context) | 347   if (!script_context) | 
| 344     return; | 348     return; | 
| 345   script_context->module_system()->CallModuleMethod("app.window", | 349   script_context->module_system()->CallModuleMethod("app.window", | 
| 346                                                     "onAppWindowClosed"); | 350                                                     "onAppWindowClosed"); | 
| 347 } | 351 } | 
| 348 | 352 | 
|  | 353 void ExtensionHelper::OnGrantContentScriptPermission(int request_id) { | 
|  | 354   dispatcher_->user_script_slave()->OnContentScriptGrantedPermission( | 
|  | 355       render_view(), request_id); | 
|  | 356 } | 
|  | 357 | 
| 349 }  // namespace extensions | 358 }  // namespace extensions | 
| OLD | NEW | 
|---|