function refresh_extension(callback, context)

% refresh_extension - update browser extension state
% --------------------------------------------------
%
% refresh_extension(callback, context)
%
% Input:
% ------
%  callback - callback context
%  context - extension context

% NOTE: this function may use 'set_browser_extension'

%-----------------------------
% SETUP
%-----------------------------

%--
% unpack input
%--

pal = callback.pal; par = callback.par; 

ext = context.ext;

%-----------------------------
% REFRESH EXTENSION
%-----------------------------

%--
% close palette
%--

close(pal.handle);

%--
% refresh extension
%--

data = get_browser(par.handle);

[ext, ix] = get_browser_extension(ext.subtype, par.handle, ext.name, data);

data.browser.(ext.subtype).ext(ix) = extension_initialize(ext, context);

set(par.handle, 'userdata', data);

%--
% open palette
%--

extension_palettes(par.handle, ext.name);
