I am trying to use declarative Content API with chrome.dart . I want to display the pageAction icon only when loading the corresponding url.
I am looking for a working example of how to do this.
What I am doing now. First I create an instance of chrome.Rule calledr
var url = new chrome.UrlFilter(
pathSuffix: 'private/chat/index.pl'
, queryContains: 'xyz=');
var matcher = new chrome.PageStateMatcher(pageUrl: url);
var r = new chrome.Rule(
id: 'myrule'
, actions: [new chrome.ShowPageAction()]
, conditions: [matcher]);
From the documentation , I suggest that I should do this (which does not work, throws an exception)
var eventName = 'onPageChanged';
var e = new chrome.ChromeEvent();
e.addRules(eventName, [r]);
The exception is
Exception: NoSuchMethodError: method not found: 'addRules'
Receiver: Instance of 'JsObject'
Arguments: ["onPageChanged", Instance of 'JsArray', Closure: ([dynamic]) => dynamic]
I tried to find other ways to get an instance of ChromeEvent. I did not find anything in the library. The most I got is to do
var p = jsContext['chrome']['declarativeContent']['onPageChanged'];
var e = new chrome.ChromeEvent.fromProxy(p);
which also crashed with an exception, but a little deeper in the code;)
chrome.dart: https://github.com/dart-gde/chrome.dart/issues/161