Google has agreed to pay $28 million to settle a class-action lawsuit that it gave preferential treatment to white and Asian employees.