diff options
author | dhg@chromium.org <dhg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-02 20:32:05 +0000 |
---|---|---|
committer | dhg@chromium.org <dhg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-02 20:32:05 +0000 |
commit | 6ba198fd7a578d370215fd5816962286070f9b3c (patch) | |
tree | 57dd8d3c58f118af9d6881f349bcdccb42935aa1 /chrome/browser/dom_ui | |
parent | 277bcc7aa162b6d92b01bdcad3bd76e2bb4a7cf6 (diff) | |
download | chromium_src-6ba198fd7a578d370215fd5816962286070f9b3c.zip chromium_src-6ba198fd7a578d370215fd5816962286070f9b3c.tar.gz chromium_src-6ba198fd7a578d370215fd5816962286070f9b3c.tar.bz2 |
Moving mediaplayer and filebrowser behind a preference. This just adds the preference and sets its default value to false. After this we'll have to add the UI to set it.
BUG=4362
TEST=none
Review URL: http://codereview.chromium.org/2873032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51563 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-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 |
4 files changed, 52 insertions, 1 deletions
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); |