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

Side by Side Diff: chrome/browser/extensions/api/web_navigation/web_navigation_api_helpers.cc

Issue 2937623002: [Extensions] Simplify EventFilteringInfo (Closed)
Patch Set: karan's Created 3 years, 6 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 // Implements the Chrome Extensions WebNavigation API. 5 // Implements the Chrome Extensions WebNavigation API.
6 6
7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_helper s.h" 7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_helper s.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // Returns |time| as milliseconds since the epoch. 43 // Returns |time| as milliseconds since the epoch.
44 double MilliSecondsFromTime(const base::Time& time) { 44 double MilliSecondsFromTime(const base::Time& time) {
45 return 1000 * time.ToDoubleT(); 45 return 1000 * time.ToDoubleT();
46 } 46 }
47 47
48 // Dispatches events to the extension message service. 48 // Dispatches events to the extension message service.
49 void DispatchEvent(content::BrowserContext* browser_context, 49 void DispatchEvent(content::BrowserContext* browser_context,
50 std::unique_ptr<Event> event, 50 std::unique_ptr<Event> event,
51 const GURL& url) { 51 const GURL& url) {
52 EventFilteringInfo info; 52 EventFilteringInfo info;
53 info.SetURL(url); 53 info.url = url;
54 54
55 Profile* profile = Profile::FromBrowserContext(browser_context); 55 Profile* profile = Profile::FromBrowserContext(browser_context);
56 EventRouter* event_router = EventRouter::Get(profile); 56 EventRouter* event_router = EventRouter::Get(profile);
57 if (profile && event_router) { 57 if (profile && event_router) {
58 DCHECK_EQ(profile, event->restrict_to_browser_context); 58 DCHECK_EQ(profile, event->restrict_to_browser_context);
59 event->filter_info = info; 59 event->filter_info = info;
60 event_router->BroadcastEvent(std::move(event)); 60 event_router->BroadcastEvent(std::move(event));
61 } 61 }
62 } 62 }
63 63
(...skipping 14 matching lines...) Expand all
78 ExtensionApiFrameIdMap::GetParentFrameId(navigation_handle); 78 ExtensionApiFrameIdMap::GetParentFrameId(navigation_handle);
79 details.time_stamp = MilliSecondsFromTime(base::Time::Now()); 79 details.time_stamp = MilliSecondsFromTime(base::Time::Now());
80 80
81 auto event = base::MakeUnique<Event>( 81 auto event = base::MakeUnique<Event>(
82 events::WEB_NAVIGATION_ON_BEFORE_NAVIGATE, 82 events::WEB_NAVIGATION_ON_BEFORE_NAVIGATE,
83 web_navigation::OnBeforeNavigate::kEventName, 83 web_navigation::OnBeforeNavigate::kEventName,
84 web_navigation::OnBeforeNavigate::Create(details), 84 web_navigation::OnBeforeNavigate::Create(details),
85 navigation_handle->GetWebContents()->GetBrowserContext()); 85 navigation_handle->GetWebContents()->GetBrowserContext());
86 86
87 EventFilteringInfo info; 87 EventFilteringInfo info;
88 info.SetURL(navigation_handle->GetURL()); 88 info.url = navigation_handle->GetURL();
89 event->filter_info = info; 89 event->filter_info = info;
90 90
91 return event; 91 return event;
92 } 92 }
93 93
94 // Constructs and dispatches an onCommitted or onReferenceFragmentUpdated 94 // Constructs and dispatches an onCommitted or onReferenceFragmentUpdated
95 // event. 95 // event.
96 void DispatchOnCommitted(events::HistogramValue histogram_value, 96 void DispatchOnCommitted(events::HistogramValue histogram_value,
97 const std::string& event_name, 97 const std::string& event_name,
98 content::NavigationHandle* navigation_handle) { 98 content::NavigationHandle* navigation_handle) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 auto event = base::MakeUnique<Event>( 274 auto event = base::MakeUnique<Event>(
275 events::WEB_NAVIGATION_ON_TAB_REPLACED, 275 events::WEB_NAVIGATION_ON_TAB_REPLACED,
276 web_navigation::OnTabReplaced::kEventName, 276 web_navigation::OnTabReplaced::kEventName,
277 web_navigation::OnTabReplaced::Create(details), browser_context); 277 web_navigation::OnTabReplaced::Create(details), browser_context);
278 DispatchEvent(browser_context, std::move(event), GURL()); 278 DispatchEvent(browser_context, std::move(event), GURL());
279 } 279 }
280 280
281 } // namespace web_navigation_api_helpers 281 } // namespace web_navigation_api_helpers
282 282
283 } // namespace extensions 283 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/windows_event_router.cc ('k') | chrome/browser/extensions/menu_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698