| 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/metrics/user_metrics.h" | 7 #include "base/metrics/user_metrics.h" |
| 8 #include "base/strings/string_util.h" |
| 8 #include "components/crx_file/id_util.h" | 9 #include "components/crx_file/id_util.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/guest_view/extension_view/extension_view_constants.
h" | 13 #include "extensions/browser/guest_view/extension_view/extension_view_constants.
h" |
| 13 #include "extensions/common/constants.h" | 14 #include "extensions/common/constants.h" |
| 14 #include "extensions/common/extension_messages.h" | 15 #include "extensions/common/extension_messages.h" |
| 15 #include "extensions/strings/grit/extensions_strings.h" | 16 #include "extensions/strings/grit/extensions_strings.h" |
| 16 | 17 |
| 17 using content::WebContents; | 18 using content::WebContents; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 120 |
| 120 int ExtensionViewGuest::GetTaskPrefix() const { | 121 int ExtensionViewGuest::GetTaskPrefix() const { |
| 121 return IDS_EXTENSION_TASK_MANAGER_EXTENSIONVIEW_TAG_PREFIX; | 122 return IDS_EXTENSION_TASK_MANAGER_EXTENSIONVIEW_TAG_PREFIX; |
| 122 } | 123 } |
| 123 | 124 |
| 124 // content::WebContentsObserver implementation. | 125 // content::WebContentsObserver implementation. |
| 125 void ExtensionViewGuest::DidCommitProvisionalLoadForFrame( | 126 void ExtensionViewGuest::DidCommitProvisionalLoadForFrame( |
| 126 content::RenderFrameHost* render_frame_host, | 127 content::RenderFrameHost* render_frame_host, |
| 127 const GURL& url, | 128 const GURL& url, |
| 128 ui::PageTransition transition_type) { | 129 ui::PageTransition transition_type) { |
| 129 if (!render_frame_host->GetParent()) | 130 if (render_frame_host->GetParent()) |
| 130 view_page_ = url; | 131 return; |
| 132 |
| 133 view_page_ = url; |
| 134 |
| 135 // Gets chrome-extension://extensionid/ prefix. |
| 136 std::string prefix = url.GetWithEmptyPath().spec(); |
| 137 std::string relative_url = url.spec(); |
| 138 |
| 139 // Removes the prefix. |
| 140 ReplaceFirstSubstringAfterOffset(&relative_url, 0, prefix, ""); |
| 131 | 141 |
| 132 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 142 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 133 args->SetString(guestview::kUrl, url.spec()); | 143 args->SetString(guestview::kUrl, relative_url); |
| 134 DispatchEventToView( | 144 DispatchEventToView( |
| 135 new GuestViewBase::Event(extensionview::kEventLoadCommit, args.Pass())); | 145 new GuestViewBase::Event(extensionview::kEventLoadCommit, args.Pass())); |
| 136 } | 146 } |
| 137 | 147 |
| 138 void ExtensionViewGuest::DidNavigateMainFrame( | 148 void ExtensionViewGuest::DidNavigateMainFrame( |
| 139 const content::LoadCommittedDetails& details, | 149 const content::LoadCommittedDetails& details, |
| 140 const content::FrameNavigateParams& params) { | 150 const content::FrameNavigateParams& params) { |
| 141 if (attached() && (params.url.GetOrigin() != view_page_.GetOrigin())) { | 151 if (attached() && (params.url.GetOrigin() != view_page_.GetOrigin())) { |
| 142 base::RecordAction(base::UserMetricsAction("BadMessageTerminate_EVG")); | 152 base::RecordAction(base::UserMetricsAction("BadMessageTerminate_EVG")); |
| 143 web_contents()->GetRenderProcessHost()->Shutdown( | 153 web_contents()->GetRenderProcessHost()->Shutdown( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 161 web_contents()->GetRenderViewHost()); | 171 web_contents()->GetRenderViewHost()); |
| 162 } | 172 } |
| 163 | 173 |
| 164 void ExtensionViewGuest::ApplyAttributes(const base::DictionaryValue& params) { | 174 void ExtensionViewGuest::ApplyAttributes(const base::DictionaryValue& params) { |
| 165 std::string src; | 175 std::string src; |
| 166 params.GetString(extensionview::kAttributeSrc, &src); | 176 params.GetString(extensionview::kAttributeSrc, &src); |
| 167 NavigateGuest(src, false /* force_navigation */); | 177 NavigateGuest(src, false /* force_navigation */); |
| 168 } | 178 } |
| 169 | 179 |
| 170 } // namespace extensions | 180 } // namespace extensions |
| OLD | NEW |