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

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: Fix more review comments, and make script_badge_ non-mutable 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
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
24 ScriptBadgeController::ScriptBadgeController(TabContents* tab_contents) 25 ScriptBadgeController::ScriptBadgeController(TabContents* tab_contents)
25 : content::WebContentsObserver(tab_contents->web_contents()), 26 : content::WebContentsObserver(tab_contents->web_contents()),
26 script_executor_(tab_contents->web_contents()), 27 script_executor_(tab_contents->web_contents()),
27 tab_contents_(tab_contents) {} 28 tab_contents_(tab_contents) {
29 DCHECK(switch_utils::AreScriptBadgesEnabled())
30 << "This class will only be constructed from ExtensionTabHelper if "
31 << "script badges have been enabled.";
32 }
28 33
29 ScriptBadgeController::~ScriptBadgeController() {} 34 ScriptBadgeController::~ScriptBadgeController() {}
30 35
31 scoped_ptr<std::vector<ExtensionAction*> > 36 scoped_ptr<std::vector<ExtensionAction*> >
32 ScriptBadgeController::GetCurrentActions() { 37 ScriptBadgeController::GetCurrentActions() {
33 scoped_ptr<std::vector<ExtensionAction*> > current_actions( 38 scoped_ptr<std::vector<ExtensionAction*> > current_actions(
34 new std::vector<ExtensionAction*>()); 39 new std::vector<ExtensionAction*>());
35 40
36 ExtensionService* service = GetExtensionService(); 41 ExtensionService* service = GetExtensionService();
37 if (!service) 42 if (!service)
38 return current_actions.Pass(); 43 return current_actions.Pass();
39 44
40 for (ExtensionSet::const_iterator it = service->extensions()->begin(); 45 for (ExtensionSet::const_iterator it = service->extensions()->begin();
41 it != service->extensions()->end(); ++it) { 46 it != service->extensions()->end(); ++it) {
42 const Extension* extension = *it; 47 const Extension* extension = *it;
43 if (extensions_executing_scripts_.count(extension->id())) 48 if (extensions_executing_scripts_.count(extension->id()))
44 current_actions->push_back(extension->GetScriptBadge()); 49 current_actions->push_back(extension->script_badge());
45 } 50 }
46 return current_actions.Pass(); 51 return current_actions.Pass();
47 } 52 }
48 53
49 LocationBarController::Action ScriptBadgeController::OnClicked( 54 LocationBarController::Action ScriptBadgeController::OnClicked(
50 const std::string& extension_id, int mouse_button) { 55 const std::string& extension_id, int mouse_button) {
51 ExtensionService* service = GetExtensionService(); 56 ExtensionService* service = GetExtensionService();
52 if (!service) 57 if (!service)
53 return ACTION_NONE; 58 return ACTION_NONE;
54 59
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if (page_id == GetPageID()) { 147 if (page_id == GetPageID()) {
143 size_t original_size = extensions_executing_scripts_.size(); 148 size_t original_size = extensions_executing_scripts_.size();
144 extensions_executing_scripts_.insert(extension_ids.begin(), 149 extensions_executing_scripts_.insert(extension_ids.begin(),
145 extension_ids.end()); 150 extension_ids.end());
146 if (extensions_executing_scripts_.size() > original_size) 151 if (extensions_executing_scripts_.size() > original_size)
147 Notify(); 152 Notify();
148 } 153 }
149 } 154 }
150 155
151 } // namespace extensions 156 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698