Commit 89df1e83 authored by vandebo@chromium.org's avatar vandebo@chromium.org

Enable gallery watches on Mac

Resubmit of https://codereview.chromium.org/332003002

BUG=144491

Review URL: https://codereview.chromium.org/340543002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277871 0039d316-1c4b-4281-b951-d872f2087c98
parent 593ae88a
...@@ -92,15 +92,12 @@ GalleryWatchStateTracker::~GalleryWatchStateTracker() { ...@@ -92,15 +92,12 @@ GalleryWatchStateTracker::~GalleryWatchStateTracker() {
GalleryWatchStateTracker* GalleryWatchStateTracker::GetForProfile( GalleryWatchStateTracker* GalleryWatchStateTracker::GetForProfile(
Profile* profile) { Profile* profile) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
#if defined(OS_WIN) || defined(OS_LINUX)
// Gallery watch operation is not supported on Mac: crbug.com/144491.
DCHECK(profile); DCHECK(profile);
MediaGalleriesPrivateAPI* private_api = MediaGalleriesPrivateAPI* private_api =
MediaGalleriesPrivateAPI::Get(profile); MediaGalleriesPrivateAPI::Get(profile);
// In unit tests, we don't have a MediaGalleriesPrivateAPI. // In unit tests, we don't have a MediaGalleriesPrivateAPI.
if (private_api) if (private_api)
return private_api->GetGalleryWatchStateTracker(); return private_api->GetGalleryWatchStateTracker();
#endif
return NULL; return NULL;
} }
......
...@@ -192,7 +192,6 @@ void MediaGalleriesPrivateAddGalleryWatchFunction::OnPreferencesInit( ...@@ -192,7 +192,6 @@ void MediaGalleriesPrivateAddGalleryWatchFunction::OnPreferencesInit(
return; return;
} }
#if defined(OS_WIN) || defined(OS_LINUX)
MediaGalleriesPrivateEventRouter* router = MediaGalleriesPrivateEventRouter* router =
MediaGalleriesPrivateAPI::Get(GetProfile())->GetEventRouter(); MediaGalleriesPrivateAPI::Get(GetProfile())->GetEventRouter();
DCHECK(router); DCHECK(router);
...@@ -208,11 +207,6 @@ void MediaGalleriesPrivateAddGalleryWatchFunction::OnPreferencesInit( ...@@ -208,11 +207,6 @@ void MediaGalleriesPrivateAddGalleryWatchFunction::OnPreferencesInit(
base::Bind(&MediaGalleriesPrivateAddGalleryWatchFunction::HandleResponse, base::Bind(&MediaGalleriesPrivateAddGalleryWatchFunction::HandleResponse,
this, this,
gallery_pref_id)); gallery_pref_id));
#else
// Recursive gallery watch operation is not currently supported on Mac:
// crbug.com/144491
HandleResponse(gallery_pref_id, false);
#endif
} }
void MediaGalleriesPrivateAddGalleryWatchFunction::HandleResponse( void MediaGalleriesPrivateAddGalleryWatchFunction::HandleResponse(
...@@ -248,8 +242,6 @@ bool MediaGalleriesPrivateRemoveGalleryWatchFunction::RunAsync() { ...@@ -248,8 +242,6 @@ bool MediaGalleriesPrivateRemoveGalleryWatchFunction::RunAsync() {
if (!render_view_host() || !render_view_host()->GetProcess()) if (!render_view_host() || !render_view_host()->GetProcess())
return false; return false;
// Remove gallery watch operation is currently supported on Mac:
// crbug.com/144491
scoped_ptr<RemoveGalleryWatch::Params> params( scoped_ptr<RemoveGalleryWatch::Params> params(
RemoveGalleryWatch::Params::Create(*args_)); RemoveGalleryWatch::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get()); EXTENSION_FUNCTION_VALIDATE(params.get());
...@@ -266,7 +258,6 @@ bool MediaGalleriesPrivateRemoveGalleryWatchFunction::RunAsync() { ...@@ -266,7 +258,6 @@ bool MediaGalleriesPrivateRemoveGalleryWatchFunction::RunAsync() {
void MediaGalleriesPrivateRemoveGalleryWatchFunction::OnPreferencesInit( void MediaGalleriesPrivateRemoveGalleryWatchFunction::OnPreferencesInit(
const std::string& pref_id) { const std::string& pref_id) {
#if defined(OS_WIN) || defined(OS_LINUX)
base::FilePath gallery_file_path; base::FilePath gallery_file_path;
MediaGalleryPrefId gallery_pref_id = 0; MediaGalleryPrefId gallery_pref_id = 0;
if (!GetGalleryFilePathAndId(pref_id, if (!GetGalleryFilePathAndId(pref_id,
...@@ -290,7 +281,6 @@ void MediaGalleriesPrivateRemoveGalleryWatchFunction::OnPreferencesInit( ...@@ -290,7 +281,6 @@ void MediaGalleriesPrivateRemoveGalleryWatchFunction::OnPreferencesInit(
GalleryWatchStateTracker* state_tracker = MediaGalleriesPrivateAPI::Get( GalleryWatchStateTracker* state_tracker = MediaGalleriesPrivateAPI::Get(
GetProfile())->GetGalleryWatchStateTracker(); GetProfile())->GetGalleryWatchStateTracker();
state_tracker->OnGalleryWatchRemoved(extension_id(), gallery_pref_id); state_tracker->OnGalleryWatchRemoved(extension_id(), gallery_pref_id);
#endif
SendResponse(true); SendResponse(true);
} }
...@@ -318,7 +308,6 @@ bool MediaGalleriesPrivateGetAllGalleryWatchFunction::RunAsync() { ...@@ -318,7 +308,6 @@ bool MediaGalleriesPrivateGetAllGalleryWatchFunction::RunAsync() {
void MediaGalleriesPrivateGetAllGalleryWatchFunction::OnPreferencesInit() { void MediaGalleriesPrivateGetAllGalleryWatchFunction::OnPreferencesInit() {
std::vector<std::string> result; std::vector<std::string> result;
#if defined(OS_WIN) || defined(OS_LINUX)
GalleryWatchStateTracker* state_tracker = MediaGalleriesPrivateAPI::Get( GalleryWatchStateTracker* state_tracker = MediaGalleriesPrivateAPI::Get(
GetProfile())->GetGalleryWatchStateTracker(); GetProfile())->GetGalleryWatchStateTracker();
MediaGalleryPrefIdSet gallery_ids = MediaGalleryPrefIdSet gallery_ids =
...@@ -327,7 +316,6 @@ void MediaGalleriesPrivateGetAllGalleryWatchFunction::OnPreferencesInit() { ...@@ -327,7 +316,6 @@ void MediaGalleriesPrivateGetAllGalleryWatchFunction::OnPreferencesInit() {
iter != gallery_ids.end(); ++iter) { iter != gallery_ids.end(); ++iter) {
result.push_back(base::Uint64ToString(*iter)); result.push_back(base::Uint64ToString(*iter));
} }
#endif
results_ = GetAllGalleryWatch::Results::Create(result); results_ = GetAllGalleryWatch::Results::Create(result);
SendResponse(true); SendResponse(true);
} }
...@@ -355,7 +343,6 @@ bool MediaGalleriesPrivateRemoveAllGalleryWatchFunction::RunAsync() { ...@@ -355,7 +343,6 @@ bool MediaGalleriesPrivateRemoveAllGalleryWatchFunction::RunAsync() {
} }
void MediaGalleriesPrivateRemoveAllGalleryWatchFunction::OnPreferencesInit() { void MediaGalleriesPrivateRemoveAllGalleryWatchFunction::OnPreferencesInit() {
#if defined(OS_WIN) || defined(OS_LINUX)
MediaGalleriesPreferences* preferences = MediaGalleriesPreferences* preferences =
g_browser_process->media_file_system_registry()->GetPreferences( g_browser_process->media_file_system_registry()->GetPreferences(
GetProfile()); GetProfile());
...@@ -363,7 +350,6 @@ void MediaGalleriesPrivateRemoveAllGalleryWatchFunction::OnPreferencesInit() { ...@@ -363,7 +350,6 @@ void MediaGalleriesPrivateRemoveAllGalleryWatchFunction::OnPreferencesInit() {
GetProfile())->GetGalleryWatchStateTracker(); GetProfile())->GetGalleryWatchStateTracker();
state_tracker->RemoveAllGalleryWatchersForExtension( state_tracker->RemoveAllGalleryWatchersForExtension(
extension_id(), preferences); extension_id(), preferences);
#endif
SendResponse(true); SendResponse(true);
} }
......
...@@ -33,14 +33,14 @@ var getAllGalleryWatchCallback = function (results) { ...@@ -33,14 +33,14 @@ var getAllGalleryWatchCallback = function (results) {
if (results.length == 0) { if (results.length == 0) {
chrome.test.sendMessage('gallery_watchers_does_not_exists'); chrome.test.sendMessage('gallery_watchers_does_not_exists');
} else { } else {
var gallery_ids_str = ""; for (var i = 0; i < results.lendth; ++i) {
for (var i = 0; i < results.length; ++i) { var info = chrome.mediaGalleries.getMediaFileSystemMetadata(galleries[i]);
if (gallery_ids_str != "") if (results[i] !== info.galleryId) {
gallery_ids_str += ", "; chrome.test.sendMessage('gallery_watcher_mismatch');
gallery_ids_str += results[i]; return;
}
} }
chrome.test.sendMessage( chrome.test.sendMessage('gallery_watcher_checks');
'watchers_for_galleries_{' + gallery_ids_str + '}_found');
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment