Cache the bookmarks menu on OSX between profile switches.

Previously, when you switched to a profile, we invalidated the existing
bookmarks menu and updated it lazily. Because of the way OSX works, this causes
the menu to be recalculated from scratch the first time you press *any* keyboard
shortcut afer switching to the profile. On a profile with several hundred
bookmarks, this can take several seconds - more than enough to impact casual
browsing.
In particular, it would appear to the user that various innocent shortcuts (e.g.
opening a new tab, copying text, highlighting the location bar) are extremely
slow some of the time. Even more annoyingly, if you switched to a profile and
then immediately alt-tabbed away from it (for example, to get to a third
profile), the lockup would take place when you switched *away* from the profile
– even if you didn't perform any actions on the profile!

This change caches the bookmarks menu and restores it when a window for the
profile gains focus again. That way, the bookmarks menu is updated only when an
action directly invalidates it (i.e. adding or changing bookmarks themselves).
The accompanying test (BookmarksMenuIsRestoredAfterProfileSwitch) verifies that
the menu is restored correctly after switching profile windows and back.

Thanks to Robert Sesek for extensive help while writing and debugging this fix,
as well as its accompanying test. :-)

BUG=429371
TEST=Follow the steps in comment #27 on bug 429371: https://crbug.com/429371#c27

Review URL: https://codereview.chromium.org/733673003

Cr-Commit-Position: refs/heads/master@{#304531}
8 files changed