Attempt to handle a case whereby we've lost our automation server.

TEST=See bug.
BUG=52894

Review URL: http://codereview.chromium.org/3122041

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57539 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome_frame/chrome_active_document.cc b/chrome_frame/chrome_active_document.cc
index 7443943..1c967f0 100644
--- a/chrome_frame/chrome_active_document.cc
+++ b/chrome_frame/chrome_active_document.cc
@@ -975,9 +975,18 @@
 
 bool ChromeActiveDocument::LaunchUrl(const ChromeFrameUrl& cf_url,
                                      const std::string& referrer) {
-  DCHECK(automation_client_.get() != NULL);
   DCHECK(!cf_url.gurl().is_empty());
 
+  if (!automation_client_.get()) {
+    // http://code.google.com/p/chromium/issues/detail?id=52894
+    // Still not sure how this happens.
+    DLOG(ERROR) << "No automation client!";
+    if (!Initialize()) {
+      NOTREACHED() << "...and failed to start a new one >:(";
+      return false;
+    }
+  }
+
   url_.Allocate(UTF8ToWide(cf_url.gurl().spec()).c_str());
   if (cf_url.attach_to_external_tab()) {
     dimensions_ = cf_url.dimensions();
@@ -1020,6 +1029,7 @@
     tab_proxy->ReloadAsync();
   } else {
     DLOG(ERROR) << "No automation proxy";
+    DCHECK(automation_client_.get() != NULL) << "how did it get freed?";
     // The current url request manager (url_fetcher_) has been switched to
     // a stopping state so we need to reset it and get a new one for the new
     // automation server.