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/browser/extensions/api/declarative_content/content_action.h" | 5 #include "chrome/browser/extensions/api/declarative_content/content_action.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 master_ = | 251 master_ = |
252 ExtensionSystem::Get(profile)->GetDeclarativeUserScriptMasterByExtension( | 252 ExtensionSystem::Get(profile)->GetDeclarativeUserScriptMasterByExtension( |
253 extension->id()); | 253 extension->id()); |
254 DCHECK(master_); | 254 DCHECK(master_); |
255 master_->AddScript(script_); | 255 master_->AddScript(script_); |
256 } | 256 } |
257 | 257 |
258 void RequestContentScript::InstructRenderProcessToInject( | 258 void RequestContentScript::InstructRenderProcessToInject( |
259 content::WebContents* contents, | 259 content::WebContents* contents, |
260 const std::string& extension_id) const { | 260 const std::string& extension_id) const { |
261 // TODO(markdittmer): Send ExtensionMsg to renderer. | 261 contents->GetRenderProcessHost()->Send( |
Devlin
2014/08/21 17:06:16
Why not send this to the RenderViewHost so you don
Mark Dittmer
2014/08/23 12:21:38
Done.
| |
262 new ExtensionMsg_ExecuteDeclarativeScript( | |
263 contents->GetRenderViewHost()->GetRoutingID(), | |
264 SessionTabHelper::IdForTab(contents), | |
265 extension_id, | |
266 script_.id(), | |
267 contents->GetLastCommittedURL())); | |
262 } | 268 } |
263 | 269 |
264 struct ContentActionFactory { | 270 struct ContentActionFactory { |
265 // Factory methods for ContentAction instances. |extension| is the extension | 271 // Factory methods for ContentAction instances. |extension| is the extension |
266 // for which the action is being created. |dict| contains the json dictionary | 272 // for which the action is being created. |dict| contains the json dictionary |
267 // that describes the action. |error| is used to return error messages in case | 273 // that describes the action. |error| is used to return error messages in case |
268 // the extension passed an action that was syntactically correct but | 274 // the extension passed an action that was syntactically correct but |
269 // semantically incorrect. |bad_message| is set to true in case |dict| does | 275 // semantically incorrect. |bad_message| is set to true in case |dict| does |
270 // not confirm to the validated JSON specification. | 276 // not confirm to the validated JSON specification. |
271 typedef scoped_refptr<ContentAction>(*FactoryMethod)( | 277 typedef scoped_refptr<ContentAction>(*FactoryMethod)( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 factory_method_iter = factory.factory_methods.find(instance_type); | 327 factory_method_iter = factory.factory_methods.find(instance_type); |
322 if (factory_method_iter != factory.factory_methods.end()) | 328 if (factory_method_iter != factory.factory_methods.end()) |
323 return (*factory_method_iter->second)( | 329 return (*factory_method_iter->second)( |
324 profile, extension, action_dict, error, bad_message); | 330 profile, extension, action_dict, error, bad_message); |
325 | 331 |
326 *error = base::StringPrintf(kInvalidInstanceTypeError, instance_type.c_str()); | 332 *error = base::StringPrintf(kInvalidInstanceTypeError, instance_type.c_str()); |
327 return scoped_refptr<ContentAction>(); | 333 return scoped_refptr<ContentAction>(); |
328 } | 334 } |
329 | 335 |
330 } // namespace extensions | 336 } // namespace extensions |
OLD | NEW |