| 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 // 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" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // Dispatches events to the extension message service. | 37 // Dispatches events to the extension message service. |
| 38 void DispatchEvent(content::BrowserContext* browser_context, | 38 void DispatchEvent(content::BrowserContext* browser_context, |
| 39 const char* event_name, | 39 const char* event_name, |
| 40 scoped_ptr<ListValue> args, | 40 scoped_ptr<ListValue> args, |
| 41 const GURL& url) { | 41 const GURL& url) { |
| 42 EventFilteringInfo info; | 42 EventFilteringInfo info; |
| 43 info.SetURL(url); | 43 info.SetURL(url); |
| 44 | 44 |
| 45 Profile* profile = Profile::FromBrowserContext(browser_context); | 45 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 46 if (profile && extensions::ExtensionSystem::Get(profile)->event_router()) { | 46 if (profile && extensions::ExtensionSystem::Get(profile)->event_router()) { |
| 47 extensions::ExtensionSystem::Get(profile)->event_router()-> | 47 scoped_ptr<Event> event(new Event(event_name, args.Pass())); |
| 48 DispatchEventToRenderers(event_name, args.Pass(), profile, GURL(), | 48 event->restrict_to_profile = profile; |
| 49 info); | 49 event->filter_info = info; |
| 50 ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); |
| 50 } | 51 } |
| 51 } | 52 } |
| 52 | 53 |
| 53 } // namespace | 54 } // namespace |
| 54 | 55 |
| 55 int GetFrameId(bool is_main_frame, int64 frame_id) { | 56 int GetFrameId(bool is_main_frame, int64 frame_id) { |
| 56 return is_main_frame ? 0 : static_cast<int>(frame_id); | 57 return is_main_frame ? 0 : static_cast<int>(frame_id); |
| 57 } | 58 } |
| 58 | 59 |
| 59 // Constructs and dispatches an onBeforeNavigate event. | 60 // Constructs and dispatches an onBeforeNavigate event. |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 ExtensionTabUtil::GetTabId(new_web_contents)); | 226 ExtensionTabUtil::GetTabId(new_web_contents)); |
| 226 dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); | 227 dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); |
| 227 args->Append(dict); | 228 args->Append(dict); |
| 228 | 229 |
| 229 DispatchEvent(browser_context, keys::kOnTabReplaced, args.Pass(), GURL()); | 230 DispatchEvent(browser_context, keys::kOnTabReplaced, args.Pass(), GURL()); |
| 230 } | 231 } |
| 231 | 232 |
| 232 } // namespace web_navigation_api_helpers | 233 } // namespace web_navigation_api_helpers |
| 233 | 234 |
| 234 } // namespace extensions | 235 } // namespace extensions |
| OLD | NEW |