From c90786f5aa8c695ad9077a613f8c58a057c6fbba Mon Sep 17 00:00:00 2001 From: Jan Rucka Date: Mon, 13 Feb 2017 13:40:23 +0100 Subject: [PATCH] chrome.history.addUrl - optional title attribute added --- chrome/browser/extensions/api/history/history_api.cc | 7 +++++++ chrome/common/extensions/api/history.json | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/chrome/browser/extensions/api/history/history_api.cc b/chrome/browser/extensions/api/history/history_api.cc index 9d0441493caa1..8db7f35c620e0 100644 --- a/chrome/browser/extensions/api/history/history_api.cc +++ b/chrome/browser/extensions/api/history/history_api.cc @@ -351,10 +351,17 @@ bool HistoryAddUrlFunction::RunAsync() { if (!ValidateUrl(params->details.url, &url)) return false; + base::string16 title; + if (params->details.title.get()) + title = base::UTF8ToUTF16(*params->details.title); + history::HistoryService* hs = HistoryServiceFactory::GetForProfile( GetProfile(), ServiceAccessType::EXPLICIT_ACCESS); hs->AddPage(url, base::Time::Now(), history::SOURCE_EXTENSION); + if (!title.empty()) + hs->SetPageTitle(url, title); + SendResponse(true); return true; } diff --git a/chrome/common/extensions/api/history.json b/chrome/common/extensions/api/history.json index 2eb7044ad3b7f..994aefd5b01ee 100644 --- a/chrome/common/extensions/api/history.json +++ b/chrome/common/extensions/api/history.json @@ -97,7 +97,8 @@ "name": "details", "type": "object", "properties": { - "url": {"type": "string", "description": "The URL to add."} + "url": {"type": "string", "description": "The URL to add."}, + "title": {"type": "string", "optional": true, "description": "The title of URL to add."} } }, {