diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_resources.grd | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/preferences.cc | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/usb_mount_observer.cc | 5 | ||||
-rw-r--r-- | chrome/browser/dom_ui/filebrowse_ui.cc | 19 | ||||
-rw-r--r-- | chrome/browser/dom_ui/mediaplayer_browsertest.cc | 11 | ||||
-rw-r--r-- | chrome/browser/dom_ui/mediaplayer_ui.cc | 20 | ||||
-rw-r--r-- | chrome/browser/dom_ui/mediaplayer_ui.h | 3 | ||||
-rw-r--r-- | chrome/browser/resources/filebrowse.html | 232 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 11 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 2 |
10 files changed, 196 insertions, 111 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index 0604e7a..743bc41 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- This comment is only here because changes to resources are not picked up -without changes to the corresponding grd file. sew --> +without changes to the corresponding grd file. eadee --> <grit latest_public_release="0" current_release="1"> <outputs> <output filename="grit/browser_resources.h" type="rc_header"> diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc index c124913..1094b97 100644 --- a/chrome/browser/chromeos/preferences.cc +++ b/chrome/browser/chromeos/preferences.cc @@ -24,6 +24,8 @@ static const char kFallbackInputMethodLocale[] = "en-US"; // static void Preferences::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kTapToClickEnabled, false); + prefs->RegisterBooleanPref(prefs::kLabsMediaplayerEnabled, false); + prefs->RegisterBooleanPref(prefs::kLabsAdvancedFilesystemEnabled, false); prefs->RegisterBooleanPref(prefs::kAccessibilityEnabled, false); prefs->RegisterBooleanPref(prefs::kVertEdgeScrollEnabled, false); prefs->RegisterIntegerPref(prefs::kTouchpadSpeedFactor, 9); diff --git a/chrome/browser/chromeos/usb_mount_observer.cc b/chrome/browser/chromeos/usb_mount_observer.cc index 890b8af..d0e329f 100644 --- a/chrome/browser/chromeos/usb_mount_observer.cc +++ b/chrome/browser/chromeos/usb_mount_observer.cc @@ -8,6 +8,7 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/dom_ui/filebrowse_ui.h" +#include "chrome/browser/pref_service.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/url_constants.h" @@ -52,6 +53,10 @@ void USBMountObserver::OpenFileBrowse(const std::string& url, Browser* browser; Profile* profile; profile = BrowserList::GetLastActive()->profile(); + PrefService* pref_service = profile->GetPrefs(); + if (!pref_service->GetBoolean(prefs::kLabsAdvancedFilesystemEnabled)) { + return; + } if (small) { browser = FileBrowseUI::OpenPopup(profile, url, diff --git a/chrome/browser/dom_ui/filebrowse_ui.cc b/chrome/browser/dom_ui/filebrowse_ui.cc index 69d39bc..4010ed1 100644 --- a/chrome/browser/dom_ui/filebrowse_ui.cc +++ b/chrome/browser/dom_ui/filebrowse_ui.cc @@ -27,12 +27,14 @@ #include "chrome/browser/download/download_util.h" #include "chrome/browser/history/history_types.h" #include "chrome/browser/metrics/user_metrics.h" +#include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/dom_ui/mediaplayer_ui.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/net/url_fetcher.h" +#include "chrome/common/pref_names.h" #include "chrome/common/time_format.h" #include "chrome/common/url_constants.h" #include "net/base/escape.h" @@ -141,6 +143,7 @@ class FilebrowseHandler : public net::DirectoryLister::DirectoryListerDelegate, void HandleGetChildren(const Value* value); // Callback for the "refreshDirectory" message. void HandleRefreshDirectory(const Value* value); + void HandleIsAdvancedEnabled(const Value* value); // Callback for the "getMetadata" message. void HandleGetMetadata(const Value* value); @@ -429,6 +432,8 @@ void FilebrowseHandler::RegisterMessages() { NewCallback(this, &FilebrowseHandler::HandleAllowDownload)); dom_ui_->RegisterMessageCallback("refreshDirectory", NewCallback(this, &FilebrowseHandler::HandleRefreshDirectory)); + dom_ui_->RegisterMessageCallback("isAdvancedEnabled", + NewCallback(this, &FilebrowseHandler::HandleIsAdvancedEnabled)); } @@ -619,6 +624,20 @@ void FilebrowseHandler::EnqueueMediaFile(const Value* value) { #endif } +void FilebrowseHandler::HandleIsAdvancedEnabled(const Value* value) { +#if defined(OS_CHROMEOS) + Profile* profile = BrowserList::GetLastActive()->profile(); + PrefService* pref_service = profile->GetPrefs(); + bool is_enabled = pref_service->GetBoolean( + prefs::kLabsAdvancedFilesystemEnabled); + bool mp_enabled = pref_service->GetBoolean(prefs::kLabsMediaplayerEnabled); + DictionaryValue info_value; + info_value.SetBoolean(L"enabled", is_enabled); + info_value.SetBoolean(L"mpEnabled", mp_enabled); + dom_ui_->CallJavascriptFunction(L"enabledResult", + info_value); +#endif +} void FilebrowseHandler::HandleRefreshDirectory(const Value* value) { if (value && value->GetType() == Value::TYPE_LIST) { const ListValue* list_value = static_cast<const ListValue*>(value); diff --git a/chrome/browser/dom_ui/mediaplayer_browsertest.cc b/chrome/browser/dom_ui/mediaplayer_browsertest.cc index 92869ae..e2c582f 100644 --- a/chrome/browser/dom_ui/mediaplayer_browsertest.cc +++ b/chrome/browser/dom_ui/mediaplayer_browsertest.cc @@ -8,7 +8,9 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/dom_ui/mediaplayer_ui.h" +#include "chrome/browser/pref_service.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" @@ -62,6 +64,10 @@ IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, Popup) { // Doing this so we have a valid profile. ui_test_utils::NavigateToURL(browser(), GURL("chrome://downloads")); + + PrefService* pref_service = browser()->profile()->GetPrefs(); + pref_service->SetBoolean(prefs::kLabsMediaplayerEnabled, true); + MediaPlayer* player = MediaPlayer::Get(); // Check that its not currently visible ASSERT_FALSE(IsPlayerVisible()); @@ -76,6 +82,11 @@ IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, PopupPlaylist) { // Doing this so we have a valid profile. ui_test_utils::NavigateToURL(browser(), GURL("chrome://downloads")); + + + PrefService* pref_service = browser()->profile()->GetPrefs(); + pref_service->SetBoolean(prefs::kLabsMediaplayerEnabled, true); + MediaPlayer* player = MediaPlayer::Get(); player->EnqueueMediaURL(GetMusicTestURL(), NULL); diff --git a/chrome/browser/dom_ui/mediaplayer_ui.cc b/chrome/browser/dom_ui/mediaplayer_ui.cc index 9e08f6d..5cad6dc 100644 --- a/chrome/browser/dom_ui/mediaplayer_ui.cc +++ b/chrome/browser/dom_ui/mediaplayer_ui.cc @@ -26,11 +26,13 @@ #include "chrome/browser/download/download_util.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/history/history_types.h" +#include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/net/url_fetcher.h" +#include "chrome/common/pref_names.h" #include "chrome/common/time_format.h" #include "chrome/common/url_constants.h" #include "net/base/escape.h" @@ -86,7 +88,7 @@ class MediaplayerHandler : public DOMMessageHandler, struct MediaUrl { MediaUrl() {} - MediaUrl(const GURL& newurl) + explicit MediaUrl(const GURL& newurl) : url(newurl), haderror(false) {} GURL url; @@ -376,6 +378,9 @@ void MediaplayerHandler::HandleShowPlaylist(const Value* value) { DISABLE_RUNNABLE_METHOD_REFCOUNT(MediaPlayer); void MediaPlayer::EnqueueMediaURL(const GURL& url, Browser* creator) { + if (!Enabled()) { + return; + } if (handler_ == NULL) { unhandled_urls_.push_back(url); PopupMediaPlayer(creator); @@ -385,6 +390,9 @@ void MediaPlayer::EnqueueMediaURL(const GURL& url, Browser* creator) { } void MediaPlayer::ForcePlayMediaURL(const GURL& url, Browser* creator) { + if (!Enabled()) { + return; + } if (handler_ == NULL) { unhandled_urls_.push_back(url); PopupMediaPlayer(creator); @@ -393,6 +401,16 @@ void MediaPlayer::ForcePlayMediaURL(const GURL& url, Browser* creator) { } } +bool MediaPlayer::Enabled() { +#if defined(OS_CHROMEOS) + Profile* profile = BrowserList::GetLastActive()->profile(); + PrefService* pref_service = profile->GetPrefs(); + return pref_service->GetBoolean(prefs::kLabsMediaplayerEnabled); +#else + return true; +#endif +} + void MediaPlayer::TogglePlaylistWindowVisible() { if (playlist_browser_) { ClosePlaylistWindow(); diff --git a/chrome/browser/dom_ui/mediaplayer_ui.h b/chrome/browser/dom_ui/mediaplayer_ui.h index a34c39c..24e2585 100644 --- a/chrome/browser/dom_ui/mediaplayer_ui.h +++ b/chrome/browser/dom_ui/mediaplayer_ui.h @@ -101,6 +101,9 @@ class MediaPlayer : public NotificationObserver, // locations correctly. void PopupMediaPlayer(Browser* creator); + // Checks to see the the mediaplayer is currently enabled + bool Enabled(); + // Popup the playlist. Shows the browser, sets it up to point at // chrome://mediaplayer#playlist void PopupPlaylist(Browser* creator); diff --git a/chrome/browser/resources/filebrowse.html b/chrome/browser/resources/filebrowse.html index 963eb37..aca418a 100644 --- a/chrome/browser/resources/filebrowse.html +++ b/chrome/browser/resources/filebrowse.html @@ -604,11 +604,131 @@ var currentMenu = null; var mainColumn = null; var localStrings; var downloadList = []; - +var advancedEnabled = false; +var mediaPlayerEnabled = false; // strings var kPauseDownload; var kResumeDownload; +function enabledResult(info) { + advancedEnabled = info.enabled; + mediaPlayerEnabled = info.mpEnabled; + mainColumn = $('main'); + if (!advancedEnabled) { + $('back').style.display = 'none'; + } + if(document.documentElement.clientWidth <= 600) { + inFullMode = false; + if (chrome.dialogArguments) { + var args = JSON.parse(chrome.dialogArguments); + if (args.type == 'open') { + multiSelect = false; + selectFolder = false; + } else if (args.type == 'save') { + inSaveMode = true; + selectFolder = false; + } else if (args.type == 'open_multiple') { + multiSelect = true; + selectFolder = false; + } else if (args.type == 'folder') { + multiSelect = false; + selectFolder = true; + } else { + alert ('got unknown type' + args.type); + } + inSelectMode = true; + if (inSaveMode) { + var main = mainColumn; + main.className = 'containerwithsavebuttons'; + var savemenu = document.createElement('div'); + savemenu.className = 'savecontainer'; + + var savebutton = document.createElement('div'); + savebutton.id = 'savebutton'; + savebutton.className = 'filebutton openbutton disabled'; + savebutton.onclick = dialogSaveClick; + savebutton.textContent = localStrings.getString('save'); + savemenu.appendChild(savebutton); + + var cancelbutton = document.createElement('div'); + cancelbutton.className = 'filebutton cancelbutton'; + savemenu.appendChild(cancelbutton); + cancelbutton.textContent = localStrings.getString('confirmcancel'); + cancelbutton.onclick = dialogCancelClick; + + var filenameprompt = document.createElement('div'); + filenameprompt.className = 'filenameprompt'; + filenameprompt.textContent = localStrings.getString('filenameprompt'); + savemenu.appendChild(filenameprompt); + + var filename = document.createElement('input'); + filename.className = 'filename'; + filename.id = 'filename'; + filename.value = args.current_file; + savemenu.appendChild(filename); + if (advancedEnabled) { + var newfolderbutton = document.createElement('div'); + newfolderbutton.id = 'newfolderbutton'; + newfolderbutton.className = 'filebutton newfolderbutton disabled'; + newfolderbutton.textContent = localStrings.getString('newfolder'); + newfolderbutton.onclick = dialogNewFolderClick; + savemenu.appendChild(newfolderbutton); + } + document.body.appendChild(savemenu); + + } else { + var main = mainColumn; + main.className = 'containerwithopenbuttons'; + var openmenu = document.createElement('div'); + openmenu.className = 'opencontainer'; + var openbutton = document.createElement('div'); + openbutton.id = 'openbutton'; + openbutton.className = 'filebutton openbutton disabled'; + var cancelbutton = document.createElement('div'); + cancelbutton.className = 'filebutton cancelbutton'; + openmenu.appendChild(openbutton); + openbutton.onclick = dialogOkClick; + openmenu.appendChild(cancelbutton); + cancelbutton.onclick = dialogCancelClick; + openbutton.textContent = localStrings.getString('open'); + cancelbutton.textContent = localStrings.getString('confirmcancel'); + document.body.appendChild(openmenu); + } + } + } else { + var main = mainColumn; + main.className = 'fullcontainer'; + var innerContainer = document.createElement('div'); + innerContainer.className = 'container'; + innerContainer.id = 'inner'; + main.appendChild(innerContainer); + inFullMode = true; + $('back').style.display = 'none'; + } + + if (document.location.href.indexOf('#') != -1) { + var currentpathArray = document.location.href.split('#'); + var path = currentpathArray[1]; + if (path == 'scanningdevice') { + setUpForScanning(); + } else { + currentNode++; + currentSavedPath = path; + getDataForPath(path); + } + } else { + currentNode++; + if (advancedEnabled) { + currentSavedPath = 'roots'; + getDataForPath('roots'); + } else { + currentSavedPath = localStrings.getString('downloadpath'); + getDataForPath(currentSavedPath); + } + } + chrome.send("getDownloads", []); +} + function goBackInList() { currentNode--; if (currentSavedPath == localStrings.getString('downloadpath')) { @@ -1077,112 +1197,7 @@ function load() { localStrings = new LocalStrings(); kPauseDownload = localStrings.getString('pause'); kResumeDownload = localStrings.getString('resume'); - mainColumn = $('main'); - if(document.documentElement.clientWidth <= 600) { - inFullMode = false; - if (chrome.dialogArguments) { - var args = JSON.parse(chrome.dialogArguments); - if (args.type == 'open') { - multiSelect = false; - selectFolder = false; - } else if (args.type == 'save') { - inSaveMode = true; - selectFolder = false; - } else if (args.type == 'open_multiple') { - multiSelect = true; - selectFolder = false; - } else if (args.type == 'folder') { - multiSelect = false; - selectFolder = true; - } else { - alert ('got unknown type' + args.type); - } - inSelectMode = true; - if (inSaveMode) { - var main = mainColumn; - main.className = 'containerwithsavebuttons'; - var savemenu = document.createElement('div'); - savemenu.className = 'savecontainer'; - - var savebutton = document.createElement('div'); - savebutton.id = 'savebutton'; - savebutton.className = 'filebutton openbutton disabled'; - savebutton.onclick = dialogSaveClick; - savebutton.textContent = localStrings.getString('save'); - savemenu.appendChild(savebutton); - - var cancelbutton = document.createElement('div'); - cancelbutton.className = 'filebutton cancelbutton'; - savemenu.appendChild(cancelbutton); - cancelbutton.textContent = localStrings.getString('confirmcancel'); - cancelbutton.onclick = dialogCancelClick; - - var filenameprompt = document.createElement('div'); - filenameprompt.className = 'filenameprompt'; - filenameprompt.textContent = localStrings.getString('filenameprompt'); - savemenu.appendChild(filenameprompt); - - var filename = document.createElement('input'); - filename.className = 'filename'; - filename.id = 'filename'; - filename.value = args.current_file; - savemenu.appendChild(filename); - - var newfolderbutton = document.createElement('div'); - newfolderbutton.id = 'newfolderbutton'; - newfolderbutton.className = 'filebutton newfolderbutton disabled'; - newfolderbutton.textContent = localStrings.getString('newfolder'); - newfolderbutton.onclick = dialogNewFolderClick; - savemenu.appendChild(newfolderbutton); - - document.body.appendChild(savemenu); - - } else { - var main = mainColumn; - main.className = 'containerwithopenbuttons'; - var openmenu = document.createElement('div'); - openmenu.className = 'opencontainer'; - var openbutton = document.createElement('div'); - openbutton.id = 'openbutton'; - openbutton.className = 'filebutton openbutton disabled'; - var cancelbutton = document.createElement('div'); - cancelbutton.className = 'filebutton cancelbutton'; - openmenu.appendChild(openbutton); - openbutton.onclick = dialogOkClick; - openmenu.appendChild(cancelbutton); - cancelbutton.onclick = dialogCancelClick; - openbutton.textContent = localStrings.getString('open'); - cancelbutton.textContent = localStrings.getString('confirmcancel'); - document.body.appendChild(openmenu); - } - } - } else { - var main = mainColumn; - main.className = 'fullcontainer'; - var innerContainer = document.createElement('div'); - innerContainer.className = 'container'; - innerContainer.id = 'inner'; - main.appendChild(innerContainer); - inFullMode = true; - $('back').style.display = 'none'; - } - - if (document.location.href.indexOf('#') != -1) { - var currentpathArray = document.location.href.split('#'); - var path = currentpathArray[1]; - if (path == 'scanningdevice') { - setUpForScanning(); - } else { - currentNode++; - currentSavedPath = path; - getDataForPath(path); - } - } else { - currentNode++; - currentSavedPath = 'roots'; - getDataForPath('roots'); - } - chrome.send("getDownloads", []); + chrome.send('isAdvancedEnabled', ['']); }; function jumpToNode(nodeNumber) { @@ -1454,7 +1469,8 @@ function createNewItem(title, path, isDirectory) { menu.appendChild(flickritem); menu.appendChild(emailitem); } - if (pathIsVideoFile(path) || pathIsAudioFile(path)) { + if ((pathIsVideoFile(path) || pathIsAudioFile(path)) && + mediaPlayerEnabled) { var enqueueitem = document.createElement('div'); enqueueitem.textContent = localStrings.getString('enqueue'); enqueueitem.className = 'menuitem'; diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 36fe1b5..b8e7d07 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -323,7 +323,16 @@ const wchar_t kLanguageMozcSuggestionsSize[] = // A boolean pref which determines whether accessibility is enabled. const wchar_t kAccessibilityEnabled[] = L"settings.accessibility"; -#endif + +// A boolean pref which turns on Advanced Filesystem +// (USB support, SD card, etc). +const wchar_t kLabsAdvancedFilesystemEnabled[] = + L"settings.labs.advanced_filesystem"; + +// A boolean pref which turns on the mediaplayer. +const wchar_t kLabsMediaplayerEnabled[] = L"settings.labs.mediaplayer"; + +#endif // defined(OS_CHROMEOS) // The disabled messages in IPC logging. const wchar_t kIpcDisabledMessages[] = L"ipc_log_disabled_messages"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index a582cec..e5350dc 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -124,6 +124,8 @@ extern const wchar_t kLanguageMozcUseHistorySuggest[]; extern const wchar_t kLanguageMozcUseDictionarySuggest[]; extern const wchar_t kLanguageMozcSuggestionsSize[]; extern const wchar_t kAccessibilityEnabled[]; +extern const wchar_t kLabsAdvancedFilesystemEnabled[]; +extern const wchar_t kLabsMediaplayerEnabled[]; #endif extern const wchar_t kIpcDisabledMessages[]; extern const wchar_t kShowHomeButton[]; |