Skip to content

Commit 87e1d8e

Browse files
committed
chrome.history.addUrl - optional title attribute added
1 parent 5e7b9cd commit 87e1d8e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

chrome/browser/extensions/api/history/history_api.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,17 @@ ExtensionFunction::ResponseAction HistoryAddUrlFunction::Run() {
340340
if (!ValidateUrl(params->details.url, &url, &error))
341341
return RespondNow(Error(error));
342342

343+
base::string16 title;
344+
if (params->details.title.get())
345+
title = base::UTF8ToUTF16(*params->details.title);
346+
343347
history::HistoryService* hs = HistoryServiceFactory::GetForProfile(
344348
GetProfile(), ServiceAccessType::EXPLICIT_ACCESS);
345349
hs->AddPage(url, base::Time::Now(), history::SOURCE_EXTENSION);
346350

351+
if (!title.empty())
352+
hs->SetPageTitle(url, title);
353+
347354
return RespondNow(NoArguments());
348355
}
349356

chrome/common/extensions/api/history.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@
9797
"name": "details",
9898
"type": "object",
9999
"properties": {
100-
"url": {"type": "string", "description": "The URL to add."}
100+
"url": {"type": "string", "description": "The URL to add."},
101+
"title": {"type": "string", "optional": true, "description": "The title of URL to add."}
101102
}
102103
},
103104
{

0 commit comments

Comments
 (0)