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: extensions/browser/guest_view/extension_view/extension_view_guest.cc

Issue 2659773003: Convert ExtensionViewGuest to use the new navigation callbacks. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « extensions/browser/guest_view/extension_view/extension_view_guest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "extensions/browser/guest_view/extension_view/extension_view_guest.h" 5 #include "extensions/browser/guest_view/extension_view/extension_view_guest.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "components/crx_file/id_util.h" 10 #include "components/crx_file/id_util.h"
11 #include "components/guest_view/browser/guest_view_event.h" 11 #include "components/guest_view/browser/guest_view_event.h"
12 #include "content/public/browser/navigation_handle.h"
12 #include "content/public/browser/render_process_host.h" 13 #include "content/public/browser/render_process_host.h"
13 #include "content/public/common/result_codes.h" 14 #include "content/public/common/result_codes.h"
14 #include "extensions/browser/api/extensions_api_client.h" 15 #include "extensions/browser/api/extensions_api_client.h"
15 #include "extensions/browser/bad_message.h" 16 #include "extensions/browser/bad_message.h"
16 #include "extensions/browser/guest_view/extension_view/extension_view_constants. h" 17 #include "extensions/browser/guest_view/extension_view/extension_view_constants. h"
17 #include "extensions/browser/guest_view/extension_view/whitelist/extension_view_ whitelist.h" 18 #include "extensions/browser/guest_view/extension_view/whitelist/extension_view_ whitelist.h"
18 #include "extensions/common/constants.h" 19 #include "extensions/common/constants.h"
19 #include "extensions/common/extension_messages.h" 20 #include "extensions/common/extension_messages.h"
20 #include "extensions/strings/grit/extensions_strings.h" 21 #include "extensions/strings/grit/extensions_strings.h"
21 #include "url/origin.h" 22 #include "url/origin.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 111 }
111 112
112 const char* ExtensionViewGuest::GetAPINamespace() const { 113 const char* ExtensionViewGuest::GetAPINamespace() const {
113 return extensionview::kAPINamespace; 114 return extensionview::kAPINamespace;
114 } 115 }
115 116
116 int ExtensionViewGuest::GetTaskPrefix() const { 117 int ExtensionViewGuest::GetTaskPrefix() const {
117 return IDS_EXTENSION_TASK_MANAGER_EXTENSIONVIEW_TAG_PREFIX; 118 return IDS_EXTENSION_TASK_MANAGER_EXTENSIONVIEW_TAG_PREFIX;
118 } 119 }
119 120
120 void ExtensionViewGuest::DidCommitProvisionalLoadForFrame( 121 void ExtensionViewGuest::DidFinishNavigation(
121 content::RenderFrameHost* render_frame_host, 122 content::NavigationHandle* navigation_handle) {
122 const GURL& url, 123 if (!navigation_handle->HasCommitted() || !navigation_handle->IsInMainFrame())
123 ui::PageTransition transition_type) {
124 if (render_frame_host->GetParent())
125 return; 124 return;
126 125
127 url_ = url; 126 url_ = navigation_handle->GetURL();
128 127
129 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 128 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
130 args->SetString(guest_view::kUrl, url_.spec()); 129 args->SetString(guest_view::kUrl, url_.spec());
131 DispatchEventToView(base::MakeUnique<GuestViewEvent>( 130 DispatchEventToView(base::MakeUnique<GuestViewEvent>(
132 extensionview::kEventLoadCommit, std::move(args))); 131 extensionview::kEventLoadCommit, std::move(args)));
133 } 132 }
134 133
135 void ExtensionViewGuest::DidNavigateMainFrame(
136 const content::LoadCommittedDetails& details,
137 const content::FrameNavigateParams& params) {
138 if (attached() && !url::IsSameOriginWith(params.url, url_)) {
Fady Samuel 2017/01/26 23:39:07 Do we want to allow navigating to a different orig
jam 2017/01/26 23:40:20 well before there were two different navigation ca
139 bad_message::ReceivedBadMessage(web_contents()->GetRenderProcessHost(),
140 bad_message::EVG_BAD_ORIGIN);
141 }
142 }
143
144 void ExtensionViewGuest::ApplyAttributes(const base::DictionaryValue& params) { 134 void ExtensionViewGuest::ApplyAttributes(const base::DictionaryValue& params) {
145 std::string src; 135 std::string src;
146 params.GetString(extensionview::kAttributeSrc, &src); 136 params.GetString(extensionview::kAttributeSrc, &src);
147 NavigateGuest(src, false /* force_navigation */); 137 NavigateGuest(src, false /* force_navigation */);
148 } 138 }
149 139
150 } // namespace extensions 140 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/guest_view/extension_view/extension_view_guest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698