I've had both jobs where I could mostly work when I wanted to and also where I had to be in the office basically the entire day. I found that at the job where I had flexibility, I produced better output, and I didn't have a lot of time where I would surf the net to overcome boredom.
In the inflexible environment, surfing net locations that were somewhat work related was the only thing I could do to pass by time when I knew I wasn't going to write quality code or when I was too mentally tired to accomplish the task that was at hand. I had many times where going home and returning in the morning was the best thing for trying to solve a difficult problem.
Unfortunately, many employers don't care and want to fit development staff into the typical 9-5 mold even if it means reduced productivity.