Skip to content

Commit

Permalink
chrome.history.addUrl - optional title attribute added
Browse files Browse the repository at this point in the history
  • Loading branch information
janRucka committed Feb 13, 2017
1 parent e4f0eb0 commit c90786f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions chrome/browser/extensions/api/history/history_api.cc
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion chrome/common/extensions/api/history.json
Expand Up @@ -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."}
}
},
{
Expand Down

0 comments on commit c90786f

Please sign in to comment.