def UpdateState(browser, action):
  """Return new browser state after performing action.

  Args:
    browser: current browser state.
    action: next action performed.

  Returns:
    new browser state.
  """
  a = action.split(';')[0]
  if a == 'openwindow':
    browser.NewWindow()
  elif a == 'goofftherecord':
    browser.NewWindow(private=True)
  elif a == 'newtab':
    browser.NewTab()
  elif a == 'dragtabout':
    browser.DragOut()
  elif a == 'dragtableft':
    browser.DragLeft()
  elif a == 'dragtabright':
    browser.DragRight()
  elif a == 'closetab':
    browser.RemoveTab()
  elif a == 'closewindow':
    browser.RemoveWindow()
  elif a == 'restoretab':
    browser.Restore()
  elif a == 'navigate':
    browser.Navigate(action.split(';')[1])
  elif a == 'downloads':
    browser.Downloads()
  elif a == 'back':
    browser.Back()
  elif a == 'forward':
    browser.Forward()
  elif a == 'nexttab':
    browser.NextTab()
  elif a == 'lasttab':
    browser.LastTab()
  return browser