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

Unified Diff: chrome/browser/extensions/extension_action.cc

Issue 11547033: Implement declarativeContent API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix vabr's comments; make GetMatches const; fix NULL dereference in test Created 7 years, 11 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/extension_action.cc
diff --git a/chrome/browser/extensions/extension_action.cc b/chrome/browser/extensions/extension_action.cc
index c193f4c98f329d9ffef7f1159add92cd51dae943..1d7648aebb372c6c30fc376daa86ff7c691b76e2 100644
--- a/chrome/browser/extensions/extension_action.cc
+++ b/chrome/browser/extensions/extension_action.cc
@@ -272,6 +272,18 @@ bool ExtensionAction::SetAppearance(int tab_id, Appearance new_appearance) {
return true;
}
+void ExtensionAction::DeclarativeShow(int tab_id) {
+ DCHECK_NE(tab_id, kDefaultTabId);
+ ++declarative_show_count_[tab_id]; // Use default initialization to 0.
+}
+
+void ExtensionAction::UndoDeclarativeShow(int tab_id) {
+ int& show_count = declarative_show_count_[tab_id];
+ DCHECK_GT(show_count, 0);
+ if (--show_count == 0)
+ declarative_show_count_.erase(tab_id);
+}
+
void ExtensionAction::ClearAllValuesForTab(int tab_id) {
popup_url_.erase(tab_id);
title_.erase(tab_id);
@@ -280,6 +292,10 @@ void ExtensionAction::ClearAllValuesForTab(int tab_id) {
badge_text_color_.erase(tab_id);
badge_background_color_.erase(tab_id);
appearance_.erase(tab_id);
+ // TODO(jyasskin): Erase the element from declarative_show_count_
+ // when the tab's closed. There's a race between the
+ // PageActionController and the ContentRulesRegistry on navigation,
+ // which prevents me from cleaning everything up now.
icon_animation_.erase(tab_id);
}

Powered by Google App Engine
This is Rietveld 408576698