| 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/filebrowse_ui.h" | 5 #include "chrome/browser/dom_ui/filebrowse_ui.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 13 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 14 #include "base/singleton.h" | 15 #include "base/singleton.h" |
| 15 #include "base/string_piece.h" | 16 #include "base/string_piece.h" |
| 16 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 17 #include "base/thread.h" | 18 #include "base/thread.h" |
| 18 #include "base/time.h" | 19 #include "base/time.h" |
| 19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 20 #include "base/values.h" | 21 #include "base/values.h" |
| 21 #include "base/weak_ptr.h" | 22 #include "base/weak_ptr.h" |
| 22 #include "chrome/browser/bookmarks/bookmark_model.h" | 23 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 23 #include "chrome/browser/browser.h" | 24 #include "chrome/browser/browser.h" |
| 24 #include "chrome/browser/browser_list.h" | 25 #include "chrome/browser/browser_list.h" |
| 25 #include "chrome/browser/browser_thread.h" | 26 #include "chrome/browser/browser_thread.h" |
| 26 #include "chrome/browser/browser_window.h" | 27 #include "chrome/browser/browser_window.h" |
| 27 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" | 28 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" |
| 28 #include "chrome/browser/dom_ui/mediaplayer_ui.h" | 29 #include "chrome/browser/dom_ui/mediaplayer_ui.h" |
| 29 #include "chrome/browser/download/download_item.h" | 30 #include "chrome/browser/download/download_item.h" |
| 30 #include "chrome/browser/download/download_manager.h" | 31 #include "chrome/browser/download/download_manager.h" |
| 31 #include "chrome/browser/download/download_util.h" | 32 #include "chrome/browser/download/download_util.h" |
| 32 #include "chrome/browser/history/history_types.h" | 33 #include "chrome/browser/history/history_types.h" |
| 33 #include "chrome/browser/metrics/user_metrics.h" | 34 #include "chrome/browser/metrics/user_metrics.h" |
| 34 #include "chrome/browser/prefs/pref_service.h" | |
| 35 #include "chrome/browser/profile.h" | 35 #include "chrome/browser/profile.h" |
| 36 #include "chrome/browser/tab_contents/tab_contents.h" | 36 #include "chrome/browser/tab_contents/tab_contents.h" |
| 37 #include "chrome/browser/tabs/tab_strip_model.h" | 37 #include "chrome/browser/tabs/tab_strip_model.h" |
| 38 #include "chrome/browser/ui/browser_navigator.h" | 38 #include "chrome/browser/ui/browser_navigator.h" |
| 39 #include "chrome/common/chrome_paths.h" | 39 #include "chrome/common/chrome_paths.h" |
| 40 #include "chrome/common/chrome_switches.h" |
| 40 #include "chrome/common/jstemplate_builder.h" | 41 #include "chrome/common/jstemplate_builder.h" |
| 41 #include "chrome/common/net/url_fetcher.h" | 42 #include "chrome/common/net/url_fetcher.h" |
| 42 #include "chrome/common/pref_names.h" | |
| 43 #include "chrome/common/time_format.h" | 43 #include "chrome/common/time_format.h" |
| 44 #include "chrome/common/url_constants.h" | 44 #include "chrome/common/url_constants.h" |
| 45 #include "grit/browser_resources.h" | 45 #include "grit/browser_resources.h" |
| 46 #include "grit/chromium_strings.h" | 46 #include "grit/chromium_strings.h" |
| 47 #include "grit/generated_resources.h" | 47 #include "grit/generated_resources.h" |
| 48 #include "grit/locale_settings.h" | 48 #include "grit/locale_settings.h" |
| 49 #include "net/base/escape.h" | 49 #include "net/base/escape.h" |
| 50 | 50 |
| 51 #if defined(OS_CHROMEOS) | 51 #if defined(OS_CHROMEOS) |
| 52 #include "chrome/browser/chromeos/cros/cros_library.h" | 52 #include "chrome/browser/chromeos/cros/cros_library.h" |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 | 633 |
| 634 Browser* browser = Browser::GetBrowserForController( | 634 Browser* browser = Browser::GetBrowserForController( |
| 635 &tab_contents_->controller(), NULL); | 635 &tab_contents_->controller(), NULL); |
| 636 MediaPlayer* mediaplayer = MediaPlayer::Get(); | 636 MediaPlayer* mediaplayer = MediaPlayer::Get(); |
| 637 mediaplayer->EnqueueMediaURL(gurl, browser); | 637 mediaplayer->EnqueueMediaURL(gurl, browser); |
| 638 #endif | 638 #endif |
| 639 } | 639 } |
| 640 | 640 |
| 641 void FilebrowseHandler::HandleIsAdvancedEnabled(const ListValue* args) { | 641 void FilebrowseHandler::HandleIsAdvancedEnabled(const ListValue* args) { |
| 642 #if defined(OS_CHROMEOS) | 642 #if defined(OS_CHROMEOS) |
| 643 Browser* browser = BrowserList::GetLastActive(); | 643 bool is_enabled = CommandLine::ForCurrentProcess()->HasSwitch( |
| 644 bool is_enabled = false; | 644 switches::kEnableAdvancedFileSystem); |
| 645 bool mp_enabled = false; | 645 bool mp_enabled = CommandLine::ForCurrentProcess()->HasSwitch( |
| 646 if (browser) { | 646 switches::kEnableMediaPlayer); |
| 647 Profile* profile = browser->profile(); | |
| 648 PrefService* pref_service = profile->GetPrefs(); | |
| 649 is_enabled = pref_service->GetBoolean( | |
| 650 prefs::kLabsAdvancedFilesystemEnabled); | |
| 651 mp_enabled = pref_service->GetBoolean(prefs::kLabsMediaplayerEnabled); | |
| 652 } | |
| 653 DictionaryValue info_value; | 647 DictionaryValue info_value; |
| 654 info_value.SetBoolean("enabled", is_enabled); | 648 info_value.SetBoolean("enabled", is_enabled); |
| 655 info_value.SetBoolean("mpEnabled", mp_enabled); | 649 info_value.SetBoolean("mpEnabled", mp_enabled); |
| 656 dom_ui_->CallJavascriptFunction(L"enabledResult", | 650 dom_ui_->CallJavascriptFunction(L"enabledResult", |
| 657 info_value); | 651 info_value); |
| 658 | 652 |
| 659 #endif | 653 #endif |
| 660 } | 654 } |
| 661 | 655 |
| 662 void FilebrowseHandler::HandleRefreshDirectory(const ListValue* args) { | 656 void FilebrowseHandler::HandleRefreshDirectory(const ListValue* args) { |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 browser->window()->Show(); | 1150 browser->window()->Show(); |
| 1157 } | 1151 } |
| 1158 | 1152 |
| 1159 return browser; | 1153 return browser; |
| 1160 } | 1154 } |
| 1161 | 1155 |
| 1162 Browser* FileBrowseUI::GetPopupForPath(const std::string& path, | 1156 Browser* FileBrowseUI::GetPopupForPath(const std::string& path, |
| 1163 Profile* profile) { | 1157 Profile* profile) { |
| 1164 std::string current_path = path; | 1158 std::string current_path = path; |
| 1165 if (current_path.empty()) { | 1159 if (current_path.empty()) { |
| 1166 Browser* browser = BrowserList::GetLastActive(); | 1160 bool is_enabled = CommandLine::ForCurrentProcess()->HasSwitch( |
| 1167 if (browser == NULL) { | 1161 switches::kEnableAdvancedFileSystem); |
| 1168 return NULL; | |
| 1169 } | |
| 1170 Profile* profile = browser->profile(); | |
| 1171 PrefService* pref_service = profile->GetPrefs(); | |
| 1172 bool is_enabled = pref_service->GetBoolean( | |
| 1173 prefs::kLabsAdvancedFilesystemEnabled); | |
| 1174 if (!is_enabled) { | 1162 if (!is_enabled) { |
| 1175 FilePath default_download_path; | 1163 FilePath default_download_path; |
| 1176 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, | 1164 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, |
| 1177 &default_download_path)) { | 1165 &default_download_path)) { |
| 1178 NOTREACHED(); | 1166 NOTREACHED(); |
| 1179 } | 1167 } |
| 1180 current_path = default_download_path.value(); | 1168 current_path = default_download_path.value(); |
| 1181 } | 1169 } |
| 1182 } | 1170 } |
| 1183 | 1171 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1199 } | 1187 } |
| 1200 } | 1188 } |
| 1201 | 1189 |
| 1202 return NULL; | 1190 return NULL; |
| 1203 } | 1191 } |
| 1204 | 1192 |
| 1205 const int FileBrowseUI::kPopupWidth = 250; | 1193 const int FileBrowseUI::kPopupWidth = 250; |
| 1206 const int FileBrowseUI::kPopupHeight = 300; | 1194 const int FileBrowseUI::kPopupHeight = 300; |
| 1207 const int FileBrowseUI::kSmallPopupWidth = 250; | 1195 const int FileBrowseUI::kSmallPopupWidth = 250; |
| 1208 const int FileBrowseUI::kSmallPopupHeight = 50; | 1196 const int FileBrowseUI::kSmallPopupHeight = 50; |
| OLD | NEW |