Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1733)

Unified Diff: chrome/browser/win/jumplist.cc

Issue 2846383002: Improve JumpList icon folders' naming style (Closed)
Patch Set: Merge branch 'master' of https://chromium.googlesource.com/chromium/src into updatejumplisticonsfol… Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/win/jumplist.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/win/jumplist.cc
diff --git a/chrome/browser/win/jumplist.cc b/chrome/browser/win/jumplist.cc
index cee078ad7f048d5d86baa0c0bf6a582024eda887..379ebf0e2b2b8d9d95303a90060e732d6a998d65 100644
--- a/chrome/browser/win/jumplist.cc
+++ b/chrome/browser/win/jumplist.cc
@@ -197,13 +197,23 @@ bool UpdateTaskCategory(
return jumplist_updater->AddTasks(items);
}
+// Returns the full path of the JumpListIcons[|suffix|] directory in
+// |profile_dir|.
+base::FilePath GenerateJumplistIconDirName(
+ const base::FilePath& profile_dir,
+ const base::FilePath::StringPieceType& suffix) {
+ base::FilePath::StringType dir_name(chrome::kJumpListIconDirname);
+ suffix.AppendToString(&dir_name);
+ return profile_dir.Append(dir_name);
+}
+
// Updates the application JumpList, which consists of 1) delete old icon files;
// 2) create new icon files; 3) notify the OS.
// Note that any timeout error along the way results in the old jumplist being
// left as-is, while any non-timeout error results in the old jumplist being
// left as-is, but without icon files.
bool UpdateJumpList(const wchar_t* app_id,
- const base::FilePath& icon_dir,
+ const base::FilePath& profile_dir,
const ShellLinkItemList& most_visited_pages,
const ShellLinkItemList& recently_closed_pages,
bool most_visited_pages_have_updates,
@@ -261,8 +271,8 @@ bool UpdateJumpList(const wchar_t* app_id,
// Update the icons for "Most Visisted" category of the JumpList if needed.
if (most_visited_pages_have_updates) {
- base::FilePath icon_dir_most_visited = icon_dir.DirName().Append(
- icon_dir.BaseName().value() + FILE_PATH_LITERAL("MostVisited"));
+ base::FilePath icon_dir_most_visited = GenerateJumplistIconDirName(
+ profile_dir, FILE_PATH_LITERAL("MostVisited"));
UpdateIconFiles(icon_dir_most_visited, most_visited_pages,
most_visited_items);
@@ -272,8 +282,8 @@ bool UpdateJumpList(const wchar_t* app_id,
// Update the icons for "Recently Closed" category of the JumpList if needed.
if (recently_closed_pages_have_updates) {
- base::FilePath icon_dir_recent_closed = icon_dir.DirName().Append(
- icon_dir.BaseName().value() + FILE_PATH_LITERAL("RecentClosed"));
+ base::FilePath icon_dir_recent_closed = GenerateJumplistIconDirName(
+ profile_dir, FILE_PATH_LITERAL("RecentClosed"));
UpdateIconFiles(icon_dir_recent_closed, recently_closed_pages,
recently_closed_items);
@@ -315,7 +325,7 @@ bool UpdateJumpList(const wchar_t* app_id,
// Updates the jumplist, once all the data has been fetched.
void RunUpdateJumpList(IncognitoModePrefs::Availability incognito_availability,
const std::wstring& app_id,
- const base::FilePath& icon_dir,
+ const base::FilePath& profile_dir,
base::RefCountedData<JumpListData>* ref_counted_data) {
JumpListData* data = &ref_counted_data->data;
ShellLinkItemList local_most_visited_pages;
@@ -350,7 +360,7 @@ void RunUpdateJumpList(IncognitoModePrefs::Availability incognito_availability,
// they were so that the corresponding JumpList categories will be tried to
// update again in the next run.
if (!UpdateJumpList(
- app_id.c_str(), icon_dir, local_most_visited_pages,
+ app_id.c_str(), profile_dir, local_most_visited_pages,
local_recently_closed_pages, most_visited_pages_have_updates,
recently_closed_pages_have_updates, incognito_availability)) {
base::AutoLock auto_lock(data->list_lock_);
@@ -394,7 +404,6 @@ JumpList::JumpList(Profile* profile)
app_id_ =
shell_integration::win::GetChromiumModelIdForProfile(profile_->GetPath());
- icon_dir_ = profile_->GetPath().Append(chrome::kJumpListIconDirname);
scoped_refptr<history::TopSites> top_sites =
TopSitesFactory::GetForProfile(profile_);
@@ -682,26 +691,34 @@ void JumpList::DeferredRunUpdate() {
DCHECK(CalledOnValidThread());
TRACE_EVENT0("browser", "JumpList::DeferredRunUpdate");
+ if (!profile_)
+ return;
+
+ base::FilePath profile_dir = profile_->GetPath();
+
// Check if incognito windows (or normal windows) are disabled by policy.
IncognitoModePrefs::Availability incognito_availability =
- profile_ ? IncognitoModePrefs::GetAvailability(profile_->GetPrefs())
- : IncognitoModePrefs::ENABLED;
+ IncognitoModePrefs::GetAvailability(profile_->GetPrefs());
// Post a task to update the JumpList, which consists of 1) delete old icons,
// 2) create new icons, 3) notify the OS.
update_jumplist_task_runner_->PostTask(
FROM_HERE, base::Bind(&RunUpdateJumpList, incognito_availability, app_id_,
- icon_dir_, base::RetainedRef(jumplist_data_)));
+ profile_dir, base::RetainedRef(jumplist_data_)));
// Post a task to delete JumpListIcons folder as it's no longer needed.
// Now we have JumpListIconsMostVisited folder and JumpListIconsRecentClosed
// folder instead.
+ base::FilePath icon_dir =
+ GenerateJumplistIconDirName(profile_dir, FILE_PATH_LITERAL(""));
+
delete_jumplisticons_task_runner_->PostTask(
- FROM_HERE, base::Bind(&DeleteDirectory, icon_dir_, kFileDeleteLimit));
+ FROM_HERE,
+ base::Bind(&DeleteDirectory, std::move(icon_dir), kFileDeleteLimit));
// Post a task to delete JumpListIconsOld folder as it's no longer needed.
- base::FilePath icon_dir_old = icon_dir_.DirName().Append(
- icon_dir_.BaseName().value() + FILE_PATH_LITERAL("Old"));
+ base::FilePath icon_dir_old =
+ GenerateJumplistIconDirName(profile_dir, FILE_PATH_LITERAL("Old"));
delete_jumplisticons_task_runner_->PostTask(
FROM_HERE,
« no previous file with comments | « chrome/browser/win/jumplist.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698