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 <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" |
(...skipping 29 matching lines...) Expand all Loading... |
40 GuestViewBase* ExtensionViewGuest::Create(WebContents* owner_web_contents) { | 40 GuestViewBase* ExtensionViewGuest::Create(WebContents* owner_web_contents) { |
41 return new ExtensionViewGuest(owner_web_contents); | 41 return new ExtensionViewGuest(owner_web_contents); |
42 } | 42 } |
43 | 43 |
44 bool ExtensionViewGuest::NavigateGuest(const std::string& src, | 44 bool ExtensionViewGuest::NavigateGuest(const std::string& src, |
45 bool force_navigation) { | 45 bool force_navigation) { |
46 GURL url = extension_url_.Resolve(src); | 46 GURL url = extension_url_.Resolve(src); |
47 | 47 |
48 // If the URL is not valid, about:blank, or the same origin as the extension, | 48 // If the URL is not valid, about:blank, or the same origin as the extension, |
49 // then navigate to about:blank. | 49 // then navigate to about:blank. |
50 bool url_not_allowed = url != GURL(url::kAboutBlankURL) && | 50 bool url_not_allowed = |
51 !url::IsSameOriginWith(url, extension_url_); | 51 url != url::kAboutBlankURL && !url::IsSameOriginWith(url, extension_url_); |
52 if (!url.is_valid() || url_not_allowed) | 52 if (!url.is_valid() || url_not_allowed) |
53 return NavigateGuest(url::kAboutBlankURL, true /* force_navigation */); | 53 return NavigateGuest(url::kAboutBlankURL, true /* force_navigation */); |
54 | 54 |
55 if (!force_navigation && (url_ == url)) | 55 if (!force_navigation && (url_ == url)) |
56 return false; | 56 return false; |
57 | 57 |
58 web_contents()->GetRenderProcessHost()->FilterURL(false, &url); | 58 web_contents()->GetRenderProcessHost()->FilterURL(false, &url); |
59 web_contents()->GetController().LoadURL(url, content::Referrer(), | 59 web_contents()->GetController().LoadURL(url, content::Referrer(), |
60 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 60 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
61 std::string()); | 61 std::string()); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 void ExtensionViewGuest::ApplyAttributes(const base::DictionaryValue& params) { | 144 void ExtensionViewGuest::ApplyAttributes(const base::DictionaryValue& params) { |
145 std::string src; | 145 std::string src; |
146 params.GetString(extensionview::kAttributeSrc, &src); | 146 params.GetString(extensionview::kAttributeSrc, &src); |
147 NavigateGuest(src, false /* force_navigation */); | 147 NavigateGuest(src, false /* force_navigation */); |
148 } | 148 } |
149 | 149 |
150 } // namespace extensions | 150 } // namespace extensions |
OLD | NEW |