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/extensions/extension_downloads_api.h" | 5 #include "chrome/browser/extensions/extension_downloads_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cctype> | 8 #include <cctype> |
9 #include <iterator> | 9 #include <iterator> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/json/json_writer.h" | 15 #include "base/json/json_writer.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
19 #include "base/string16.h" | 19 #include "base/string16.h" |
20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
21 #include "base/stringprintf.h" | 21 #include "base/stringprintf.h" |
22 #include "base/values.h" | 22 #include "base/values.h" |
23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/download/download_service.h" | |
25 #include "chrome/browser/download/download_service_factory.h" | |
24 #include "chrome/browser/download/download_util.h" | 26 #include "chrome/browser/download/download_util.h" |
25 #include "chrome/browser/extensions/extension_downloads_api_constants.h" | 27 #include "chrome/browser/extensions/extension_downloads_api_constants.h" |
26 #include "chrome/browser/extensions/extension_event_names.h" | 28 #include "chrome/browser/extensions/extension_event_names.h" |
27 #include "chrome/browser/extensions/extension_event_router.h" | 29 #include "chrome/browser/extensions/extension_event_router.h" |
28 #include "chrome/browser/icon_loader.h" | 30 #include "chrome/browser/icon_loader.h" |
29 #include "chrome/browser/icon_manager.h" | 31 #include "chrome/browser/icon_manager.h" |
30 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | 32 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
31 #include "chrome/browser/ui/browser_list.h" | 33 #include "chrome/browser/ui/browser_list.h" |
32 #include "content/browser/download/download_file_manager.h" | 34 #include "content/browser/download/download_file_manager.h" |
33 #include "content/browser/download/download_item.h" | 35 #include "content/browser/download/download_item.h" |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 // TODO(benjhayden): Implement endTime and fileSize. | 409 // TODO(benjhayden): Implement endTime and fileSize. |
408 // json->SetInteger(constants::kEndTimeKey, -1); | 410 // json->SetInteger(constants::kEndTimeKey, -1); |
409 json->SetInteger(constants::kFileSizeKey, item->total_bytes()); | 411 json->SetInteger(constants::kFileSizeKey, item->total_bytes()); |
410 return json; | 412 return json; |
411 } | 413 } |
412 } // anonymous namespace | 414 } // anonymous namespace |
413 | 415 |
414 ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter( | 416 ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter( |
415 Profile* profile) | 417 Profile* profile) |
416 : profile_(profile), | 418 : profile_(profile), |
417 manager_(profile ? profile->GetDownloadManager() : NULL) { | 419 manager_(profile ? |
420 DownloadServiceFactory::GetForProfile(profile) | |
421 ->GetDownloadManager() : NULL) { | |
Miranda Callahan
2011/10/06 20:07:32
hmm, again, wrapping before the -> is not kosher,
Randy Smith (Not in Mondays)
2011/10/08 23:46:54
Done.
| |
418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 422 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
419 DCHECK(profile_); | 423 DCHECK(profile_); |
420 DCHECK(manager_); | 424 DCHECK(manager_); |
421 manager_->AddObserver(this); | 425 manager_->AddObserver(this); |
422 } | 426 } |
423 | 427 |
424 ExtensionDownloadsEventRouter::~ExtensionDownloadsEventRouter() { | 428 ExtensionDownloadsEventRouter::~ExtensionDownloadsEventRouter() { |
425 if (manager_ != NULL) | 429 if (manager_ != NULL) |
426 manager_->RemoveObserver(this); | 430 manager_->RemoveObserver(this); |
427 } | 431 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 ListValue args; | 484 ListValue args; |
481 args.Append(arg); | 485 args.Append(arg); |
482 std::string json_args; | 486 std::string json_args; |
483 base::JSONWriter::Write(&args, false, &json_args); | 487 base::JSONWriter::Write(&args, false, &json_args); |
484 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 488 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
485 event_name, | 489 event_name, |
486 json_args, | 490 json_args, |
487 profile_, | 491 profile_, |
488 GURL()); | 492 GURL()); |
489 } | 493 } |
OLD | NEW |