Include "public" source files in generated Xcode project.

Targets can restrict the list of public headers by using "public"
property in addition to "sources". Include them in the generated
Xcode project as any other source file.

BUG=None

Review-Url: https://codereview.chromium.org/2740123003
Cr-Original-Commit-Position: refs/heads/master@{#456339}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 5d93a97915ac8492667e3fbedfc26f606e1d1099
diff --git a/tools/gn/xcode_writer.cc b/tools/gn/xcode_writer.cc
index 41af628..8b96db4 100644
--- a/tools/gn/xcode_writer.cc
+++ b/tools/gn/xcode_writer.cc
@@ -404,7 +404,7 @@
       new PBXProject("products", config_name, source_path, attributes));
   SourceDir source_dir("//");
 
-  // Add all source files for indexing.
+  // Add all source files for indexing, both private and public.
   std::vector<SourceFile> sources;
   for (const Target* target : all_targets) {
     for (const SourceFile& source : target->sources()) {
@@ -413,6 +413,16 @@
 
       sources.push_back(source);
     }
+
+    if (target->all_headers_public())
+      continue;
+
+    for (const SourceFile& source : target->public_headers()) {
+      if (IsStringInOutputDir(build_settings->build_dir(), source.value()))
+        continue;
+
+      sources.push_back(source);
+    }
   }
 
   // Sort sources to ensure determinisn of the project file generation and