How do I generate a pivoted CROSS JOIN where the resulting table definition is unknown?
Simple case, static SQL
The non-dynamic solution with crosstab() for the simple case:
SELECT * FROM crosstab(
  'SELECT b.x, f.name, f.x * b.x AS prod
   FROM   foo f, bar b
   ORDER  BY 1, 2'
   ) AS ct (x int, &quot;A&quot; int, &quot;B&quot; int, &quot;C&quot; int, &quot;D&quot; int, &quot;E&quot; int
                 , &quot;F&quot; int, &quot;G&quot; int, &quot;H&quot; int, &quot;I&quot; int, &quot;J&quot; int);

I order resulting columns by foo.name, not foo.x. Both happen to be sorted in parallel, but that's just the simple setup. Pick the right sort order for your case. The actual value of the second column is irrelevant in this query (1-parameter form of crosstab()).
We don't even need crosstab() with 2 parameters because there are no missing values by definition. See:

PostgreSQL Crosstab Query

(You fixed the crosstab query in the question by replacing foo with bar in a later edit. This also fixes the query, but keeps working with names from foo.)
Unknown return type, dynamic SQL
Column names and types cannot be dynamic. SQL demands to know number, names and types of resulting columns at call time. Either by explicit declaration or from information in the system catalogs (That's what happens with SELECT * FROM tbl: Postgres looks up the registered table definition.)
You want Postgres to derive resulting columns from data in a user table.  Not going to happen.
One way or the other, you need two round trips to the server. Either you create a cursor and then walk through it. Or you create a temp table and then select from it. Or you register a type and use it in the call.
Or you simply generate the query in one step and execute it in the next:
SELECT $$SELECT * FROM crosstab(
  'SELECT b.x, f.name, f.x * b.x AS prod
   FROM   foo f, bar b
   ORDER  BY 1, 2'
   ) AS ct (x int, $$
 || string_agg(quote_ident(name), ' int, ' ORDER BY name) || ' int)'
FROM   foo;

This generates the query above, dynamically. Execute it in the next step.
I am using dollar-quotes ($$) to keep handling of nested quotes simple. See:

Insert text with single quotes in PostgreSQL

quote_ident() is essential to escape otherwise illegal column names (and possibly defend against SQL injection).
Related:

PostgreSQL convert columns to rows? Transpose?
Dynamic alternative to pivot with CASE and GROUP BY