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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // Implementation of ContentAction: | 63 // Implementation of ContentAction: |
64 virtual Type GetType() const OVERRIDE { return ACTION_SHOW_PAGE_ACTION; } | 64 virtual Type GetType() const OVERRIDE { return ACTION_SHOW_PAGE_ACTION; } |
65 virtual void Apply(const std::string& extension_id, | 65 virtual void Apply(const std::string& extension_id, |
66 const base::Time& extension_install_time, | 66 const base::Time& extension_install_time, |
67 ApplyInfo* apply_info) const OVERRIDE { | 67 ApplyInfo* apply_info) const OVERRIDE { |
68 ExtensionAction* action = GetPageAction(apply_info->profile, extension_id); | 68 ExtensionAction* action = GetPageAction(apply_info->profile, extension_id); |
69 action->DeclarativeShow(ExtensionTabUtil::GetTabId(apply_info->tab)); | 69 action->DeclarativeShow(ExtensionTabUtil::GetTabId(apply_info->tab)); |
70 ExtensionActionAPI::Get(apply_info->profile)->NotifyChange( | 70 ExtensionActionAPI::Get(apply_info->profile)->NotifyChange( |
71 action, apply_info->tab, apply_info->profile); | 71 action, apply_info->tab, apply_info->profile); |
72 } | 72 } |
| 73 // The page action is already showing, so nothing needs to be done here. |
| 74 virtual void Reapply(const std::string& extension_id, |
| 75 const base::Time& extension_install_time, |
| 76 ApplyInfo* apply_info) const OVERRIDE {} |
73 virtual void Revert(const std::string& extension_id, | 77 virtual void Revert(const std::string& extension_id, |
74 const base::Time& extension_install_time, | 78 const base::Time& extension_install_time, |
75 ApplyInfo* apply_info) const OVERRIDE { | 79 ApplyInfo* apply_info) const OVERRIDE { |
76 if (ExtensionAction* action = | 80 if (ExtensionAction* action = |
77 GetPageAction(apply_info->profile, extension_id)) { | 81 GetPageAction(apply_info->profile, extension_id)) { |
78 action->UndoDeclarativeShow(ExtensionTabUtil::GetTabId(apply_info->tab)); | 82 action->UndoDeclarativeShow(ExtensionTabUtil::GetTabId(apply_info->tab)); |
79 ExtensionActionAPI::Get(apply_info->profile)->NotifyChange( | 83 ExtensionActionAPI::Get(apply_info->profile)->NotifyChange( |
80 action, apply_info->tab, apply_info->profile); | 84 action, apply_info->tab, apply_info->profile); |
81 } | 85 } |
82 } | 86 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 return ACTION_REQUEST_CONTENT_SCRIPT; | 122 return ACTION_REQUEST_CONTENT_SCRIPT; |
119 } | 123 } |
120 | 124 |
121 virtual void Apply(const std::string& extension_id, | 125 virtual void Apply(const std::string& extension_id, |
122 const base::Time& extension_install_time, | 126 const base::Time& extension_install_time, |
123 ApplyInfo* apply_info) const OVERRIDE { | 127 ApplyInfo* apply_info) const OVERRIDE { |
124 // TODO(markdittmer): Invoke UserScriptMaster declarative script loader: | 128 // TODO(markdittmer): Invoke UserScriptMaster declarative script loader: |
125 // load new user script. | 129 // load new user script. |
126 } | 130 } |
127 | 131 |
| 132 virtual void Reapply(const std::string& extension_id, |
| 133 const base::Time& extension_install_time, |
| 134 ApplyInfo* apply_info) const OVERRIDE { |
| 135 // TODO(markdittmer): Invoke UserScriptMaster declarative script loader: |
| 136 // load new user script. |
| 137 } |
| 138 |
128 virtual void Revert(const std::string& extension_id, | 139 virtual void Revert(const std::string& extension_id, |
129 const base::Time& extension_install_time, | 140 const base::Time& extension_install_time, |
130 ApplyInfo* apply_info) const OVERRIDE { | 141 ApplyInfo* apply_info) const OVERRIDE { |
131 // TODO(markdittmer): Invoke UserScriptMaster declarative script loader: | 142 // TODO(markdittmer): Invoke UserScriptMaster declarative script loader: |
132 // do not load user script if Apply() runs again on the same page. | 143 // do not load user script if Apply() runs again on the same page. |
133 } | 144 } |
134 | 145 |
135 private: | 146 private: |
136 virtual ~RequestContentScript() {} | 147 virtual ~RequestContentScript() {} |
137 | 148 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 factory_method_iter = factory.factory_methods.find(instance_type); | 267 factory_method_iter = factory.factory_methods.find(instance_type); |
257 if (factory_method_iter != factory.factory_methods.end()) | 268 if (factory_method_iter != factory.factory_methods.end()) |
258 return (*factory_method_iter->second)( | 269 return (*factory_method_iter->second)( |
259 extension, action_dict, error, bad_message); | 270 extension, action_dict, error, bad_message); |
260 | 271 |
261 *error = base::StringPrintf(kInvalidInstanceTypeError, instance_type.c_str()); | 272 *error = base::StringPrintf(kInvalidInstanceTypeError, instance_type.c_str()); |
262 return scoped_refptr<ContentAction>(); | 273 return scoped_refptr<ContentAction>(); |
263 } | 274 } |
264 | 275 |
265 } // namespace extensions | 276 } // namespace extensions |
OLD | NEW |