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

Side by Side Diff: chrome/browser/extensions/script_badge_controller.cc

Issue 10565017: Parse the script_badge manifest section. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Back out support for setting switches in unittests. Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_browser_event_router.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/script_badge_controller.h" 5 #include "chrome/browser/extensions/script_badge_controller.h"
6 6
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/extension_system.h" 8 #include "chrome/browser/extensions/extension_system.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents.h" 9 #include "chrome/browser/ui/tab_contents/tab_contents.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
11 #include "chrome/common/extensions/extension_action.h" 11 #include "chrome/common/extensions/extension_action.h"
12 #include "chrome/common/extensions/extension_messages.h" 12 #include "chrome/common/extensions/extension_messages.h"
13 #include "chrome/common/extensions/extension_set.h" 13 #include "chrome/common/extensions/extension_set.h"
14 #include "chrome/common/extensions/extension_switch_utils.h"
14 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
15 #include "content/public/browser/navigation_controller.h" 16 #include "content/public/browser/navigation_controller.h"
16 #include "content/public/browser/navigation_entry.h" 17 #include "content/public/browser/navigation_entry.h"
17 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
19 #include "ipc/ipc_message.h" 20 #include "ipc/ipc_message.h"
20 #include "ipc/ipc_message_macros.h" 21 #include "ipc/ipc_message_macros.h"
21 22
22 namespace extensions { 23 namespace extensions {
23 24
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 return false; 159 return false;
159 160
160 ExtensionService* service = GetExtensionService(); 161 ExtensionService* service = GetExtensionService();
161 if (!service) 162 if (!service)
162 return false; 163 return false;
163 164
164 const Extension* extension = service->extensions()->GetByID(extension_id); 165 const Extension* extension = service->extensions()->GetByID(extension_id);
165 if (!extension) 166 if (!extension)
166 return false; 167 return false;
167 168
168 current_actions_.push_back(extension->GetScriptBadge()); 169 current_actions_.push_back(extension->script_badge());
169 return true; 170 return true;
170 } 171 }
171 172
172 173
173 bool ScriptBadgeController::EraseExtension(const Extension* extension) { 174 bool ScriptBadgeController::EraseExtension(const Extension* extension) {
174 if (extensions_executing_scripts_.erase(extension->id()) == 0) 175 if (extensions_executing_scripts_.erase(extension->id()) == 0)
175 return false; 176 return false;
176 177
177 size_t size_before = current_actions_.size(); 178 size_t size_before = current_actions_.size();
178 179
179 for (std::vector<ExtensionAction*>::iterator it = current_actions_.begin(); 180 for (std::vector<ExtensionAction*>::iterator it = current_actions_.begin();
180 it != current_actions_.end(); ++it) { 181 it != current_actions_.end(); ++it) {
181 // Safe to -> the extension action because we still have a handle to the 182 // Safe to -> the extension action because we still have a handle to the
182 // owner Extension. 183 // owner Extension.
183 // 184 //
184 // Also note that this means that when extensions are uninstalled their 185 // Also note that this means that when extensions are uninstalled their
185 // script badges will disappear, even though they're still acting on the 186 // script badges will disappear, even though they're still acting on the
186 // page (since they would have already acted). 187 // page (since they would have already acted).
187 if ((*it)->extension_id() == extension->id()) { 188 if ((*it)->extension_id() == extension->id()) {
188 current_actions_.erase(it); 189 current_actions_.erase(it);
189 break; 190 break;
190 } 191 }
191 } 192 }
192 193
193 CHECK_EQ(size_before, current_actions_.size() + 1); 194 CHECK_EQ(size_before, current_actions_.size() + 1);
194 return true; 195 return true;
195 } 196 }
196 197
197 } // namespace extensions 198 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browser_event_router.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698