Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/extensions/api/declarative_content/content_action.cc

Issue 491913003: Add Reapply() to declarative action interface. This is needed for RequestContentScript to work corr… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 virtual void Revert(const std::string& extension_id, 73 virtual void Revert(const std::string& extension_id,
74 const base::Time& extension_install_time, 74 const base::Time& extension_install_time,
75 ApplyInfo* apply_info) const OVERRIDE { 75 ApplyInfo* apply_info) const OVERRIDE {
76 if (ExtensionAction* action = 76 if (ExtensionAction* action =
77 GetPageAction(apply_info->profile, extension_id)) { 77 GetPageAction(apply_info->profile, extension_id)) {
78 action->UndoDeclarativeShow(ExtensionTabUtil::GetTabId(apply_info->tab)); 78 action->UndoDeclarativeShow(ExtensionTabUtil::GetTabId(apply_info->tab));
79 ExtensionActionAPI::Get(apply_info->profile)->NotifyChange( 79 ExtensionActionAPI::Get(apply_info->profile)->NotifyChange(
80 action, apply_info->tab); 80 action, apply_info->tab);
81 } 81 }
82 } 82 }
83 virtual void Reapply(const std::string& extension_id,
not at google - send to devlin 2014/08/21 00:32:56 Ditto, and add comment like, // The page action i
Mark Dittmer 2014/08/21 01:08:48 Done.
84 const base::Time& extension_install_time,
85 ApplyInfo* apply_info) const OVERRIDE {}
83 86
84 private: 87 private:
85 static ExtensionAction* GetPageAction(Profile* profile, 88 static ExtensionAction* GetPageAction(Profile* profile,
86 const std::string& extension_id) { 89 const std::string& extension_id) {
87 const Extension* extension = 90 const Extension* extension =
88 ExtensionRegistry::Get(profile) 91 ExtensionRegistry::Get(profile)
89 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); 92 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING);
90 if (!extension) 93 if (!extension)
91 return NULL; 94 return NULL;
92 return ExtensionActionManager::Get(profile)->GetPageAction(*extension); 95 return ExtensionActionManager::Get(profile)->GetPageAction(*extension);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // load new user script. 128 // load new user script.
126 } 129 }
127 130
128 virtual void Revert(const std::string& extension_id, 131 virtual void Revert(const std::string& extension_id,
129 const base::Time& extension_install_time, 132 const base::Time& extension_install_time,
130 ApplyInfo* apply_info) const OVERRIDE { 133 ApplyInfo* apply_info) const OVERRIDE {
131 // TODO(markdittmer): Invoke UserScriptMaster declarative script loader: 134 // TODO(markdittmer): Invoke UserScriptMaster declarative script loader:
132 // do not load user script if Apply() runs again on the same page. 135 // do not load user script if Apply() runs again on the same page.
133 } 136 }
134 137
138 virtual void Reapply(const std::string& extension_id,
not at google - send to devlin 2014/08/21 00:32:56 Ditto (ordering).
Mark Dittmer 2014/08/21 01:08:48 Done.
139 const base::Time& extension_install_time,
140 ApplyInfo* apply_info) const OVERRIDE {
141 // TODO(markdittmer): Invoke UserScriptMaster declarative script loader:
142 // load new user script.
143 }
144
135 private: 145 private:
136 virtual ~RequestContentScript() {} 146 virtual ~RequestContentScript() {}
137 147
138 std::vector<std::string> css_file_names_; 148 std::vector<std::string> css_file_names_;
139 std::vector<std::string> js_file_names_; 149 std::vector<std::string> js_file_names_;
140 bool all_frames_; 150 bool all_frames_;
141 bool match_about_blank_; 151 bool match_about_blank_;
142 152
143 DISALLOW_COPY_AND_ASSIGN(RequestContentScript); 153 DISALLOW_COPY_AND_ASSIGN(RequestContentScript);
144 }; 154 };
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 factory_method_iter = factory.factory_methods.find(instance_type); 266 factory_method_iter = factory.factory_methods.find(instance_type);
257 if (factory_method_iter != factory.factory_methods.end()) 267 if (factory_method_iter != factory.factory_methods.end())
258 return (*factory_method_iter->second)( 268 return (*factory_method_iter->second)(
259 extension, action_dict, error, bad_message); 269 extension, action_dict, error, bad_message);
260 270
261 *error = base::StringPrintf(kInvalidInstanceTypeError, instance_type.c_str()); 271 *error = base::StringPrintf(kInvalidInstanceTypeError, instance_type.c_str());
262 return scoped_refptr<ContentAction>(); 272 return scoped_refptr<ContentAction>();
263 } 273 }
264 274
265 } // namespace extensions 275 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698