Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1002)

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 2898383002: [Extensions] Make Event::restrict_to_browser_context const. (Closed)
Patch Set: sync @tott Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
1896 event->restrict_to_browser_context = 1894 // TODO(lazyboy): When |restrict_to_browser_context| is nullptr, this will
1897 (include_incognito && !profile_->IsOffTheRecord()) ? NULL : profile_; 1895 // broadcast events to unrelated profiles, not just incognito. Fix this
1896 // by introducing "include incognito" option to Event constructor.
1897 // https://crbug.com/726022.
1898 Profile* restrict_to_browser_context =
1899 (include_incognito && !profile_->IsOffTheRecord()) ? nullptr : profile_;
1900 auto event =
1901 base::MakeUnique<Event>(histogram_value, event_name, std::move(args),
1902 restrict_to_browser_context);
1898 event->will_dispatch_callback = will_dispatch_callback; 1903 event->will_dispatch_callback = will_dispatch_callback;
1899 EventRouter::Get(profile_)->BroadcastEvent(std::move(event)); 1904 EventRouter::Get(profile_)->BroadcastEvent(std::move(event));
1900 DownloadsNotificationSource notification_source; 1905 DownloadsNotificationSource notification_source;
1901 notification_source.event_name = event_name; 1906 notification_source.event_name = event_name;
1902 notification_source.profile = profile_; 1907 notification_source.profile = profile_;
1903 content::Source<DownloadsNotificationSource> content_source( 1908 content::Source<DownloadsNotificationSource> content_source(
1904 &notification_source); 1909 &notification_source);
1905 content::NotificationService::current()->Notify( 1910 content::NotificationService::current()->Notify(
1906 extensions::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, 1911 extensions::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT,
1907 content_source, 1912 content_source,
(...skipping 18 matching lines...) Expand all
1926 return; 1931 return;
1927 base::Time now(base::Time::Now()); 1932 base::Time now(base::Time::Now());
1928 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); 1933 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT();
1929 if (delta <= kFileExistenceRateLimitSeconds) 1934 if (delta <= kFileExistenceRateLimitSeconds)
1930 return; 1935 return;
1931 last_checked_removal_ = now; 1936 last_checked_removal_ = now;
1932 manager->CheckForHistoryFilesRemoval(); 1937 manager->CheckForHistoryFilesRemoval();
1933 } 1938 }
1934 1939
1935 } // namespace extensions 1940 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698