diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-13 09:29:17 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-13 09:29:17 +0000 |
commit | 4d225de1816cceef6be266d5253e420341f3f4c9 (patch) | |
tree | 5f047e9d851c4af5da8453d3bdc047851ef30860 /chrome | |
parent | 2a5f3f55076eb774be0aa57c8786f2c6e7612d0b (diff) | |
download | chromium_src-4d225de1816cceef6be266d5253e420341f3f4c9.zip chromium_src-4d225de1816cceef6be266d5253e420341f3f4c9.tar.gz chromium_src-4d225de1816cceef6be266d5253e420341f3f4c9.tar.bz2 |
Remove GetDefaultProfile() from c/b/cros/file_manager.
This is a part of the effort to get rid of GetDefaultProfile()
that doesn't make nice sense in multi-profiled Chrome OS.
This CL adds Profile* parameter to functions in platform_util.h,
which is the source of all the call site of GetDefaultProfile
in file_manager code.
BUG=322682
Review URL: https://codereview.chromium.org/104503008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240571 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chromeos/extensions/file_manager/event_router.cc | 4 | ||||
-rw-r--r-- | chrome/browser/chromeos/file_manager/open_util.cc | 17 | ||||
-rw-r--r-- | chrome/browser/chromeos/file_manager/open_util.h | 8 | ||||
-rw-r--r-- | chrome/browser/download/chrome_download_manager_delegate.cc | 4 | ||||
-rw-r--r-- | chrome/browser/download/download_status_updater_win.cc | 1 | ||||
-rw-r--r-- | chrome/browser/extensions/api/downloads/downloads_api.cc | 5 | ||||
-rw-r--r-- | chrome/browser/platform_util.h | 6 | ||||
-rw-r--r-- | chrome/browser/platform_util_android.cc | 4 | ||||
-rw-r--r-- | chrome/browser/platform_util_chromeos.cc | 8 | ||||
-rw-r--r-- | chrome/browser/platform_util_linux.cc | 4 | ||||
-rw-r--r-- | chrome/browser/platform_util_mac.mm | 4 | ||||
-rw-r--r-- | chrome/browser/platform_util_win.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/ash/screenshot_taker.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/webui/downloads_dom_handler.cc | 8 |
14 files changed, 43 insertions, 36 deletions
diff --git a/chrome/browser/chromeos/extensions/file_manager/event_router.cc b/chrome/browser/chromeos/extensions/file_manager/event_router.cc index 36bfbe8..fd1296f 100644 --- a/chrome/browser/chromeos/extensions/file_manager/event_router.cc +++ b/chrome/browser/chromeos/extensions/file_manager/event_router.cc @@ -634,8 +634,8 @@ void EventRouter::ShowRemovableDeviceInFileManager( dcim_path, IsGooglePhotosInstalled(profile_) ? base::Bind(&base::DoNothing) : - base::Bind(&util::OpenRemovableDrive, mount_path), - base::Bind(&util::OpenRemovableDrive, mount_path)); + base::Bind(&util::OpenRemovableDrive, profile_, mount_path), + base::Bind(&util::OpenRemovableDrive, profile_, mount_path)); } void EventRouter::OnDiskAdded( diff --git a/chrome/browser/chromeos/file_manager/open_util.cc b/chrome/browser/chromeos/file_manager/open_util.cc index b4f9cc1..825f56a 100644 --- a/chrome/browser/chromeos/file_manager/open_util.cc +++ b/chrome/browser/chromeos/file_manager/open_util.cc @@ -111,14 +111,14 @@ void ExecuteFileTaskForUrl(Profile* profile, // the file manager when the removal drive is unmounted. // "select" - Open the file manager for the given file. The folder containing // the file will be opened with the file selected. -void OpenFileManagerWithInternalActionId(const base::FilePath& file_path, +void OpenFileManagerWithInternalActionId(Profile* profile, + const base::FilePath& file_path, const std::string& action_id) { DCHECK(action_id == "auto-open" || action_id == "open" || action_id == "select"); content::RecordAction(UserMetricsAction("ShowFileBrowserFullTab")); - Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); GURL url; if (!ConvertAbsoluteFilePathToFileSystemUrl( @@ -179,7 +179,7 @@ void ContinueOpenItem(Profile* profile, if (error == base::PLATFORM_FILE_OK) { // A directory exists at |file_path|. Open it with the file manager. - OpenFileManagerWithInternalActionId(file_path, "open"); + OpenFileManagerWithInternalActionId(profile, file_path, "open"); } else { // |file_path| should be a file. Open it. if (!OpenFile(profile, file_path)) @@ -216,14 +216,13 @@ void CheckIfDirectoryExists( } // namespace -void OpenRemovableDrive(const base::FilePath& file_path) { - OpenFileManagerWithInternalActionId(file_path, "auto-open"); +void OpenRemovableDrive(Profile* profile, const base::FilePath& file_path) { + OpenFileManagerWithInternalActionId(profile, file_path, "auto-open"); } -void OpenItem(const base::FilePath& file_path) { +void OpenItem(Profile* profile, const base::FilePath& file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); GURL url; if (!ConvertAbsoluteFilePathToFileSystemUrl( profile, file_path, kFileManagerAppId, &url) || @@ -240,9 +239,9 @@ void OpenItem(const base::FilePath& file_path) { base::Bind(&ContinueOpenItem, profile, file_path)); } -void ShowItemInFolder(const base::FilePath& file_path) { +void ShowItemInFolder(Profile* profile, const base::FilePath& file_path) { // This action changes the selection so we do not reuse existing tabs. - OpenFileManagerWithInternalActionId(file_path, "select"); + OpenFileManagerWithInternalActionId(profile, file_path, "select"); } } // namespace util diff --git a/chrome/browser/chromeos/file_manager/open_util.h b/chrome/browser/chromeos/file_manager/open_util.h index 31c8c60..e590041 100644 --- a/chrome/browser/chromeos/file_manager/open_util.h +++ b/chrome/browser/chromeos/file_manager/open_util.h @@ -8,6 +8,8 @@ #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_OPEN_UTIL_H_ #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_OPEN_UTIL_H_ +class Profile; + namespace base { class FilePath; } @@ -23,18 +25,18 @@ namespace util { // If there is no file manager open, this call opens a new one pointing to // |file_path|. In this case the tab will automatically close on |file_path| // unmount. -void OpenRemovableDrive(const base::FilePath& file_path); +void OpenRemovableDrive(Profile* profile, const base::FilePath& file_path); // Opens an item (file or directory). If the target is a directory, the // directory will be opened in the file manager. If the target is a file, the // file will be opened using a file handler, a file browser handler, or the // browser (open in a tab). The default handler has precedence over other // handlers, if defined for the type of the target file. -void OpenItem(const base::FilePath& file_path); +void OpenItem(Profile* profile, const base::FilePath& file_path); // Opens the file manager for the folder containing the item specified by // |file_path|, with the item selected. -void ShowItemInFolder(const base::FilePath& file_path); +void ShowItemInFolder(Profile* profile, const base::FilePath& file_path); } // namespace util } // namespace file_manager diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc index 2f59821..0d1c0c5 100644 --- a/chrome/browser/download/chrome_download_manager_delegate.cc +++ b/chrome/browser/download/chrome_download_manager_delegate.cc @@ -427,7 +427,7 @@ void ChromeDownloadManagerDelegate::OpenDownloadUsingPlatformHandler( base::FilePath platform_path( GetPlatformDownloadPath(profile_, download, PLATFORM_TARGET_PATH)); DCHECK(!platform_path.empty()); - platform_util::OpenItem(platform_path); + platform_util::OpenItem(profile_, platform_path); } void ChromeDownloadManagerDelegate::OpenDownload(DownloadItem* download) { @@ -474,7 +474,7 @@ void ChromeDownloadManagerDelegate::ShowDownloadInShell( base::FilePath platform_path( GetPlatformDownloadPath(profile_, download, PLATFORM_CURRENT_PATH)); DCHECK(!platform_path.empty()); - platform_util::ShowItemInFolder(platform_path); + platform_util::ShowItemInFolder(profile_, platform_path); } void ChromeDownloadManagerDelegate::CheckForFileExistence( diff --git a/chrome/browser/download/download_status_updater_win.cc b/chrome/browser/download/download_status_updater_win.cc index f8587ed..f63808a 100644 --- a/chrome/browser/download/download_status_updater_win.cc +++ b/chrome/browser/download/download_status_updater_win.cc @@ -76,6 +76,7 @@ void MetroDownloadNotificationClickedHandler(const wchar_t* download_path) { // UI thread. content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, base::Bind(platform_util::ShowItemInFolder, + static_cast<Profile*>(NULL), base::FilePath(download_path))); } diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc index 999b2a1..fab0dd1 100644 --- a/chrome/browser/extensions/api/downloads/downloads_api.cc +++ b/chrome/browser/extensions/api/downloads/downloads_api.cc @@ -1351,8 +1351,9 @@ bool DownloadsShowDefaultFolderFunction::RunImpl() { DownloadManager* manager = NULL; DownloadManager* incognito_manager = NULL; GetManagers(GetProfile(), include_incognito(), &manager, &incognito_manager); - platform_util::OpenItem(DownloadPrefs::FromDownloadManager( - manager)->DownloadPath()); + platform_util::OpenItem( + GetProfile(), + DownloadPrefs::FromDownloadManager(manager)->DownloadPath()); RecordApiFunctions(DOWNLOADS_FUNCTION_SHOW_DEFAULT_FOLDER); return true; } diff --git a/chrome/browser/platform_util.h b/chrome/browser/platform_util.h index c2008a1..916f3a3 100644 --- a/chrome/browser/platform_util.h +++ b/chrome/browser/platform_util.h @@ -20,12 +20,14 @@ class FilePath; namespace platform_util { // Show the given file in a file manager. If possible, select the file. +// The |profile| is used to determine the running profile of file manager app +// in Chrome OS only. Not used in other platforms. // Must be called from the UI thread. -void ShowItemInFolder(const base::FilePath& full_path); +void ShowItemInFolder(Profile* profile, const base::FilePath& full_path); // Open the given file in the desktop's default manner. // Must be called from the UI thread. -void OpenItem(const base::FilePath& full_path); +void OpenItem(Profile* profile, const base::FilePath& full_path); // Open the given external protocol URL in the desktop's default manner. // (For example, mailto: URLs in the default mail user agent.) diff --git a/chrome/browser/platform_util_android.cc b/chrome/browser/platform_util_android.cc index 935bc3a..143d313 100644 --- a/chrome/browser/platform_util_android.cc +++ b/chrome/browser/platform_util_android.cc @@ -10,11 +10,11 @@ namespace platform_util { // TODO: crbug/115682 to track implementation of the following methods. -void ShowItemInFolder(const base::FilePath& full_path) { +void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) { NOTIMPLEMENTED(); } -void OpenItem(const base::FilePath& full_path) { +void OpenItem(Profile* profile, const base::FilePath& full_path) { NOTIMPLEMENTED(); } diff --git a/chrome/browser/platform_util_chromeos.cc b/chrome/browser/platform_util_chromeos.cc index 8824183..fc1a476 100644 --- a/chrome/browser/platform_util_chromeos.cc +++ b/chrome/browser/platform_util_chromeos.cc @@ -20,14 +20,14 @@ const char kGmailComposeUrl[] = namespace platform_util { -void ShowItemInFolder(const base::FilePath& full_path) { +void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - file_manager::util::ShowItemInFolder(full_path); + file_manager::util::ShowItemInFolder(profile, full_path); } -void OpenItem(const base::FilePath& full_path) { +void OpenItem(Profile* profile, const base::FilePath& full_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - file_manager::util::OpenItem(full_path); + file_manager::util::OpenItem(profile, full_path); } void OpenExternal(Profile* profile, const GURL& url) { diff --git a/chrome/browser/platform_util_linux.cc b/chrome/browser/platform_util_linux.cc index 002acf0..27bb72b3 100644 --- a/chrome/browser/platform_util_linux.cc +++ b/chrome/browser/platform_util_linux.cc @@ -64,13 +64,13 @@ void ShowItemInFolderOnFileThread(const base::FilePath& full_path) { namespace platform_util { -void ShowItemInFolder(const base::FilePath& full_path) { +void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind(&ShowItemInFolderOnFileThread, full_path)); } -void OpenItem(const base::FilePath& full_path) { +void OpenItem(Profile* profile, const base::FilePath& full_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind(&XDGOpen, full_path.value())); diff --git a/chrome/browser/platform_util_mac.mm b/chrome/browser/platform_util_mac.mm index 6741519..b6df240 100644 --- a/chrome/browser/platform_util_mac.mm +++ b/chrome/browser/platform_util_mac.mm @@ -20,7 +20,7 @@ namespace platform_util { -void ShowItemInFolder(const base::FilePath& full_path) { +void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) { DCHECK([NSThread isMainThread]); NSString* path_string = base::SysUTF8ToNSString(full_path.value()); if (!path_string || ![[NSWorkspace sharedWorkspace] selectFile:path_string @@ -35,7 +35,7 @@ void ShowItemInFolder(const base::FilePath& full_path) { // 2. Silent no-op for unassociated file types: http://crbug.com/50263 // Instead, an AppleEvent is constructed to tell the Finder to open the // document. -void OpenItem(const base::FilePath& full_path) { +void OpenItem(Profile* profile, const base::FilePath& full_path) { DCHECK([NSThread isMainThread]); NSString* path_string = base::SysUTF8ToNSString(full_path.value()); if (!path_string) diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc index 38ecb39..567fa15 100644 --- a/chrome/browser/platform_util_win.cc +++ b/chrome/browser/platform_util_win.cc @@ -166,7 +166,7 @@ void OpenExternalOnFileThread(const GURL& url) { namespace platform_util { -void ShowItemInFolder(const base::FilePath& full_path) { +void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) @@ -176,7 +176,7 @@ void ShowItemInFolder(const base::FilePath& full_path) { base::Bind(&ShowItemInFolderOnFileThread, full_path)); } -void OpenItem(const base::FilePath& full_path) { +void OpenItem(Profile* profile, const base::FilePath& full_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) diff --git a/chrome/browser/ui/ash/screenshot_taker.cc b/chrome/browser/ui/ash/screenshot_taker.cc index 77922b9..02cb64d 100644 --- a/chrome/browser/ui/ash/screenshot_taker.cc +++ b/chrome/browser/ui/ash/screenshot_taker.cc @@ -138,7 +138,7 @@ class ScreenshotTakerNotificationDelegate : public NotificationDelegate { if (!success_) return; #if defined(OS_CHROMEOS) - file_manager::util::ShowItemInFolder(screenshot_path_); + file_manager::util::ShowItemInFolder(profile_, screenshot_path_); #else // TODO(sschmitz): perhaps add similar action for Windows. #endif diff --git a/chrome/browser/ui/webui/downloads_dom_handler.cc b/chrome/browser/ui/webui/downloads_dom_handler.cc index 77f3c31..70b6f90 100644 --- a/chrome/browser/ui/webui/downloads_dom_handler.cc +++ b/chrome/browser/ui/webui/downloads_dom_handler.cc @@ -468,9 +468,11 @@ void DownloadsDOMHandler::HandleClearAll(const base::ListValue* args) { void DownloadsDOMHandler::HandleOpenDownloadsFolder( const base::ListValue* args) { CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_OPEN_FOLDER); - if (main_notifier_.GetManager()) { - platform_util::OpenItem(DownloadPrefs::FromDownloadManager( - main_notifier_.GetManager())->DownloadPath()); + content::DownloadManager* manager = main_notifier_.GetManager(); + if (manager) { + platform_util::OpenItem( + Profile::FromBrowserContext(manager->GetBrowserContext()), + DownloadPrefs::FromDownloadManager(manager)->DownloadPath()); } } |