When "Search file contents" is selected the file names are ignored
A separate option should exist for excluding file names from the search, such as "Exclude filenames". As for what to do when both are excluded and a search is attempted you can just display a message saying something along the lines of "You must choose to search filenames and/or file contents before performing a search"
Edit: alternatively the option could be called "Search filenames" and be on by default so that it matches the labeling of the "Search file contents" option.
Edited by John Doe