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

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: 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 CHECK(switch_utils::IsActionBoxEnabled())
30 << "Without this, extension->script_badge() would return NULL.";
not at google - send to devlin 2012/06/18 18:51:24 Is this necessary? We only construct these objects
Jeffrey Yasskin 2012/06/18 22:16:03 The CHECK is intended to tell people reading the c
not at google - send to devlin 2012/06/18 22:59:41 Maybe just a comment would be more appropriate the
Jeffrey Yasskin 2012/06/18 23:58:41 I put the comment inside the DCHECK. For future r
not at google - send to devlin 2012/06/19 00:27:32 I think of DCHECK as documentation and CHECK as bu
Jeffrey Yasskin 2012/06/19 21:43:08 Now that script_badge() always returns non-NULL, I
31 }
28 32
29 ScriptBadgeController::~ScriptBadgeController() {} 33 ScriptBadgeController::~ScriptBadgeController() {}
30 34
31 scoped_ptr<std::vector<ExtensionAction*> > 35 scoped_ptr<std::vector<ExtensionAction*> >
32 ScriptBadgeController::GetCurrentActions() { 36 ScriptBadgeController::GetCurrentActions() {
33 scoped_ptr<std::vector<ExtensionAction*> > current_actions( 37 scoped_ptr<std::vector<ExtensionAction*> > current_actions(
34 new std::vector<ExtensionAction*>()); 38 new std::vector<ExtensionAction*>());
35 39
36 ExtensionService* service = GetExtensionService(); 40 ExtensionService* service = GetExtensionService();
37 if (!service) 41 if (!service)
38 return current_actions.Pass(); 42 return current_actions.Pass();
39 43
40 for (ExtensionSet::const_iterator it = service->extensions()->begin(); 44 for (ExtensionSet::const_iterator it = service->extensions()->begin();
41 it != service->extensions()->end(); ++it) { 45 it != service->extensions()->end(); ++it) {
42 const Extension* extension = *it; 46 const Extension* extension = *it;
43 if (extensions_executing_scripts_.count(extension->id())) 47 if (extensions_executing_scripts_.count(extension->id()))
44 current_actions->push_back(extension->GetScriptBadge()); 48 current_actions->push_back(extension->script_badge());
45 } 49 }
46 return current_actions.Pass(); 50 return current_actions.Pass();
47 } 51 }
48 52
49 LocationBarController::Action ScriptBadgeController::OnClicked( 53 LocationBarController::Action ScriptBadgeController::OnClicked(
50 const std::string& extension_id, int mouse_button) { 54 const std::string& extension_id, int mouse_button) {
51 ExtensionService* service = GetExtensionService(); 55 ExtensionService* service = GetExtensionService();
52 if (!service) 56 if (!service)
53 return ACTION_NONE; 57 return ACTION_NONE;
54 58
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if (page_id == GetPageID()) { 146 if (page_id == GetPageID()) {
143 size_t original_size = extensions_executing_scripts_.size(); 147 size_t original_size = extensions_executing_scripts_.size();
144 extensions_executing_scripts_.insert(extension_ids.begin(), 148 extensions_executing_scripts_.insert(extension_ids.begin(),
145 extension_ids.end()); 149 extension_ids.end());
146 if (extensions_executing_scripts_.size() > original_size) 150 if (extensions_executing_scripts_.size() > original_size)
147 Notify(); 151 Notify();
148 } 152 }
149 } 153 }
150 154
151 } // namespace extensions 155 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698