Chromium Code Reviews| 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" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/extensions/api/declarative_content/content_constants.h" | 12 #include "chrome/browser/extensions/api/declarative_content/content_constants.h" |
| 13 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 13 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 14 #include "chrome/browser/extensions/extension_action.h" | 14 #include "chrome/browser/extensions/extension_action.h" |
| 15 #include "chrome/browser/extensions/extension_action_manager.h" | 15 #include "chrome/browser/extensions/extension_action_manager.h" |
| 16 #include "chrome/browser/extensions/extension_tab_util.h" | 16 #include "chrome/browser/extensions/extension_tab_util.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/sessions/session_tab_helper.h" | |
| 19 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" | |
|
Devlin
2014/08/26 21:59:15
Do we use this?
Mark Dittmer
2014/08/27 22:37:04
We do not. Removed.
| |
| 18 #include "content/public/browser/invalidate_type.h" | 20 #include "content/public/browser/invalidate_type.h" |
| 21 #include "content/public/browser/render_view_host.h" | |
| 19 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 20 #include "extensions/browser/extension_registry.h" | 23 #include "extensions/browser/extension_registry.h" |
| 21 #include "extensions/browser/extension_system.h" | 24 #include "extensions/browser/extension_system.h" |
| 22 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
| 26 #include "extensions/common/extension_messages.h" | |
| 23 | 27 |
| 24 namespace extensions { | 28 namespace extensions { |
| 25 | 29 |
| 26 namespace keys = declarative_content_constants; | 30 namespace keys = declarative_content_constants; |
| 27 | 31 |
| 28 namespace { | 32 namespace { |
| 29 // Error messages. | 33 // Error messages. |
| 30 const char kInvalidInstanceTypeError[] = | 34 const char kInvalidInstanceTypeError[] = |
| 31 "An action has an invalid instanceType: %s"; | 35 "An action has an invalid instanceType: %s"; |
| 32 const char kNoPageAction[] = | 36 const char kNoPageAction[] = |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 } | 299 } |
| 296 } | 300 } |
| 297 | 301 |
| 298 ContentAction::Type RequestContentScript::GetType() const { | 302 ContentAction::Type RequestContentScript::GetType() const { |
| 299 return ACTION_REQUEST_CONTENT_SCRIPT; | 303 return ACTION_REQUEST_CONTENT_SCRIPT; |
| 300 } | 304 } |
| 301 | 305 |
| 302 void RequestContentScript::Apply(const std::string& extension_id, | 306 void RequestContentScript::Apply(const std::string& extension_id, |
| 303 const base::Time& extension_install_time, | 307 const base::Time& extension_install_time, |
| 304 ApplyInfo* apply_info) const { | 308 ApplyInfo* apply_info) const { |
| 305 InstructRenderProcessToInject(apply_info->tab, extension_id); | 309 InstructRenderProcessToInject(apply_info->tab, extension_id); |
| 306 } | 310 } |
| 307 | 311 |
| 308 void RequestContentScript::Reapply(const std::string& extension_id, | 312 void RequestContentScript::Reapply(const std::string& extension_id, |
| 309 const base::Time& extension_install_time, | 313 const base::Time& extension_install_time, |
| 310 ApplyInfo* apply_info) const { | 314 ApplyInfo* apply_info) const { |
| 311 InstructRenderProcessToInject(apply_info->tab, extension_id); | 315 InstructRenderProcessToInject(apply_info->tab, extension_id); |
| 312 } | 316 } |
| 313 | 317 |
| 314 void RequestContentScript::Revert(const std::string& extension_id, | 318 void RequestContentScript::Revert(const std::string& extension_id, |
| 315 const base::Time& extension_install_time, | 319 const base::Time& extension_install_time, |
| 316 ApplyInfo* apply_info) const {} | 320 ApplyInfo* apply_info) const {} |
| 317 | 321 |
| 318 void RequestContentScript::InstructRenderProcessToInject( | 322 void RequestContentScript::InstructRenderProcessToInject( |
| 319 content::WebContents* contents, | 323 content::WebContents* contents, |
| 320 const std::string& extension_id) const { | 324 const std::string& extension_id) const { |
| 321 // TODO(markdittmer): Send ExtensionMsg to renderer. | 325 content::RenderViewHost* render_view_host = contents->GetRenderViewHost(); |
| 326 render_view_host->Send(new ExtensionMsg_ExecuteDeclarativeScript( | |
| 327 render_view_host->GetRoutingID(), | |
| 328 SessionTabHelper::IdForTab(contents), | |
| 329 extension_id, | |
| 330 script_.id(), | |
| 331 contents->GetLastCommittedURL())); | |
| 322 } | 332 } |
| 323 | 333 |
| 324 // | 334 // |
| 325 // ContentAction | 335 // ContentAction |
| 326 // | 336 // |
| 327 | 337 |
| 328 ContentAction::ContentAction() {} | 338 ContentAction::ContentAction() {} |
| 329 | 339 |
| 330 ContentAction::~ContentAction() {} | 340 ContentAction::~ContentAction() {} |
| 331 | 341 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 358 bool* bad_message, | 368 bool* bad_message, |
| 359 const base::DictionaryValue** action_dict, | 369 const base::DictionaryValue** action_dict, |
| 360 std::string* instance_type) { | 370 std::string* instance_type) { |
| 361 INPUT_FORMAT_VALIDATE(json_action.GetAsDictionary(action_dict)); | 371 INPUT_FORMAT_VALIDATE(json_action.GetAsDictionary(action_dict)); |
| 362 INPUT_FORMAT_VALIDATE( | 372 INPUT_FORMAT_VALIDATE( |
| 363 (*action_dict)->GetString(keys::kInstanceType, instance_type)); | 373 (*action_dict)->GetString(keys::kInstanceType, instance_type)); |
| 364 return true; | 374 return true; |
| 365 } | 375 } |
| 366 | 376 |
| 367 } // namespace extensions | 377 } // namespace extensions |
| OLD | NEW |