Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/devtools.js

Issue 29362526: Issue 4644 - Pass search messages to our devtools panel (Closed)
Patch Set: Created Nov. 14, 2016, 7:56 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/devtools.js
diff --git a/chrome/devtools.js b/chrome/devtools.js
index 255aeb387bfa8db9e15005390587874a782f4a1b..aed487c1fdef1c8ae00dd1cf9306e836fe5f50c4 100644
--- a/chrome/devtools.js
+++ b/chrome/devtools.js
@@ -17,6 +17,8 @@
"use strict";
+var panelWindow = null;
Sebastian Noack 2017/01/12 23:25:02 Is the panel (and it's window) a singleton? What i
Sebastian Noack 2017/01/12 23:25:02 Any reason to not use let (instead of var) here?
kzar 2017/01/13 08:30:08 Done.
kzar 2017/01/13 08:30:08 Good point, but I just tested and it works fine wi
+
chrome.runtime.sendMessage(
{
type: "prefs.get",
@@ -25,8 +27,35 @@ chrome.runtime.sendMessage(
function(enabled)
{
if (enabled)
- chrome.devtools.panels.create("Adblock Plus",
- "icons/detailed/abp-48.png",
- "devtools-panel.html");
+ {
+ chrome.devtools.panels.create(
+ "Adblock Plus",
+ "icons/detailed/abp-48.png",
+ "devtools-panel.html",
+ function (panel)
Sebastian Noack 2017/01/12 23:25:02 I wonder whether we should use arrow functions her
kzar 2017/01/13 08:30:08 I think the rule is to use let and arrow functions
Sebastian Noack 2017/01/13 11:57:38 I tend to agree. Mind filing a review to add it to
+ {
+ panel.onShown.addListener(function(window)
+ {
+ panelWindow = window;
+ });
+
+ panel.onHidden.addListener(function(window)
+ {
+ panelWindow = null;
+ });
+
+ panel.onSearch.addListener(function(eventName, queryString)
+ {
+ if (panelWindow)
+ {
+ panelWindow.postMessage({
+ type: eventName,
+ queryString: queryString
+ }, "*");
+ }
+ });
+ }
+ );
+ }
}
);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld