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

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

Issue 2541063002: Revert of Remove about:srcdoc url conversion. (Closed)
Patch Set: Created 4 years 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 event->filter_info = info; 57 event->filter_info = info;
58 event_router->BroadcastEvent(std::move(event)); 58 event_router->BroadcastEvent(std::move(event));
59 } 59 }
60 } 60 }
61 61
62 } // namespace 62 } // namespace
63 63
64 // Constructs and dispatches an onBeforeNavigate event. 64 // Constructs and dispatches an onBeforeNavigate event.
65 void DispatchOnBeforeNavigate(content::NavigationHandle* navigation_handle) { 65 void DispatchOnBeforeNavigate(content::NavigationHandle* navigation_handle) {
66 GURL url(navigation_handle->GetURL()); 66 GURL url(navigation_handle->GetURL());
67 if (navigation_handle->IsSrcdoc())
68 url = GURL(content::kAboutSrcDocURL);
67 69
68 web_navigation::OnBeforeNavigate::Details details; 70 web_navigation::OnBeforeNavigate::Details details;
69 details.tab_id = 71 details.tab_id =
70 ExtensionTabUtil::GetTabId(navigation_handle->GetWebContents()); 72 ExtensionTabUtil::GetTabId(navigation_handle->GetWebContents());
71 details.url = url.spec(); 73 details.url = url.spec();
72 details.process_id = -1; 74 details.process_id = -1;
73 details.frame_id = ExtensionApiFrameIdMap::GetFrameId(navigation_handle); 75 details.frame_id = ExtensionApiFrameIdMap::GetFrameId(navigation_handle);
74 details.parent_frame_id = 76 details.parent_frame_id =
75 ExtensionApiFrameIdMap::GetParentFrameId(navigation_handle); 77 ExtensionApiFrameIdMap::GetParentFrameId(navigation_handle);
76 details.time_stamp = MilliSecondsFromTime(base::Time::Now()); 78 details.time_stamp = MilliSecondsFromTime(base::Time::Now());
(...skipping 10 matching lines...) Expand all
87 // event. 89 // event.
88 void DispatchOnCommitted(events::HistogramValue histogram_value, 90 void DispatchOnCommitted(events::HistogramValue histogram_value,
89 const std::string& event_name, 91 const std::string& event_name,
90 content::NavigationHandle* navigation_handle) { 92 content::NavigationHandle* navigation_handle) {
91 content::WebContents* web_contents = navigation_handle->GetWebContents(); 93 content::WebContents* web_contents = navigation_handle->GetWebContents();
92 GURL url(navigation_handle->GetURL()); 94 GURL url(navigation_handle->GetURL());
93 content::RenderFrameHost* frame_host = 95 content::RenderFrameHost* frame_host =
94 navigation_handle->GetRenderFrameHost(); 96 navigation_handle->GetRenderFrameHost();
95 ui::PageTransition transition_type = navigation_handle->GetPageTransition(); 97 ui::PageTransition transition_type = navigation_handle->GetPageTransition();
96 98
99 if (navigation_handle->IsSrcdoc())
100 url = GURL(content::kAboutSrcDocURL);
101
97 std::unique_ptr<base::ListValue> args(new base::ListValue()); 102 std::unique_ptr<base::ListValue> args(new base::ListValue());
98 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 103 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
99 dict->SetInteger(keys::kTabIdKey, ExtensionTabUtil::GetTabId(web_contents)); 104 dict->SetInteger(keys::kTabIdKey, ExtensionTabUtil::GetTabId(web_contents));
100 dict->SetString(keys::kUrlKey, url.spec()); 105 dict->SetString(keys::kUrlKey, url.spec());
101 dict->SetInteger(keys::kProcessIdKey, frame_host->GetProcess()->GetID()); 106 dict->SetInteger(keys::kProcessIdKey, frame_host->GetProcess()->GetID());
102 dict->SetInteger(keys::kFrameIdKey, 107 dict->SetInteger(keys::kFrameIdKey,
103 ExtensionApiFrameIdMap::GetFrameId(frame_host)); 108 ExtensionApiFrameIdMap::GetFrameId(frame_host));
104 109
105 if (navigation_handle->WasServerRedirect()) { 110 if (navigation_handle->WasServerRedirect()) {
106 transition_type = ui::PageTransitionFromInt( 111 transition_type = ui::PageTransitionFromInt(
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 std::unique_ptr<Event> event( 258 std::unique_ptr<Event> event(
254 new Event(events::WEB_NAVIGATION_ON_TAB_REPLACED, 259 new Event(events::WEB_NAVIGATION_ON_TAB_REPLACED,
255 web_navigation::OnTabReplaced::kEventName, 260 web_navigation::OnTabReplaced::kEventName,
256 web_navigation::OnTabReplaced::Create(details))); 261 web_navigation::OnTabReplaced::Create(details)));
257 DispatchEvent(browser_context, std::move(event), GURL()); 262 DispatchEvent(browser_context, std::move(event), GURL());
258 } 263 }
259 264
260 } // namespace web_navigation_api_helpers 265 } // namespace web_navigation_api_helpers
261 266
262 } // namespace extensions 267 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698