Remove dependency from NaCl code on chrome_constants.

This is part of an effort to componentize NaCl code.
BUG=244791

Review URL: https://chromiumcodereview.appspot.com/16154005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207806 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/nacl_host/nacl_broker_host_win.cc b/chrome/browser/nacl_host/nacl_broker_host_win.cc
index 2115adb..b8d2c4f 100644
--- a/chrome/browser/nacl_host/nacl_broker_host_win.cc
+++ b/chrome/browser/nacl_host/nacl_broker_host_win.cc
@@ -8,8 +8,7 @@
 #include "base/path_service.h"
 #include "ipc/ipc_switches.h"
 #include "chrome/browser/nacl_host/nacl_broker_service_win.h"
-#include "chrome/browser/nacl_host/nacl_process_host.h"
-#include "chrome/common/chrome_constants.h"
+#include "chrome/browser/nacl_host/nacl_browser.h"
 #include "chrome/common/chrome_process_type.h"
 #include "chrome/common/chrome_switches.h"
 #include "chrome/common/logging_chrome.h"
@@ -52,11 +51,10 @@
     return false;
 
   // Create the path to the nacl broker/loader executable.
-  base::FilePath module_path;
-  if (!PathService::Get(base::FILE_MODULE, &module_path))
+  base::FilePath nacl_path;
+  if (!NaClBrowser::GetInstance()->GetNaCl64ExePath(&nacl_path))
     return false;
 
-  base::FilePath nacl_path = module_path.DirName().Append(chrome::kNaClAppName);
   CommandLine* cmd_line = new CommandLine(nacl_path);
   nacl::CopyNaClCommandLineArguments(cmd_line);
 
diff --git a/chrome/browser/nacl_host/nacl_browser.cc b/chrome/browser/nacl_host/nacl_browser.cc
index e6811d3..101a7de2 100644
--- a/chrome/browser/nacl_host/nacl_browser.cc
+++ b/chrome/browser/nacl_host/nacl_browser.cc
@@ -197,6 +197,18 @@
   }
 }
 
+#if defined(OS_WIN)
+bool NaClBrowser::GetNaCl64ExePath(base::FilePath* exe_path) {
+  base::FilePath module_path;
+  if (!PathService::Get(base::FILE_MODULE, &module_path)) {
+    LOG(ERROR) << "NaCl process launch failed: could not resolve module";
+    return false;
+  }
+  *exe_path = module_path.DirName().Append(L"nacl64");
+  return true;
+}
+#endif
+
 NaClBrowser* NaClBrowser::GetInstance() {
   return Singleton<NaClBrowser>::get();
 }
diff --git a/chrome/browser/nacl_host/nacl_browser.h b/chrome/browser/nacl_host/nacl_browser.h
index e2f041e..77bae0f 100644
--- a/chrome/browser/nacl_host/nacl_browser.h
+++ b/chrome/browser/nacl_host/nacl_browser.h
@@ -109,6 +109,11 @@
   bool QueryKnownToValidate(const std::string& signature, bool off_the_record);
   void SetKnownToValidate(const std::string& signature, bool off_the_record);
   void ClearValidationCache(const base::Closure& callback);
+#if defined(OS_WIN)
+  // Get path to NaCl loader on the filesystem if possible.
+  // |exe_path| does not change if the method fails.
+  bool GetNaCl64ExePath(base::FilePath* exe_path);
+#endif
 
  private:
   friend struct DefaultSingletonTraits<NaClBrowser>;
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc
index 6f7f50c..05cec37 100644
--- a/chrome/browser/nacl_host/nacl_process_host.cc
+++ b/chrome/browser/nacl_host/nacl_process_host.cc
@@ -27,7 +27,6 @@
 #include "chrome/browser/nacl_host/nacl_browser.h"
 #include "chrome/browser/nacl_host/nacl_host_message_filter.h"
 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
-#include "chrome/common/chrome_constants.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/common/chrome_process_type.h"
 #include "chrome/common/chrome_switches.h"
@@ -443,12 +442,9 @@
 #if defined(OS_WIN)
   // On Windows 64-bit NaCl loader is called nacl64.exe instead of chrome.exe
   if (RunningOnWOW64()) {
-    base::FilePath module_path;
-    if (!PathService::Get(base::FILE_MODULE, &module_path)) {
-      LOG(ERROR) << "NaCl process launch failed: could not resolve module";
+    if (!NaClBrowser::GetInstance()->GetNaCl64ExePath(&exe_path)) {
       return false;
     }
-    exe_path = module_path.DirName().Append(chrome::kNaClAppName);
   }
 #endif
 
diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc
index 14b833829..66482f1 100644
--- a/chrome/common/chrome_constants.cc
+++ b/chrome/common/chrome_constants.cc
@@ -133,8 +133,6 @@
 };
 #endif  // OS_MACOSX
 
-const wchar_t kNaClAppName[] = L"nacl64";
-
 #if defined(OS_WIN)
 const base::FilePath::CharType kMetroDriverDll[] = FPL("metro_driver.dll");
 const wchar_t kStatusTrayWindowClass[] = L"Chrome_StatusTrayWindow";
diff --git a/chrome/common/chrome_constants.h b/chrome/common/chrome_constants.h
index 7446209..1457939 100644
--- a/chrome/common/chrome_constants.h
+++ b/chrome/common/chrome_constants.h
@@ -46,7 +46,6 @@
 extern const char    kInitialProfile[];
 extern const char    kMultiProfileDirPrefix[];
 extern const wchar_t kBrowserResourcesDll[];
-extern const wchar_t kNaClAppName[];
 extern const base::FilePath::CharType kExtensionFileExtension[];
 extern const base::FilePath::CharType kExtensionKeyFileExtension[];