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

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

Issue 10696208: Move ExtensionEventRouter and related into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed bug + latest master Created 8 years, 5 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 "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta nts.h" 13 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta nts.h"
14 #include "chrome/browser/extensions/extension_event_router.h" 14 #include "chrome/browser/extensions/event_router.h"
15 #include "chrome/browser/extensions/extension_tab_util.h" 15 #include "chrome/browser/extensions/extension_tab_util.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/extensions/event_filtering_info.h" 17 #include "chrome/common/extensions/event_filtering_info.h"
18 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
19 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
21 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
22 22
23 namespace extensions { 23 namespace extensions {
24 24
25 namespace keys = web_navigation_api_constants; 25 namespace keys = web_navigation_api_constants;
26 26
27 namespace web_navigation_api_helpers { 27 namespace web_navigation_api_helpers {
28 28
29 namespace { 29 namespace {
30 30
31 // Returns |time| as milliseconds since the epoch. 31 // Returns |time| as milliseconds since the epoch.
32 double MilliSecondsFromTime(const base::Time& time) { 32 double MilliSecondsFromTime(const base::Time& time) {
33 return 1000 * time.ToDoubleT(); 33 return 1000 * time.ToDoubleT();
34 } 34 }
35 35
36 // Dispatches events to the extension message service. 36 // Dispatches events to the extension message service.
37 void DispatchEvent(content::BrowserContext* browser_context, 37 void DispatchEvent(content::BrowserContext* browser_context,
38 const char* event_name, 38 const char* event_name,
39 const ListValue& args, 39 const ListValue& args,
40 const GURL& url) { 40 const GURL& url) {
41 std::string json_args; 41 std::string json_args;
42 base::JSONWriter::Write(&args, &json_args); 42 base::JSONWriter::Write(&args, &json_args);
43 43
44 extensions::EventFilteringInfo info; 44 EventFilteringInfo info;
45 info.SetURL(url); 45 info.SetURL(url);
46 46
47 Profile* profile = Profile::FromBrowserContext(browser_context); 47 Profile* profile = Profile::FromBrowserContext(browser_context);
48 if (profile && profile->GetExtensionEventRouter()) { 48 if (profile && profile->GetExtensionEventRouter()) {
49 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 49 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
50 event_name, json_args, profile, GURL(), info); 50 event_name, json_args, profile, GURL(), info);
51 } 51 }
52 } 52 }
53 53
54 } // namespace 54 } // namespace
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 ExtensionTabUtil::GetTabId(new_web_contents)); 221 ExtensionTabUtil::GetTabId(new_web_contents));
222 dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); 222 dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now()));
223 args.Append(dict); 223 args.Append(dict);
224 224
225 DispatchEvent(browser_context, keys::kOnTabReplaced, args, GURL()); 225 DispatchEvent(browser_context, keys::kOnTabReplaced, args, GURL());
226 } 226 }
227 227
228 } // namespace web_navigation_api_helpers 228 } // namespace web_navigation_api_helpers
229 229
230 } // namespace extensions 230 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698