A new California privacy bill would require law enforcement to obtain a warrant or wiretap order before searching a person’s smartphone, laptop, or other electronic device. One would also be needed to access information stored on remote services.

The bill, called the California Electronic Communications Privacy Act, passed unanimously in the Senate and aims to modernize California’s privacy laws. It was sponsored by State Senator Mark Leno (D-San Francisco), who argued that “California is in the digital dark ages” in terms of privacy protections. It is supported by a coalition of the state’s leading technology companies and organizations, including Apple, Google, Facebook, Microsoft, Twitter, Engine, Mozilla, the American Civil Liberties Union of California, the Electronic Frontier Foundation, and the Center for Democracy and Technology.

“What the bill does is brings our state statute into the 21st century to catch up with technology with regards to privacy,” Leno said, as quoted by the Los Angeles Times. “Of course law enforcement needs a warrant before it can go into your mailbox and read your mail, but it does not currently need a warrant to read your emails or text communications or other electronic communications.”

The bill received bipartisan support from co-author Republican Senator Joel Anderson of San Diego, who said, “It is very important to protect our liberties.” It still has to pass the California Assembly and be signed into law by Governor Jerry Brown.

READ MORE: California governor vetoes bill requiring warrants for police drones

Governor Brown represents a potential stumbling block as he has been reluctant to curtail law enforcement activities using drones for surveillance, and has twice vetoed legislation that would have limited law enforcement in smartphone searches.

In a previous veto in 2011 over SB 1434, Brown said the measure would overturn a California Supreme Court decision that held that police officers can lawfully search the cell phones of people who they arrest.

“The courts are better suited to resolve the complex and case-specific issues relating to constitutional search-and-seizure protections,” said Brown.

Meanwhile, the new bill is opposed by the California District Attorneys Association, the California Police Chiefs Association, and the California State Sheriffs’ Association. They argue it would simply create obstacles for law enforcement.

The LA Times reported the prosecutors’ group had written to lawmakers saying the bill “undermines critical efforts to stop child exploitation, mandates the destruction of evidence by law enforcement, and violates the California Constitution.”

Anticipating objections from law enforcement and the governor, Senator Leno added broad exceptions to the bill allowing that a warrant was unnecessary if it would hamper ongoing law enforcement investigations or efforts to protect the public. The bill also granted an exception for situations when an owner of a device gives consent to a search and for when law enforcement thinks there is imminent danger of serious physical injury that requires access to prevent.