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/ui/webui/active_downloads_ui.h" | 5 #include "chrome/browser/ui/webui/active_downloads_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
16 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/string_piece.h" | 18 #include "base/string_piece.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "base/threading/thread.h" | 20 #include "base/threading/thread.h" |
21 #include "base/time.h" | 21 #include "base/time.h" |
22 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
23 #include "base/values.h" | 23 #include "base/values.h" |
24 #include "chrome/app/chrome_command_ids.h" | |
24 #include "chrome/browser/chromeos/cros/cros_library.h" | 25 #include "chrome/browser/chromeos/cros/cros_library.h" |
25 #include "chrome/browser/chromeos/login/user_manager.h" | 26 #include "chrome/browser/chromeos/login/user_manager.h" |
26 #include "chrome/browser/download/download_item.h" | 27 #include "chrome/browser/download/download_item.h" |
27 #include "chrome/browser/download/download_manager.h" | 28 #include "chrome/browser/download/download_manager.h" |
28 #include "chrome/browser/download/download_util.h" | 29 #include "chrome/browser/download/download_util.h" |
29 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/browser/tabs/tab_strip_model.h" | 31 #include "chrome/browser/tabs/tab_strip_model.h" |
31 #include "chrome/browser/ui/browser.h" | 32 #include "chrome/browser/ui/browser.h" |
32 #include "chrome/browser/ui/browser_list.h" | 33 #include "chrome/browser/ui/browser_list.h" |
33 #include "chrome/browser/ui/browser_window.h" | 34 #include "chrome/browser/ui/browser_window.h" |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 browser = Browser::CreateForApp(Browser::TYPE_PANEL, kActiveDownloadAppName, | 397 browser = Browser::CreateForApp(Browser::TYPE_PANEL, kActiveDownloadAppName, |
397 gfx::Size(), profile); | 398 gfx::Size(), profile); |
398 | 399 |
399 browser::NavigateParams params( | 400 browser::NavigateParams params( |
400 browser, | 401 browser, |
401 GURL(chrome::kChromeUIActiveDownloadsURL), | 402 GURL(chrome::kChromeUIActiveDownloadsURL), |
402 PageTransition::LINK); | 403 PageTransition::LINK); |
403 params.disposition = NEW_FOREGROUND_TAB; | 404 params.disposition = NEW_FOREGROUND_TAB; |
404 browser::Navigate(¶ms); | 405 browser::Navigate(¶ms); |
405 | 406 |
407 DCHECK_EQ(browser, params.browser); | |
406 // TODO(beng): The following two calls should be automatic by Navigate(). | 408 // TODO(beng): The following two calls should be automatic by Navigate(). |
407 params.browser->window()->SetBounds(gfx::Rect(kPopupLeft, | 409 browser->window()->SetBounds(gfx::Rect(kPopupLeft, |
408 kPopupTop, | 410 kPopupTop, |
409 kPopupWidth, | 411 kPopupWidth, |
410 kPopupHeight)); | 412 kPopupHeight)); |
xiyuan
2011/05/13 16:34:28
nit: align the args.
| |
411 params.browser->window()->Show(); | 413 |
412 } else { | 414 // Disallow Open File. |
413 browser->window()->Show(); | 415 browser->command_updater()->UpdateCommandEnabled(IDC_OPEN_FILE, false); |
xiyuan
2011/05/13 16:34:28
This is not a reliable way to disable a command. S
| |
414 } | 416 } |
415 | 417 |
418 browser->window()->Show(); | |
416 return browser; | 419 return browser; |
417 } | 420 } |
418 | 421 |
419 Browser* ActiveDownloadsUI::GetPopup(Profile* profile) { | 422 Browser* ActiveDownloadsUI::GetPopup(Profile* profile) { |
420 for (BrowserList::const_iterator it = BrowserList::begin(); | 423 for (BrowserList::const_iterator it = BrowserList::begin(); |
421 it != BrowserList::end(); | 424 it != BrowserList::end(); |
422 ++it) { | 425 ++it) { |
423 if ((*it)->is_type_panel() && (*it)->is_app()) { | 426 if ((*it)->is_type_panel() && (*it)->is_app()) { |
424 TabContents* tab_contents = (*it)->GetSelectedTabContents(); | 427 TabContents* tab_contents = (*it)->GetSelectedTabContents(); |
425 DCHECK(tab_contents); | 428 DCHECK(tab_contents); |
426 if (!tab_contents) | 429 if (!tab_contents) |
427 continue; | 430 continue; |
428 const GURL& url = tab_contents->GetURL(); | 431 const GURL& url = tab_contents->GetURL(); |
429 | 432 |
430 if (url.SchemeIs(chrome::kChromeUIScheme) && | 433 if (url.SchemeIs(chrome::kChromeUIScheme) && |
431 url.host() == chrome::kChromeUIActiveDownloadsHost && | 434 url.host() == chrome::kChromeUIActiveDownloadsHost && |
432 (*it)->profile() == profile) { | 435 (*it)->profile() == profile) { |
433 return (*it); | 436 return (*it); |
434 } | 437 } |
435 } | 438 } |
436 } | 439 } |
437 return NULL; | 440 return NULL; |
438 } | 441 } |
439 | 442 |
OLD | NEW |