Skip to content

Commit

Permalink
add CHECK guardrail and a cleaner conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathansampson committed Dec 11, 2024
1 parent ae42b4e commit 6313441
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions components/ai_chat/renderer/page_text_distilling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void DistillPageTextViaSiteScript(
std::string_view script_content,
int32_t world_id,
base::OnceCallback<void(const std::optional<std::string>&)> callback) {
CHECK(ai_chat::features::IsCustomSiteDistillerScriptsEnabled());
CHECK(ai_chat::features::IsCustomSiteDistillerScriptsEnabled());
// TODO (jonathansampson): Wrap scripts at build/transpile-time instead
std::string script = absl::StrFormat(
R"((()=> {
Expand All @@ -248,10 +248,9 @@ void DistillPageTextViaSiteScript(
std::optional<base::Value> value, base::TimeTicks start_time) {
if (value && value->is_string() && !value->GetString().empty()) {
std::move(callback).Run(value->GetString());
return;
} else {
std::move(callback).Run({});
}

std::move(callback).Run({});
};

// Execute the combined script as a single source
Expand Down

0 comments on commit 6313441

Please sign in to comment.