Add check that modal_delegate is not NULL in BuildViewForPasswordManager.

This will help understand reasons for crash (see bug).

BUG=305727
NOTRY=true

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229419 0039d316-1c4b-4281-b951-d872f2087c98
Use WindowActivated message instead of VisibilityChanged message to determine that Ash is the active desktop on Win8.

This is better than the VisibilityChanged event as it also handles the dual monitor case where Ash isn't hidden yet is no longer active (and Chrome desktop window can thus steal the "active desktop" state which was then not given back to the Ash desktop when re-focusing it. The WindowActivated event gets a CoreWindowActivationState_PointerActivated state for this specific case; which we treat the same as CoreWindowActivationState_CodeActivated for now.

Also remove the hooks for VisibilityChanged as they were only used for this purpose, i.e.:
https://code.google.com/p/chromium/codesearch#search/&q=OnRootWindowActivated&sq=package:chromium&type=cs
Called from: https://code.google.com/p/chromium/codesearch#chromium/src/ui/aura/env.cc&l=83
Called from: https://code.google.com/p/chromium/codesearch#chromium/src/ui/aura/root_window.cc&l=988
Called from: https://code.google.com/p/chromium/codesearch#chromium/src/ui/aura/remote_root_window_host_win.cc&l=463

BUG=177489
TEST=
The most reliable test I could find that would repro this is to:
1) Open Ash
2) Open Chrome on desktop on a 2nd monitor
3) Refocus Ash on first monitor
4) Signin with an account which will sync extensions (at least one of which opens a tab on install, e.g., https://chrome.google.com/webstore/detail/reload-all-tabs/midkcinmplflbiflboepnahkboeonkam).

Without this CL, this will result in the extension's tab opening on the desktop Chrome's window.

With this CL, the tab correctly opens in Ash as it was the last desktop focused.

Also make sure the regular use cases still work using the same test under:
A) Only Ash open
B) Ash open, but active desktop is native desktop.

Also confirmed using Sawbuck and some logging that the following is how OnWindowActivated() reports its state:
CoreWindowActivationState_CodeActivated == 0
 - First activation
 - Activated when hidden (either from Start Screen or Windows app switcher while viewing another app).

CoreWindowActivationState_Deactivated == 1
 - All deactivations (including focusing a desktop app on the 2nd monitor while Ash remains open on 1st monitor)

CoreWindowActivationState_PointerActivated
 - Ash is focused again after a window on another monitor had been focused while Ash stayed visible on its monitor.

R=cdn@chromium.org, grt@chromium.org, sky@chromium.org

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

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