Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/extensions/script_bubble_controller.h" | |
| 6 | |
| 7 #include "base/string_number_conversions.h" | |
| 8 #include "chrome/browser/profiles/profile.h" | |
| 9 #include "chrome/browser/extensions/component_loader.h" | |
| 10 #include "chrome/browser/extensions/extension_service.h" | |
| 11 #include "chrome/browser/extensions/extension_system.h" | |
| 12 #include "chrome/browser/extensions/extension_tab_util.h" | |
| 13 #include "chrome/common/extensions/extension.h" | |
| 14 #include "chrome/common/extensions/extension_action.h" | |
| 15 #include "third_party/skia/include/core/SkColor.h" | |
| 16 | |
| 17 namespace extensions { | |
| 18 | |
| 19 namespace { | |
| 20 | |
| 21 const SkColor kBadgeBackgroundColor = 0xEEEEDD00; | |
| 22 | |
| 23 } // namespace | |
| 24 | |
| 25 ScriptBubbleController::ScriptBubbleController(TabHelper* tab_helper) | |
| 26 : TabHelper::ContentScriptObserver(tab_helper) { | |
| 27 } | |
| 28 | |
| 29 void ScriptBubbleController::OnContentScriptsExecuting( | |
| 30 const content::WebContents* web_contents, | |
| 31 const ExecutingScriptsMap& extension_ids, | |
| 32 int32 page_id, | |
| 33 const GURL& on_url) { | |
| 34 Profile* profile = | |
| 35 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | |
| 36 ComponentLoader* loader = | |
| 37 ExtensionSystem::Get(profile)->extension_service()->component_loader(); | |
| 38 const Extension* extension = loader->GetScriptBubble(); | |
| 39 if (!extension) | |
| 40 return; | |
| 41 | |
| 42 int tab_id = ExtensionTabUtil::GetTabId(web_contents); | |
|
Jeffrey Yasskin
2012/10/02 00:26:31
This should be SessionId::IdForTab(web_contents);
Aaron Boodman
2012/10/02 01:28:52
Why? I prefer to use ExtensionTabUtil because sema
Jeffrey Yasskin
2012/10/02 01:45:51
They're the same id: ExtensionTabUtil::GetTabId ju
Aaron Boodman
2012/10/02 07:46:40
The SessionID in the unit test was a paste-o from
| |
| 43 ExtensionAction* page_action = extension->page_action(); | |
| 44 | |
| 45 page_action->SetAppearance(tab_id, ExtensionAction::ACTIVE); | |
|
Jeffrey Yasskin
2012/10/02 00:26:31
I don't think this automatically tells the locatio
Aaron Boodman
2012/10/02 01:28:52
Done.
| |
| 46 page_action->SetBadgeText(tab_id, base::UintToString(extension_ids.size())); | |
| 47 page_action->SetBadgeBackgroundColor(tab_id, kBadgeBackgroundColor); | |
| 48 } | |
| 49 | |
| 50 } // namespace extensions | |
| OLD | NEW |