OLD | NEW |
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 "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "components/crx_file/id_util.h" | 8 #include "components/crx_file/id_util.h" |
9 #include "content/public/browser/render_process_host.h" | 9 #include "content/public/browser/render_process_host.h" |
10 #include "content/public/common/result_codes.h" | 10 #include "content/public/common/result_codes.h" |
11 #include "extensions/browser/api/extensions_api_client.h" | 11 #include "extensions/browser/api/extensions_api_client.h" |
12 #include "extensions/browser/bad_message.h" | 12 #include "extensions/browser/bad_message.h" |
13 #include "extensions/browser/guest_view/extension_view/extension_view_constants.
h" | 13 #include "extensions/browser/guest_view/extension_view/extension_view_constants.
h" |
| 14 #include "extensions/browser/guest_view/guest_view_event.h" |
14 #include "extensions/common/constants.h" | 15 #include "extensions/common/constants.h" |
15 #include "extensions/common/extension_messages.h" | 16 #include "extensions/common/extension_messages.h" |
16 #include "extensions/strings/grit/extensions_strings.h" | 17 #include "extensions/strings/grit/extensions_strings.h" |
17 | 18 |
18 using content::WebContents; | 19 using content::WebContents; |
19 using namespace extensions::core_api; | 20 using namespace extensions::core_api; |
20 | 21 |
21 namespace extensions { | 22 namespace extensions { |
22 | 23 |
23 // static | 24 // static |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // Gets chrome-extension://extensionid/ prefix. | 136 // Gets chrome-extension://extensionid/ prefix. |
136 std::string prefix = url.GetWithEmptyPath().spec(); | 137 std::string prefix = url.GetWithEmptyPath().spec(); |
137 std::string relative_url = url.spec(); | 138 std::string relative_url = url.spec(); |
138 | 139 |
139 // Removes the prefix. | 140 // Removes the prefix. |
140 ReplaceFirstSubstringAfterOffset(&relative_url, 0, prefix, ""); | 141 ReplaceFirstSubstringAfterOffset(&relative_url, 0, prefix, ""); |
141 | 142 |
142 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 143 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
143 args->SetString(guestview::kUrl, relative_url); | 144 args->SetString(guestview::kUrl, relative_url); |
144 DispatchEventToView( | 145 DispatchEventToView( |
145 new GuestViewBase::Event(extensionview::kEventLoadCommit, args.Pass())); | 146 new GuestViewEvent(this, extensionview::kEventLoadCommit, args.Pass())); |
146 } | 147 } |
147 | 148 |
148 void ExtensionViewGuest::DidNavigateMainFrame( | 149 void ExtensionViewGuest::DidNavigateMainFrame( |
149 const content::LoadCommittedDetails& details, | 150 const content::LoadCommittedDetails& details, |
150 const content::FrameNavigateParams& params) { | 151 const content::FrameNavigateParams& params) { |
151 if (attached() && (params.url.GetOrigin() != view_page_.GetOrigin())) { | 152 if (attached() && (params.url.GetOrigin() != view_page_.GetOrigin())) { |
152 bad_message::ReceivedBadMessage(web_contents()->GetRenderProcessHost(), | 153 bad_message::ReceivedBadMessage(web_contents()->GetRenderProcessHost(), |
153 bad_message::EVG_BAD_ORIGIN); | 154 bad_message::EVG_BAD_ORIGIN); |
154 } | 155 } |
155 } | 156 } |
(...skipping 14 matching lines...) Expand all Loading... |
170 web_contents()->GetRenderViewHost()); | 171 web_contents()->GetRenderViewHost()); |
171 } | 172 } |
172 | 173 |
173 void ExtensionViewGuest::ApplyAttributes(const base::DictionaryValue& params) { | 174 void ExtensionViewGuest::ApplyAttributes(const base::DictionaryValue& params) { |
174 std::string src; | 175 std::string src; |
175 params.GetString(extensionview::kAttributeSrc, &src); | 176 params.GetString(extensionview::kAttributeSrc, &src); |
176 NavigateGuest(src, false /* force_navigation */); | 177 NavigateGuest(src, false /* force_navigation */); |
177 } | 178 } |
178 | 179 |
179 } // namespace extensions | 180 } // namespace extensions |
OLD | NEW |