Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/api/downloads/downloads_api.h" | 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 1868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1879 bool include_incognito, | 1879 bool include_incognito, |
| 1880 const Event::WillDispatchCallback& will_dispatch_callback, | 1880 const Event::WillDispatchCallback& will_dispatch_callback, |
| 1881 std::unique_ptr<base::Value> arg) { | 1881 std::unique_ptr<base::Value> arg) { |
| 1882 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1882 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1883 if (!EventRouter::Get(profile_)) | 1883 if (!EventRouter::Get(profile_)) |
| 1884 return; | 1884 return; |
| 1885 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 1885 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
| 1886 args->Append(std::move(arg)); | 1886 args->Append(std::move(arg)); |
| 1887 std::string json_args; | 1887 std::string json_args; |
| 1888 base::JSONWriter::Write(*args, &json_args); | 1888 base::JSONWriter::Write(*args, &json_args); |
| 1889 std::unique_ptr<Event> event( | |
| 1890 new Event(histogram_value, event_name, std::move(args))); | |
| 1891 // The downloads system wants to share on-record events with off-record | 1889 // The downloads system wants to share on-record events with off-record |
| 1892 // extension renderers even in incognito_split_mode because that's how | 1890 // extension renderers even in incognito_split_mode because that's how |
| 1893 // chrome://downloads works. The "restrict_to_profile" mechanism does not | 1891 // chrome://downloads works. The "restrict_to_profile" mechanism does not |
| 1894 // anticipate this, so it does not automatically prevent sharing off-record | 1892 // anticipate this, so it does not automatically prevent sharing off-record |
| 1895 // events with on-record extension renderers. | 1893 // events with on-record extension renderers. |
|
Devlin
2017/05/24 16:08:18
This makes sense (at least, somewhat), but it's st
lazyboy
2017/05/24 19:19:32
Added a crbug. Added TODO here and in Event constr
| |
| 1896 event->restrict_to_browser_context = | 1894 Profile* restrict_to_browser_context = |
| 1897 (include_incognito && !profile_->IsOffTheRecord()) ? NULL : profile_; | 1895 (include_incognito && !profile_->IsOffTheRecord()) ? NULL : profile_; |
| 1896 auto event = | |
| 1897 base::MakeUnique<Event>(histogram_value, event_name, std::move(args), | |
| 1898 restrict_to_browser_context); | |
| 1898 event->will_dispatch_callback = will_dispatch_callback; | 1899 event->will_dispatch_callback = will_dispatch_callback; |
| 1899 EventRouter::Get(profile_)->BroadcastEvent(std::move(event)); | 1900 EventRouter::Get(profile_)->BroadcastEvent(std::move(event)); |
| 1900 DownloadsNotificationSource notification_source; | 1901 DownloadsNotificationSource notification_source; |
| 1901 notification_source.event_name = event_name; | 1902 notification_source.event_name = event_name; |
| 1902 notification_source.profile = profile_; | 1903 notification_source.profile = profile_; |
| 1903 content::Source<DownloadsNotificationSource> content_source( | 1904 content::Source<DownloadsNotificationSource> content_source( |
| 1904 ¬ification_source); | 1905 ¬ification_source); |
| 1905 content::NotificationService::current()->Notify( | 1906 content::NotificationService::current()->Notify( |
| 1906 extensions::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, | 1907 extensions::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, |
| 1907 content_source, | 1908 content_source, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1926 return; | 1927 return; |
| 1927 base::Time now(base::Time::Now()); | 1928 base::Time now(base::Time::Now()); |
| 1928 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); | 1929 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); |
| 1929 if (delta <= kFileExistenceRateLimitSeconds) | 1930 if (delta <= kFileExistenceRateLimitSeconds) |
| 1930 return; | 1931 return; |
| 1931 last_checked_removal_ = now; | 1932 last_checked_removal_ = now; |
| 1932 manager->CheckForHistoryFilesRemoval(); | 1933 manager->CheckForHistoryFilesRemoval(); |
| 1933 } | 1934 } |
| 1934 | 1935 |
| 1935 } // namespace extensions | 1936 } // namespace extensions |
| OLD | NEW |