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

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: More minor cleanup Created 8 years, 3 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..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

Powered by Google App Engine
This is Rietveld 408576698