From 38a5a94af83f5feb6aaee50dabc40ba7034b863f Mon Sep 17 00:00:00 2001 From: "evan@chromium.org" Date: Mon, 2 Nov 2009 18:58:32 +0000 Subject: Use FilePath in JumpList. BUG=24672 TEST=Compiles Patch by Thiago Farina . Review URL: http://codereview.chromium.org/348035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30727 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/jumplist.cc | 29 ++++++++++++++--------------- chrome/browser/jumplist.h | 3 ++- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/jumplist.cc b/chrome/browser/jumplist.cc index 1af060b..4c55224 100644 --- a/chrome/browser/jumplist.cc +++ b/chrome/browser/jumplist.cc @@ -239,13 +239,13 @@ HRESULT AddShellLink(ScopedComPtr collection, // Creates a temporary icon file to be shown in JumpList. bool CreateIconFile(const SkBitmap& bitmap, - const std::wstring& icon_dir, - std::wstring* icon_path) { + const FilePath& icon_dir, + FilePath* icon_path) { // Retrieve the path to a temporary file. // We don't have to care about the extension of this temporary file because // JumpList does not care about it. FilePath path; - if (!file_util::CreateTemporaryFileInDir(FilePath(icon_dir), &path)) + if (!file_util::CreateTemporaryFileInDir(icon_dir, &path)) return false; // Create an icon file from the favicon attached to the given |page|, and @@ -255,7 +255,7 @@ bool CreateIconFile(const SkBitmap& bitmap, // Add this icon file to the list and return its absolute path. // The IShellLink::SetIcon() function needs the absolute path to an icon. - icon_path->assign(path.value()); + *icon_path = path; return true; } @@ -458,7 +458,7 @@ bool UpdateJumpList(const ShellLinkItemList& most_visited_pages, // 3. Post this task to the file thread. class JumpListUpdateTask : public Task { public: - JumpListUpdateTask(const std::wstring& icon_dir, + JumpListUpdateTask(const FilePath& icon_dir, const ShellLinkItemList& most_visited_pages, const ShellLinkItemList& recently_closed_pages) : icon_dir_(icon_dir), @@ -472,7 +472,7 @@ class JumpListUpdateTask : public Task { void Run(); // The directory which contains JumpList icons. - std::wstring icon_dir_; + FilePath icon_dir_; // Items in the "Most Visited" category of the application JumpList. ShellLinkItemList most_visited_pages_; @@ -485,11 +485,10 @@ void JumpListUpdateTask::Run() { // Delete the directory which contains old icon files, rename the current // icon directory, and create a new directory which contains new JumpList // icon files. - std::wstring icon_dir_old(icon_dir_ + L"Old"); - if (file_util::PathExists(FilePath::FromWStringHack(icon_dir_old))) + FilePath icon_dir_old(icon_dir_.value() + L"Old"); + if (file_util::PathExists(icon_dir_old)) file_util::Delete(icon_dir_old, true); - file_util::Move(FilePath::FromWStringHack(icon_dir_), - FilePath::FromWStringHack(icon_dir_old)); + file_util::Move(icon_dir_, icon_dir_old); file_util::CreateDirectory(icon_dir_); // Create temporary icon files for shortcuts in the "Most Visited" category. @@ -500,9 +499,9 @@ void JumpListUpdateTask::Run() { gfx::PNGCodec::Decode((*item)->data()->front(), (*item)->data()->size(), &icon_bitmap)) { - std::wstring icon_path; + FilePath icon_path; if (CreateIconFile(icon_bitmap, icon_dir_, &icon_path)) - (*item)->SetIcon(icon_path, 0, true); + (*item)->SetIcon(icon_path.value(), 0, true); } } @@ -515,9 +514,9 @@ void JumpListUpdateTask::Run() { gfx::PNGCodec::Decode((*item)->data()->front(), (*item)->data()->size(), &icon_bitmap)) { - std::wstring icon_path; + FilePath icon_path; if (CreateIconFile(icon_bitmap, icon_dir_, &icon_path)) - (*item)->SetIcon(icon_path, 0, true); + (*item)->SetIcon(icon_path.value(), 0, true); } } @@ -561,7 +560,7 @@ bool JumpList::AddObserver(Profile* profile) { if (!tab_restore_service) return false; - icon_dir_ = profile->GetPath().Append(chrome::kJumpListIconDirname).value(); + icon_dir_ = profile->GetPath().Append(chrome::kJumpListIconDirname); profile_ = profile; tab_restore_service->AddObserver(this); return true; diff --git a/chrome/browser/jumplist.h b/chrome/browser/jumplist.h index 0a8fbb2..ed28eed 100644 --- a/chrome/browser/jumplist.h +++ b/chrome/browser/jumplist.h @@ -15,6 +15,7 @@ #include "chrome/browser/history/history.h" #include "chrome/browser/sessions/tab_restore_service.h" +class FilePath; class Profile; class PageUsageData; @@ -170,7 +171,7 @@ class JumpList : public TabRestoreService::Observer { Profile* profile_; // The directory which contains JumpList icons. - std::wstring icon_dir_; + FilePath icon_dir_; // Items in the "Most Visited" category of the application JumpList. ShellLinkItemList most_visited_pages_; -- cgit v1.1