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/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 event->filter_info = info; | 55 event->filter_info = info; |
56 event_router->BroadcastEvent(event.Pass()); | 56 event_router->BroadcastEvent(event.Pass()); |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 } // namespace | 60 } // namespace |
61 | 61 |
62 int GetFrameId(content::RenderFrameHost* frame_host) { | 62 int GetFrameId(content::RenderFrameHost* frame_host) { |
63 if (!frame_host) | 63 if (!frame_host) |
64 return -1; | 64 return -1; |
65 return !frame_host->GetParent() ? 0 : frame_host->GetRoutingID(); | 65 return !frame_host->GetParent() ? 0 : frame_host->GetFrameTreeNodeID(); |
66 } | 66 } |
67 | 67 |
68 // Constructs and dispatches an onBeforeNavigate event. | 68 // Constructs and dispatches an onBeforeNavigate event. |
69 // TODO(dcheng): Is the parent process ID needed here? http://crbug.com/393640 | |
70 // Collisions are probably possible... but maybe this won't ever happen because | |
71 // of the SiteInstance grouping policies. | |
72 void DispatchOnBeforeNavigate(content::WebContents* web_contents, | 69 void DispatchOnBeforeNavigate(content::WebContents* web_contents, |
73 content::RenderFrameHost* frame_host, | 70 content::RenderFrameHost* frame_host, |
74 const GURL& validated_url) { | 71 const GURL& validated_url) { |
75 scoped_ptr<base::ListValue> args(new base::ListValue()); | 72 scoped_ptr<base::ListValue> args(new base::ListValue()); |
76 base::DictionaryValue* dict = new base::DictionaryValue(); | 73 base::DictionaryValue* dict = new base::DictionaryValue(); |
77 dict->SetInteger(keys::kTabIdKey, ExtensionTabUtil::GetTabId(web_contents)); | 74 dict->SetInteger(keys::kTabIdKey, ExtensionTabUtil::GetTabId(web_contents)); |
78 dict->SetString(keys::kUrlKey, validated_url.spec()); | 75 dict->SetString(keys::kUrlKey, validated_url.spec()); |
79 dict->SetInteger(keys::kProcessIdKey, frame_host->GetProcess()->GetID()); | 76 dict->SetInteger(keys::kProcessIdKey, frame_host->GetProcess()->GetID()); |
80 dict->SetInteger(keys::kFrameIdKey, GetFrameId(frame_host)); | 77 dict->SetInteger(keys::kFrameIdKey, GetFrameId(frame_host)); |
81 dict->SetInteger(keys::kParentFrameIdKey, | 78 dict->SetInteger(keys::kParentFrameIdKey, |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); | 233 dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); |
237 args->Append(dict); | 234 args->Append(dict); |
238 | 235 |
239 DispatchEvent(browser_context, events::WEB_NAVIGATION_ON_TAB_REPLACED, | 236 DispatchEvent(browser_context, events::WEB_NAVIGATION_ON_TAB_REPLACED, |
240 web_navigation::OnTabReplaced::kEventName, args.Pass(), GURL()); | 237 web_navigation::OnTabReplaced::kEventName, args.Pass(), GURL()); |
241 } | 238 } |
242 | 239 |
243 } // namespace web_navigation_api_helpers | 240 } // namespace web_navigation_api_helpers |
244 | 241 |
245 } // namespace extensions | 242 } // namespace extensions |
OLD | NEW |