| 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 "components/guest_view/browser/guest_view_event.h" |
| 9 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
| 10 #include "content/public/common/result_codes.h" | 11 #include "content/public/common/result_codes.h" |
| 11 #include "extensions/browser/api/extensions_api_client.h" | 12 #include "extensions/browser/api/extensions_api_client.h" |
| 12 #include "extensions/browser/bad_message.h" | 13 #include "extensions/browser/bad_message.h" |
| 13 #include "extensions/browser/guest_view/extension_view/extension_view_constants.
h" | 14 #include "extensions/browser/guest_view/extension_view/extension_view_constants.
h" |
| 14 #include "extensions/browser/guest_view/guest_view_event.h" | |
| 15 #include "extensions/common/constants.h" | 15 #include "extensions/common/constants.h" |
| 16 #include "extensions/common/extension_messages.h" | 16 #include "extensions/common/extension_messages.h" |
| 17 #include "extensions/strings/grit/extensions_strings.h" | 17 #include "extensions/strings/grit/extensions_strings.h" |
| 18 | 18 |
| 19 using content::WebContents; | 19 using content::WebContents; |
| 20 using guestview::GuestViewBase; |
| 21 using guestview::GuestViewEvent; |
| 20 using namespace extensions::core_api; | 22 using namespace extensions::core_api; |
| 21 | 23 |
| 22 namespace extensions { | 24 namespace extensions { |
| 23 | 25 |
| 24 // static | 26 // static |
| 25 const char ExtensionViewGuest::Type[] = "extensionview"; | 27 const char ExtensionViewGuest::Type[] = "extensionview"; |
| 26 | 28 |
| 27 ExtensionViewGuest::ExtensionViewGuest( | 29 ExtensionViewGuest::ExtensionViewGuest( |
| 28 content::WebContents* owner_web_contents) | 30 content::WebContents* owner_web_contents) |
| 29 : GuestView<ExtensionViewGuest>(owner_web_contents), | 31 : GuestView<ExtensionViewGuest>(owner_web_contents), |
| 30 extension_view_guest_delegate_( | 32 extension_view_guest_delegate_( |
| 31 extensions::ExtensionsAPIClient::Get() | 33 extensions::ExtensionsAPIClient::Get() |
| 32 ->CreateExtensionViewGuestDelegate(this)) { | 34 ->CreateExtensionViewGuestDelegate(this)) { |
| 33 } | 35 } |
| 34 | 36 |
| 35 ExtensionViewGuest::~ExtensionViewGuest() { | 37 ExtensionViewGuest::~ExtensionViewGuest() { |
| 36 } | 38 } |
| 37 | 39 |
| 38 // static | 40 // static |
| 39 extensions::GuestViewBase* ExtensionViewGuest::Create( | 41 GuestViewBase* ExtensionViewGuest::Create( |
| 40 content::WebContents* owner_web_contents) { | 42 content::WebContents* owner_web_contents) { |
| 41 return new ExtensionViewGuest(owner_web_contents); | 43 return new ExtensionViewGuest(owner_web_contents); |
| 42 } | 44 } |
| 43 | 45 |
| 44 void ExtensionViewGuest::NavigateGuest(const std::string& src, | 46 void ExtensionViewGuest::NavigateGuest(const std::string& src, |
| 45 bool force_navigation) { | 47 bool force_navigation) { |
| 46 GURL url = extension_url_.Resolve(src); | 48 GURL url = extension_url_.Resolve(src); |
| 47 | 49 |
| 48 // If the URL is not valid, about:blank, or the same origin as the extension, | 50 // If the URL is not valid, about:blank, or the same origin as the extension, |
| 49 // then navigate to about:blank. | 51 // then navigate to about:blank. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 web_contents()->GetRenderViewHost()); | 173 web_contents()->GetRenderViewHost()); |
| 172 } | 174 } |
| 173 | 175 |
| 174 void ExtensionViewGuest::ApplyAttributes(const base::DictionaryValue& params) { | 176 void ExtensionViewGuest::ApplyAttributes(const base::DictionaryValue& params) { |
| 175 std::string src; | 177 std::string src; |
| 176 params.GetString(extensionview::kAttributeSrc, &src); | 178 params.GetString(extensionview::kAttributeSrc, &src); |
| 177 NavigateGuest(src, false /* force_navigation */); | 179 NavigateGuest(src, false /* force_navigation */); |
| 178 } | 180 } |
| 179 | 181 |
| 180 } // namespace extensions | 182 } // namespace extensions |
| OLD | NEW |