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 "components/crx_file/id_util.h" | 7 #include "components/crx_file/id_util.h" |
8 #include "components/guest_view/browser/guest_view_event.h" | 8 #include "components/guest_view/browser/guest_view_event.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/common/constants.h" | 14 #include "extensions/common/constants.h" |
15 #include "extensions/common/extension_messages.h" | 15 #include "extensions/common/extension_messages.h" |
16 #include "extensions/strings/grit/extensions_strings.h" | 16 #include "extensions/strings/grit/extensions_strings.h" |
17 | 17 |
18 using content::WebContents; | 18 using content::WebContents; |
19 using guest_view::GuestViewBase; | 19 using guest_view::GuestViewBase; |
20 using guest_view::GuestViewEvent; | 20 using guest_view::GuestViewEvent; |
21 using namespace extensions::api; | 21 using namespace extensions::api; |
22 | 22 |
23 namespace extensions { | 23 namespace extensions { |
24 | 24 |
25 // static | 25 // static |
26 const char ExtensionViewGuest::Type[] = "extensionview"; | 26 const char ExtensionViewGuest::Type[] = "extensionview"; |
27 | 27 |
28 ExtensionViewGuest::ExtensionViewGuest( | 28 ExtensionViewGuest::ExtensionViewGuest(WebContents* owner_web_contents) |
29 content::WebContents* owner_web_contents) | 29 : GuestView<ExtensionViewGuest>(owner_web_contents) {} |
30 : GuestView<ExtensionViewGuest>(owner_web_contents) { | |
31 } | |
32 | 30 |
33 ExtensionViewGuest::~ExtensionViewGuest() { | 31 ExtensionViewGuest::~ExtensionViewGuest() { |
34 } | 32 } |
35 | 33 |
36 // static | 34 // static |
37 GuestViewBase* ExtensionViewGuest::Create( | 35 GuestViewBase* ExtensionViewGuest::Create(WebContents* owner_web_contents) { |
38 content::WebContents* owner_web_contents) { | |
39 return new ExtensionViewGuest(owner_web_contents); | 36 return new ExtensionViewGuest(owner_web_contents); |
40 } | 37 } |
41 | 38 |
42 bool ExtensionViewGuest::NavigateGuest(const std::string& src, | 39 bool ExtensionViewGuest::NavigateGuest(const std::string& src, |
43 bool force_navigation) { | 40 bool force_navigation) { |
44 GURL url = extension_url_.Resolve(src); | 41 GURL url = extension_url_.Resolve(src); |
45 | 42 |
46 // If the URL is not valid, about:blank, or the same origin as the extension, | 43 // If the URL is not valid, about:blank, or the same origin as the extension, |
47 // then navigate to about:blank. | 44 // then navigate to about:blank. |
48 bool url_not_allowed = (url != GURL(url::kAboutBlankURL)) && | 45 bool url_not_allowed = (url != GURL(url::kAboutBlankURL)) && |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 106 } |
110 | 107 |
111 const char* ExtensionViewGuest::GetAPINamespace() const { | 108 const char* ExtensionViewGuest::GetAPINamespace() const { |
112 return extensionview::kAPINamespace; | 109 return extensionview::kAPINamespace; |
113 } | 110 } |
114 | 111 |
115 int ExtensionViewGuest::GetTaskPrefix() const { | 112 int ExtensionViewGuest::GetTaskPrefix() const { |
116 return IDS_EXTENSION_TASK_MANAGER_EXTENSIONVIEW_TAG_PREFIX; | 113 return IDS_EXTENSION_TASK_MANAGER_EXTENSIONVIEW_TAG_PREFIX; |
117 } | 114 } |
118 | 115 |
119 // content::WebContentsObserver implementation. | |
120 void ExtensionViewGuest::DidCommitProvisionalLoadForFrame( | 116 void ExtensionViewGuest::DidCommitProvisionalLoadForFrame( |
121 content::RenderFrameHost* render_frame_host, | 117 content::RenderFrameHost* render_frame_host, |
122 const GURL& url, | 118 const GURL& url, |
123 ui::PageTransition transition_type) { | 119 ui::PageTransition transition_type) { |
124 if (render_frame_host->GetParent()) | 120 if (render_frame_host->GetParent()) |
125 return; | 121 return; |
126 | 122 |
127 url_ = url; | 123 url_ = url; |
128 | 124 |
129 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 125 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
(...skipping 11 matching lines...) Expand all Loading... |
141 } | 137 } |
142 } | 138 } |
143 | 139 |
144 void ExtensionViewGuest::ApplyAttributes(const base::DictionaryValue& params) { | 140 void ExtensionViewGuest::ApplyAttributes(const base::DictionaryValue& params) { |
145 std::string src; | 141 std::string src; |
146 params.GetString(extensionview::kAttributeSrc, &src); | 142 params.GetString(extensionview::kAttributeSrc, &src); |
147 NavigateGuest(src, false /* force_navigation */); | 143 NavigateGuest(src, false /* force_navigation */); |
148 } | 144 } |
149 | 145 |
150 } // namespace extensions | 146 } // namespace extensions |
OLD | NEW |