--- a/components/pdf/browser/pdf_document_helper_client.h
+++ b/components/pdf/browser/pdf_document_helper_client.h
@@ -4,6 +4,8 @@
 
 #ifndef COMPONENTS_PDF_BROWSER_PDF_DOCUMENT_HELPER_CLIENT_H_
 #define COMPONENTS_PDF_BROWSER_PDF_DOCUMENT_HELPER_CLIENT_H_
+
+#include "services/screen_ai/buildflags/buildflags.h"
 
 namespace content {
 class RenderFrameHost;
@@ -35,10 +37,11 @@
   // Lets the client observe scroll events. Only used for testing.
   virtual void OnDidScroll(const gfx::SelectionBound& start,
                            const gfx::SelectionBound& end) {}
-
+#if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
   // See the comment for `OnSearchifyStateChange` in pdf/pdf.mojom.
   virtual void OnSearchifyStateChange(bool busy,
                                       content::WebContents* contents) = 0;
+#endif
 };
 
 }  // namespace pdf

