Use base::ScopedTypeRef for CGL types.

Use gfx::ScopedCGLSetCurrentContext for setting the current
context in the browser process. When calling CGLSetCurrentContext,
the pre-existing code inconsitently did either of restoring the
context, setting the context to NULL, or leaving the context set.
This makes the behavior consistent. It also makes error checking
pervasive.

BUG=245900

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250399 0039d316-1c4b-4281-b951-d872f2087c98
SVN changes up to revision 250399
Change which NSViews get CALayers

TLDR:
- Only give the browser's main window's contentsView a CALayer when in
  presentation mode.
- Give the find bar its own CALayer.
- Do not give infobars their own CALayers unless layer squashing is
  available (as otherwise there is no benefit).

Detail:

Giving the browser's main window's contentsView its own CALayer causes
all subviews in the entire NSView heirarchy to get their own CALayer.

The reason that the browser's main window's contentsView was given its
own CALayer is that some of these sub-layers are desirable for
overlapping views. In particular:
- The find bar will not overlap the web contents if it does not have
  its own CALayer.
- When in presentation mode, the tab strip, address bar, bookmark bar,
  and window background (the part of the tabstrip that is not the tabs)
  will not overlap the web contents when the mouse is moved to the
  top of the screen.

This (the browser window contentsView having a CALayer) has two
drawbacks:
- It causes incredibly poor performance -- only 2 windows can update
  at 60fps on an rMBP using the iGPU versus 7 or more when not (see
  http://crbug.com/340133). The reason for this is not yet known.
- It causes sub-pixel anti-aliasing to be lost on all NSViews, unless
  layer squashing or other workarounds are done (see remarks in
  r247098).

The core change of this patch is that it only gives the browser's main
window's contentsView a CALayer when in presentation mode. This elides
the performance issues (because only one fullscreen window can be
powered by the iGPU to begin with). This also fixes the remaining text
anti-aliasing issues (but only when not in presentation mode), because
the problematic views (e.g, infobars) no longer get layers.

The find bar is given its own layer unconditionally because it needs to
overlay the web contents.

The infobars are given their own layer when layer squashing is
available. This means that when layer squashing is available, infobars
will always have anti-aliased text. When layer squashing is
unavailable, infobars are still missing anti-aliased text only in
presentation mode.

Also of note is that the find bar is missing anti-aliased text in 10.6
and 10.7 (the behavior of NSTextField was changed in 10.8).

BUG=245900

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250400 0039d316-1c4b-4281-b951-d872f2087c98
SVN changes up to revision 250400