Chromium Code Reviews| Index: chrome/browser/extensions/script_bubble_controller.cc |
| diff --git a/chrome/browser/extensions/script_bubble_controller.cc b/chrome/browser/extensions/script_bubble_controller.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9ffd6ca97f86329959d80461bc74475ab4ea9842 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/script_bubble_controller.cc |
| @@ -0,0 +1,50 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/extensions/script_bubble_controller.h" |
| + |
| +#include "base/string_number_conversions.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/extensions/component_loader.h" |
| +#include "chrome/browser/extensions/extension_service.h" |
| +#include "chrome/browser/extensions/extension_system.h" |
| +#include "chrome/browser/extensions/extension_tab_util.h" |
| +#include "chrome/common/extensions/extension.h" |
| +#include "chrome/common/extensions/extension_action.h" |
| +#include "third_party/skia/include/core/SkColor.h" |
| + |
| +namespace extensions { |
| + |
| +namespace { |
| + |
| +const SkColor kBadgeBackgroundColor = 0xEEEEDD00; |
| + |
| +} // namespace |
| + |
| +ScriptBubbleController::ScriptBubbleController(TabHelper* tab_helper) |
| + : TabHelper::ContentScriptObserver(tab_helper) { |
| +} |
| + |
| +void ScriptBubbleController::OnContentScriptsExecuting( |
| + const content::WebContents* web_contents, |
| + const ExecutingScriptsMap& extension_ids, |
| + int32 page_id, |
| + const GURL& on_url) { |
| + Profile* profile = |
| + Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| + ComponentLoader* loader = |
| + ExtensionSystem::Get(profile)->extension_service()->component_loader(); |
| + const Extension* extension = loader->GetScriptBubble(); |
| + if (!extension) |
| + return; |
| + |
| + 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
|
| + ExtensionAction* page_action = extension->page_action(); |
| + |
| + 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.
|
| + page_action->SetBadgeText(tab_id, base::UintToString(extension_ids.size())); |
| + page_action->SetBadgeBackgroundColor(tab_id, kBadgeBackgroundColor); |
| +} |
| + |
| +} // namespace extensions |