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

Unified 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: ready to land 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 side-by-side diff with in-line comments
Download patch
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..f0ec9132da841fb8486157da05e5750ad6984c1f
--- /dev/null
+++ b/chrome/browser/extensions/script_bubble_controller.cc
@@ -0,0 +1,53 @@
+// 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/browser/extensions/location_bar_controller.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);
+ ExtensionAction* page_action = extension->page_action();
+
+ page_action->SetAppearance(tab_id, ExtensionAction::ACTIVE);
+ page_action->SetBadgeText(tab_id, base::UintToString(extension_ids.size()));
+ page_action->SetBadgeBackgroundColor(tab_id, kBadgeBackgroundColor);
+
+ tab_helper_->location_bar_controller()->NotifyChange();
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/script_bubble_controller.h ('k') | chrome/browser/extensions/script_bubble_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698