File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
Chrome/Example/simple_extension Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 1212 //bridge
1313 var bridge = { } ;
1414
15- chrome . extension . onMessage . addListener (
15+ chrome . runtime . onMessage . addListener (
1616 function ( message , sender , sendResponse ) {
1717 _dispatchMessage ( message , sendResponse ) ;
1818 } ) ;
2323 function _send ( msg , responseCallback ) {
2424 assert ( ! responseCallback || responseCallback instanceof Function , "responseCallback should be function" ) ;
2525 if ( responseCallback ) {
26- chrome . extension . sendMessage ( msg , responseCallback )
26+ chrome . runtime . sendMessage ( msg , responseCallback )
2727 } else {
28- chrome . extension . sendMessage ( msg )
28+ chrome . runtime . sendMessage ( msg )
2929 }
3030 }
3131 bridge . init = function ( onMessageCallback ) {
3232 _messageHandler = onMessageCallback ;
3333 //register for accept message
34- chrome . extension . sendMessage ( MSG_REGISTER_WANJUAN_INTERFACE ) ;
34+ chrome . runtime . sendMessage ( MSG_REGISTER_WANJUAN_INTERFACE ) ;
3535 }
3636
3737 bridge . registerHandler = function ( handlerName , handler ) {
Original file line number Diff line number Diff line change 1313 var messageHandlers = { } ;
1414 var _messageHandler ;
1515
16- chrome . extension . onMessage . addListener (
16+ chrome . runtime . onMessage . addListener (
1717 function ( message , sender , sendResponse ) {
18+ if ( register ( message , sender , sendResponse ) ) return ;
1819 _dispatchMessage ( message , sendResponse ) ;
1920 } ) ;
2021
5859 if ( MSG_REGISTER_WANJUAN_INTERFACE == message && ! bridge . tabIds [ sender . tab ] ) {
5960 bridge . tabIds [ sender . tab . id ] = sender . tab . id ;
6061 console . log ( "regiseter:" + sender . tab . id ) ;
62+ return true ;
6163 }
6264 }
63- chrome . extension . onMessage . addListener ( register ) ;
65+ // chrome.extension.onMessage.addListener(register);
6466
You can’t perform that action at this time.
0 commit comments