| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/dom_ui/mediaplayer_ui.h" | 5 #include "chrome/browser/dom_ui/mediaplayer_ui.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 10 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 11 #include "base/singleton.h" | 12 #include "base/singleton.h" |
| 12 #include "base/string_piece.h" | 13 #include "base/string_piece.h" |
| 13 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 14 #include "base/thread.h" | 15 #include "base/thread.h" |
| 15 #include "base/time.h" | 16 #include "base/time.h" |
| 16 #include "base/values.h" | 17 #include "base/values.h" |
| 17 #include "base/weak_ptr.h" | 18 #include "base/weak_ptr.h" |
| 18 #include "chrome/browser/bookmarks/bookmark_model.h" | 19 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 19 #include "chrome/browser/browser.h" | 20 #include "chrome/browser/browser.h" |
| 20 #include "chrome/browser/browser_list.h" | 21 #include "chrome/browser/browser_list.h" |
| 21 #include "chrome/browser/browser_thread.h" | 22 #include "chrome/browser/browser_thread.h" |
| 22 #include "chrome/browser/browser_window.h" | 23 #include "chrome/browser/browser_window.h" |
| 23 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" | 24 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" |
| 24 #include "chrome/browser/download/download_manager.h" | 25 #include "chrome/browser/download/download_manager.h" |
| 25 #include "chrome/browser/download/download_util.h" | 26 #include "chrome/browser/download/download_util.h" |
| 26 #include "chrome/browser/metrics/user_metrics.h" | 27 #include "chrome/browser/metrics/user_metrics.h" |
| 27 #include "chrome/browser/history/history_types.h" | 28 #include "chrome/browser/history/history_types.h" |
| 28 #include "chrome/browser/prefs/pref_service.h" | |
| 29 #include "chrome/browser/profile.h" | 29 #include "chrome/browser/profile.h" |
| 30 #include "chrome/browser/tab_contents/tab_contents.h" | 30 #include "chrome/browser/tab_contents/tab_contents.h" |
| 31 #include "chrome/browser/tabs/tab_strip_model.h" | 31 #include "chrome/browser/tabs/tab_strip_model.h" |
| 32 #include "chrome/common/chrome_paths.h" | 32 #include "chrome/common/chrome_paths.h" |
| 33 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/common/jstemplate_builder.h" | 34 #include "chrome/common/jstemplate_builder.h" |
| 34 #include "chrome/common/net/url_fetcher.h" | 35 #include "chrome/common/net/url_fetcher.h" |
| 35 #include "chrome/common/pref_names.h" | |
| 36 #include "chrome/common/time_format.h" | 36 #include "chrome/common/time_format.h" |
| 37 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
| 38 #include "grit/browser_resources.h" | 38 #include "grit/browser_resources.h" |
| 39 #include "grit/chromium_strings.h" | 39 #include "grit/chromium_strings.h" |
| 40 #include "grit/generated_resources.h" | 40 #include "grit/generated_resources.h" |
| 41 #include "grit/locale_settings.h" | 41 #include "grit/locale_settings.h" |
| 42 #include "net/base/escape.h" | 42 #include "net/base/escape.h" |
| 43 #include "net/base/load_flags.h" | 43 #include "net/base/load_flags.h" |
| 44 #include "net/url_request/url_request_job.h" | 44 #include "net/url_request/url_request_job.h" |
| 45 | 45 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 if (handler_ == NULL) { | 374 if (handler_ == NULL) { |
| 375 unhandled_urls_.push_back(url); | 375 unhandled_urls_.push_back(url); |
| 376 PopupMediaPlayer(creator); | 376 PopupMediaPlayer(creator); |
| 377 } else { | 377 } else { |
| 378 handler_->PlaybackMediaFile(url); | 378 handler_->PlaybackMediaFile(url); |
| 379 } | 379 } |
| 380 } | 380 } |
| 381 | 381 |
| 382 bool MediaPlayer::Enabled() { | 382 bool MediaPlayer::Enabled() { |
| 383 #if defined(OS_CHROMEOS) | 383 #if defined(OS_CHROMEOS) |
| 384 Profile* profile = BrowserList::GetLastActive()->profile(); | 384 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 385 PrefService* pref_service = profile->GetPrefs(); | 385 switches::kEnableMediaPlayer); |
| 386 return pref_service->GetBoolean(prefs::kLabsMediaplayerEnabled); | |
| 387 #else | 386 #else |
| 388 return true; | 387 return true; |
| 389 #endif | 388 #endif |
| 390 } | 389 } |
| 391 | 390 |
| 392 void MediaPlayer::TogglePlaylistWindowVisible() { | 391 void MediaPlayer::TogglePlaylistWindowVisible() { |
| 393 if (playlist_browser_) { | 392 if (playlist_browser_) { |
| 394 ClosePlaylistWindow(); | 393 ClosePlaylistWindow(); |
| 395 } else { | 394 } else { |
| 396 ShowPlaylistWindow(); | 395 ShowPlaylistWindow(); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 new MediaplayerUIHTMLSource(is_playlist); | 607 new MediaplayerUIHTMLSource(is_playlist); |
| 609 | 608 |
| 610 // Set up the chrome://mediaplayer/ source. | 609 // Set up the chrome://mediaplayer/ source. |
| 611 BrowserThread::PostTask( | 610 BrowserThread::PostTask( |
| 612 BrowserThread::IO, FROM_HERE, | 611 BrowserThread::IO, FROM_HERE, |
| 613 NewRunnableMethod( | 612 NewRunnableMethod( |
| 614 Singleton<ChromeURLDataManager>::get(), | 613 Singleton<ChromeURLDataManager>::get(), |
| 615 &ChromeURLDataManager::AddDataSource, | 614 &ChromeURLDataManager::AddDataSource, |
| 616 make_scoped_refptr(html_source))); | 615 make_scoped_refptr(html_source))); |
| 617 } | 616 } |
| OLD | NEW |