Take the query history as an example:
1. In the upper History.js, send the event request and related parameters to the bottom through Chrome.send (), where ' queryhistory ' is the signal name, [This.searchtext_, This.offset_, This.rangeindays_, EndTime, MaxResults] is the parameter passed to the bottom:
Chrome.send (' QueryHistory ', [This This] rangeindays_, EndTime, MaxResults]);
2. In the underlying browsing_history_handler.cc, the Registermessages function responds to events from the upper layer:
void browsinghistoryhandler::registermessages () {... ... WEB_UI ()->registermessagecallback ("queryhistory", Base :: Bind (&browsinghistoryhandler::handlequeryhistory, base:: Unretained ( this))); ...}
The event response for the query history is then processed in the Browsinghistoryhandler::handlequeryhistory () function.
3. After processing, call the upper JS method via Calljavascriptfunction () and return the data that needs to be returned.
void browsinghistoryhandler::returnresultstofrontend () {... ... WEB_UI (),calljavascriptfunction ( "historyresult", Results_ Info_value_, results_value);
4. Then the upper-layer-specified method, i.e. Historyresult (), obtains the history of the originally specified query and can proceed with the related processing, completing a complete communication above:
function Historyresult (info, results) { Historymodel.addresults (info, results);}
Report:
Pull substitution code: Git clone
Force recovery to a committed version: Git reset--hard
Chrome Source Learning: JS and the underlying C + + communication