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

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

Issue 11014009: Beginnings of the script bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: yozments Created 8 years, 2 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
(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/browser/extensions/location_bar_controller.h"
14 #include "chrome/common/extensions/extension.h"
15 #include "chrome/common/extensions/extension_action.h"
16 #include "third_party/skia/include/core/SkColor.h"
17
18 namespace extensions {
19
20 namespace {
21
22 const SkColor kBadgeBackgroundColor = 0xEEEEDD00;
23
24 } // namespace
25
26 ScriptBubbleController::ScriptBubbleController(TabHelper* tab_helper)
27 : TabHelper::ContentScriptObserver(tab_helper) {
28 }
29
30 void ScriptBubbleController::OnContentScriptsExecuting(
31 const content::WebContents* web_contents,
32 const ExecutingScriptsMap& extension_ids,
33 int32 page_id,
34 const GURL& on_url) {
35 Profile* profile =
36 Profile::FromBrowserContext(web_contents->GetBrowserContext());
37 ComponentLoader* loader =
38 ExtensionSystem::Get(profile)->extension_service()->component_loader();
39 const Extension* extension = loader->GetScriptBubble();
40 if (!extension)
41 return;
42
43 int tab_id = ExtensionTabUtil::GetTabId(web_contents);
44 ExtensionAction* page_action = extension->page_action();
45
46 page_action->SetAppearance(tab_id, ExtensionAction::ACTIVE);
47 page_action->SetBadgeText(tab_id, base::UintToString(extension_ids.size()));
48 page_action->SetBadgeBackgroundColor(tab_id, kBadgeBackgroundColor);
49
50 tab_helper_->location_bar_controller()->NotifyChange();
51 }
52
53 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698