| Index: chrome/renderer/extensions/content_watcher.h
|
| diff --git a/chrome/renderer/extensions/content_watcher.h b/chrome/renderer/extensions/content_watcher.h
|
| index 8ef9d487b6a85fadaf08796aa8de5902a50a1eb8..cc7fb8c712681b88c15fb65285f3b4fed1d855bc 100644
|
| --- a/chrome/renderer/extensions/content_watcher.h
|
| +++ b/chrome/renderer/extensions/content_watcher.h
|
| @@ -6,16 +6,15 @@
|
| #define CHROME_RENDERER_EXTENSIONS_CONTENT_WATCHER_H_
|
|
|
| #include <map>
|
| +#include <set>
|
| #include <string>
|
| #include <vector>
|
|
|
| -#include "base/memory/scoped_ptr.h"
|
| -#include "base/memory/weak_ptr.h"
|
| -#include "base/strings/string_piece.h"
|
| -#include "v8/include/v8.h"
|
| +#include "third_party/WebKit/public/platform/WebVector.h"
|
|
|
| namespace WebKit {
|
| class WebFrame;
|
| +class WebString;
|
| }
|
|
|
| namespace extensions {
|
| @@ -32,30 +31,27 @@ class NativeHandler;
|
| // WebFrames can move between RenderViews through adoptNode.
|
| class ContentWatcher {
|
| public:
|
| - explicit ContentWatcher(Dispatcher* dispatcher);
|
| + ContentWatcher();
|
| ~ContentWatcher();
|
|
|
| - // Returns the callback to call on a frame change.
|
| - scoped_ptr<NativeHandler> MakeNatives(ChromeV8Context* context);
|
| -
|
| // Handler for ExtensionMsg_WatchPages.
|
| void OnWatchPages(const std::vector<std::string>& css_selectors);
|
|
|
| - // Registers the MutationObserver to call back into this object whenever the
|
| - // content of |frame| changes.
|
| + // Uses WebDocument::watchCSSSelectors to watch the selectors in
|
| + // css_selectors_ and get a callback into DidMatchCSS() whenever the set of
|
| + // matching selectors in |frame| changes.
|
| void DidCreateDocumentElement(WebKit::WebFrame* frame);
|
|
|
| - // Scans *frame for the current set of interesting CSS selectors, and if
|
| - // they've changed sends ExtensionHostMsg_OnWatchedPageChange back to the
|
| - // RenderViewHost that owns the frame.
|
| - void ScanAndNotify(WebKit::WebFrame* frame);
|
| + // Records that |newlyMatchingSelectors| have started matching on |*frame|,
|
| + // and |stoppedMatchingSelectors| have stopped matching.
|
| + void DidMatchCSS(
|
| + WebKit::WebFrame* frame,
|
| + const WebKit::WebVector<WebKit::WebString>& newlyMatchingSelectors,
|
| + const WebKit::WebVector<WebKit::WebString>& stoppedMatchingSelectors);
|
|
|
| private:
|
| - void EnsureWatchingMutations(WebKit::WebFrame* frame);
|
| -
|
| - ModuleSystem* GetModuleSystem(WebKit::WebFrame* frame) const;
|
| - std::vector<base::StringPiece> FindMatchingSelectors(
|
| - WebKit::WebFrame* frame) const;
|
| + // Returns the subset of |css_selectors_| that match elements on |frame|.
|
| + std::set<std::string> FindMatchingSelectors(WebKit::WebFrame* frame) const;
|
|
|
| // Given that we saw a change in the CSS selectors that |changed_frame|
|
| // matched, tell the browser about the new set of matching selectors in its
|
| @@ -64,21 +60,13 @@ class ContentWatcher {
|
| // frames that it could run on.
|
| void NotifyBrowserOfChange(WebKit::WebFrame* changed_frame) const;
|
|
|
| - base::WeakPtrFactory<ContentWatcher> weak_ptr_factory_;
|
| - Dispatcher* dispatcher_;
|
| -
|
| // If any of these selectors match on a page, we need to send an
|
| // ExtensionHostMsg_OnWatchedPageChange back to the browser.
|
| - std::vector<std::string> css_selectors_;
|
| + WebKit::WebVector<WebKit::WebString> css_selectors_;
|
|
|
| - // Maps live WebFrames to the set of CSS selectors they match. This lets us
|
| - // traverse a top-level frame's sub-frames without rescanning them all each
|
| - // time any one changes.
|
| - //
|
| - // The StringPieces point into css_selectors_ above, so when it changes, they
|
| - // all need to be regenerated.
|
| - std::map<WebKit::WebFrame*,
|
| - std::vector<base::StringPiece> > matching_selectors_;
|
| + // Maps live WebFrames to the set of CSS selectors they match. Blink sends
|
| + // back diffs, which we apply to these sets.
|
| + std::map<WebKit::WebFrame*, std::set<std::string> > matching_selectors_;
|
| };
|
|
|
| } // namespace extensions
|
|
|