The Shulhan Aruch (276:1) rules that a Jew may benefit from a Melacha performed by a non-Jew only if it was done for the non-Jew’s own benefit. If the non-Jew did it for the Jew, no Jew may benefit from the act. In the following Halacha, Maran deals with a case in which a non-Jew does a Melacha, such as turning on the light, in the presence of a mixed group of Jews and non-Jews. In such a case, how does one determine for whom the non-Jew turned on the light? The Halacha provides a formula, by which, if the majority of those present are non-Jews, then it is assumed his intent was for them, and therefore Jews may benefit from the light. If the majority are Jews, it is assumed the Melacha was done on their behalf. Even if the group was "half-half," the Halacha is stringent and assumes the Melacha was done for the Jews.
This principle applies only to a case where the non-Jew’s intent was unclear. However, in case where his intent was apparent, this formula does not apply. For example, in a case where the majority of those present are Jews, but the non-Jew turns on the light and immediately takes out reading material and begins to read, it is clear that his intent was for himself, and therefore the Jews may benefit from his act.
SUMMARY
If a non-Jew turns on a light in the company of Jews and non-Jews, it is permitted for Jews to benefit from the light only if the majority of those present are non-Jews or the non-Jew clearly did so for his own benefit.