| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 task->AddRef(); | 415 task->AddRef(); |
| 416 BrowserThread::PostTask( | 416 BrowserThread::PostTask( |
| 417 BrowserThread::FILE, FROM_HERE, | 417 BrowserThread::FILE, FROM_HERE, |
| 418 NewRunnableMethod( | 418 NewRunnableMethod( |
| 419 task, &TaskProxy::DeleteFetcher, fetch)); | 419 task, &TaskProxy::DeleteFetcher, fetch)); |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 | 422 |
| 423 WebUIMessageHandler* FilebrowseHandler::Attach(DOMUI* dom_ui) { | 423 WebUIMessageHandler* FilebrowseHandler::Attach(DOMUI* dom_ui) { |
| 424 // Create our favicon data source. | 424 // Create our favicon data source. |
| 425 BrowserThread::PostTask( |
| 426 BrowserThread::IO, FROM_HERE, |
| 427 NewRunnableMethod( |
| 428 ChromeURLDataManager::GetInstance(), |
| 429 &ChromeURLDataManager::AddDataSource, |
| 430 make_scoped_refptr(new WebUIFavIconSource(dom_ui->GetProfile())))); |
| 425 profile_ = dom_ui->GetProfile(); | 431 profile_ = dom_ui->GetProfile(); |
| 426 profile_->GetChromeURLDataManager()->AddDataSource( | |
| 427 new WebUIFavIconSource(profile_)); | |
| 428 tab_contents_ = dom_ui->tab_contents(); | 432 tab_contents_ = dom_ui->tab_contents(); |
| 429 return WebUIMessageHandler::Attach(dom_ui); | 433 return WebUIMessageHandler::Attach(dom_ui); |
| 430 } | 434 } |
| 431 | 435 |
| 432 void FilebrowseHandler::Init() { | 436 void FilebrowseHandler::Init() { |
| 433 download_manager_ = profile_->GetDownloadManager(); | 437 download_manager_ = profile_->GetDownloadManager(); |
| 434 download_manager_->AddObserver(this); | 438 download_manager_->AddObserver(this); |
| 435 TaskProxy* task = new TaskProxy(AsWeakPtr(), currentpath_); | 439 TaskProxy* task = new TaskProxy(AsWeakPtr(), currentpath_); |
| 436 task->AddRef(); | 440 task->AddRef(); |
| 437 current_task_ = task; | 441 current_task_ = task; |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 // | 1132 // |
| 1129 //////////////////////////////////////////////////////////////////////////////// | 1133 //////////////////////////////////////////////////////////////////////////////// |
| 1130 | 1134 |
| 1131 FileBrowseUI::FileBrowseUI(TabContents* contents) : HtmlDialogUI(contents) { | 1135 FileBrowseUI::FileBrowseUI(TabContents* contents) : HtmlDialogUI(contents) { |
| 1132 FilebrowseHandler* handler = new FilebrowseHandler(); | 1136 FilebrowseHandler* handler = new FilebrowseHandler(); |
| 1133 AddMessageHandler((handler)->Attach(this)); | 1137 AddMessageHandler((handler)->Attach(this)); |
| 1134 handler->Init(); | 1138 handler->Init(); |
| 1135 FileBrowseUIHTMLSource* html_source = new FileBrowseUIHTMLSource(); | 1139 FileBrowseUIHTMLSource* html_source = new FileBrowseUIHTMLSource(); |
| 1136 | 1140 |
| 1137 // Set up the chrome://filebrowse/ source. | 1141 // Set up the chrome://filebrowse/ source. |
| 1138 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 1142 BrowserThread::PostTask( |
| 1143 BrowserThread::IO, FROM_HERE, |
| 1144 NewRunnableMethod( |
| 1145 ChromeURLDataManager::GetInstance(), |
| 1146 &ChromeURLDataManager::AddDataSource, |
| 1147 make_scoped_refptr(html_source))); |
| 1139 } | 1148 } |
| 1140 | 1149 |
| 1141 // static | 1150 // static |
| 1142 Browser* FileBrowseUI::OpenPopup(Profile* profile, | 1151 Browser* FileBrowseUI::OpenPopup(Profile* profile, |
| 1143 const std::string& hashArgument, | 1152 const std::string& hashArgument, |
| 1144 int width, | 1153 int width, |
| 1145 int height) { | 1154 int height) { |
| 1146 // Get existing pop up for given hashArgument. | 1155 // Get existing pop up for given hashArgument. |
| 1147 Browser* browser = GetPopupForPath(hashArgument, profile); | 1156 Browser* browser = GetPopupForPath(hashArgument, profile); |
| 1148 | 1157 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1208 } | 1217 } |
| 1209 } | 1218 } |
| 1210 | 1219 |
| 1211 return NULL; | 1220 return NULL; |
| 1212 } | 1221 } |
| 1213 | 1222 |
| 1214 const int FileBrowseUI::kPopupWidth = 250; | 1223 const int FileBrowseUI::kPopupWidth = 250; |
| 1215 const int FileBrowseUI::kPopupHeight = 300; | 1224 const int FileBrowseUI::kPopupHeight = 300; |
| 1216 const int FileBrowseUI::kSmallPopupWidth = 250; | 1225 const int FileBrowseUI::kSmallPopupWidth = 250; |
| 1217 const int FileBrowseUI::kSmallPopupHeight = 50; | 1226 const int FileBrowseUI::kSmallPopupHeight = 50; |
| OLD | NEW |