Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Unified Diff: chrome/browser/nacl_host/pnacl_file_host.cc

Issue 12184029: Make pnacl install on demand when it is not already installed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: forward decl Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/component_updater/pnacl/pnacl_component_installer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/nacl_host/pnacl_file_host.cc
diff --git a/chrome/browser/nacl_host/pnacl_file_host.cc b/chrome/browser/nacl_host/pnacl_file_host.cc
index 966fc7f9633e203af56ede0dbc846ef77366f5fc..0d03f8ee67a2c597606706ebfdbcc0c5e5400fd3 100644
--- a/chrome/browser/nacl_host/pnacl_file_host.cc
+++ b/chrome/browser/nacl_host/pnacl_file_host.cc
@@ -4,13 +4,18 @@
#include "chrome/browser/nacl_host/pnacl_file_host.h"
+#include <iostream>
+
#include "base/bind.h"
+#include "base/callback.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/memory/ref_counted.h"
#include "base/path_service.h"
#include "base/platform_file.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h"
#include "chrome/browser/renderer_host/chrome_render_message_filter.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/render_messages.h"
@@ -49,13 +54,59 @@ bool PnaclDoOpenFile(const base::FilePath& file_to_open,
return true;
}
-void DoOpenPnaclFile(
- ChromeRenderMessageFilter* chrome_render_message_filter,
- const std::string& filename,
- IPC::Message* reply_msg) {
+void DoOpenPnaclFile(ChromeRenderMessageFilter* chrome_render_message_filter,
+ const std::string& filename,
+ IPC::Message* reply_msg);
+
+void PnaclCheckDone(ChromeRenderMessageFilter* chrome_render_message_filter,
+ const std::string& filename,
+ IPC::Message* reply_msg,
+ bool success) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (!success) {
+ NotifyRendererOfError(chrome_render_message_filter, reply_msg);
+ } else {
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&DoOpenPnaclFile,
+ make_scoped_refptr(chrome_render_message_filter),
+ filename,
+ reply_msg));
+ }
+}
+
+void TryInstallPnacl(ChromeRenderMessageFilter* chrome_render_message_filter,
+ const std::string& filename,
+ IPC::Message* reply_msg) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ ComponentUpdateService* cus = g_browser_process->component_updater();
+ CheckUpdatesForPnacl(cus,
+ base::Bind(&PnaclCheckDone,
+ make_scoped_refptr(
+ chrome_render_message_filter),
+ filename,
+ reply_msg));
+}
+
+void DoOpenPnaclFile(ChromeRenderMessageFilter* chrome_render_message_filter,
+ const std::string& filename,
+ IPC::Message* reply_msg) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- base::FilePath full_filepath;
+ // PNaCl must be installed.
+ base::FilePath pnacl_dir;
+ if (!PathService::Get(chrome::DIR_PNACL_COMPONENT, &pnacl_dir) ||
+ !file_util::PathExists(pnacl_dir)) {
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&TryInstallPnacl,
+ make_scoped_refptr(chrome_render_message_filter),
+ filename,
+ reply_msg));
+ return;
+ }
+
+ FilePath full_filepath;
// Do some validation.
if (!pnacl_file_host::PnaclCanOpenFile(filename, &full_filepath)) {
NotifyRendererOfError(chrome_render_message_filter, reply_msg);
« no previous file with comments | « chrome/browser/component_updater/pnacl/pnacl_component_installer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698