Chromium Code Reviews| 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 "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" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 | 119 |
| 120 int ExtensionViewGuest::GetTaskPrefix() const { | 120 int ExtensionViewGuest::GetTaskPrefix() const { |
| 121 return IDS_EXTENSION_TASK_MANAGER_EXTENSIONVIEW_TAG_PREFIX; | 121 return IDS_EXTENSION_TASK_MANAGER_EXTENSIONVIEW_TAG_PREFIX; |
| 122 } | 122 } |
| 123 | 123 |
| 124 // content::WebContentsObserver implementation. | 124 // content::WebContentsObserver implementation. |
| 125 void ExtensionViewGuest::DidCommitProvisionalLoadForFrame( | 125 void ExtensionViewGuest::DidCommitProvisionalLoadForFrame( |
| 126 content::RenderFrameHost* render_frame_host, | 126 content::RenderFrameHost* render_frame_host, |
| 127 const GURL& url, | 127 const GURL& url, |
| 128 ui::PageTransition transition_type) { | 128 ui::PageTransition transition_type) { |
| 129 if (!render_frame_host->GetParent()) | 129 if (!render_frame_host->GetParent()) |
|
Fady Samuel
2015/02/18 21:50:25
Since you're only using this event to update the s
apacible
2015/02/18 22:02:56
Done.
| |
| 130 view_page_ = url; | 130 view_page_ = url; |
| 131 | 131 |
| 132 // Gets chrome-extension://extensionid/ prefix. | |
| 133 std::string prefix = url.GetWithEmptyPath().spec(); | |
| 134 std::string relative_url = url.spec(); | |
| 135 | |
| 136 // Removes the prefix. | |
| 137 ReplaceFirstSubstringAfterOffset(&relative_url, 0, prefix, ""); | |
|
Fady Samuel
2015/02/18 21:50:25
Add the include for the header at the top.
apacible
2015/02/18 22:02:56
Done.
| |
| 138 | |
| 132 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 139 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 133 args->SetString(guestview::kUrl, url.spec()); | 140 args->SetString(guestview::kUrl, relative_url); |
| 134 DispatchEventToView( | 141 DispatchEventToView( |
| 135 new GuestViewBase::Event(extensionview::kEventLoadCommit, args.Pass())); | 142 new GuestViewBase::Event(extensionview::kEventLoadCommit, args.Pass())); |
| 136 } | 143 } |
| 137 | 144 |
| 138 void ExtensionViewGuest::DidNavigateMainFrame( | 145 void ExtensionViewGuest::DidNavigateMainFrame( |
| 139 const content::LoadCommittedDetails& details, | 146 const content::LoadCommittedDetails& details, |
| 140 const content::FrameNavigateParams& params) { | 147 const content::FrameNavigateParams& params) { |
| 141 if (attached() && (params.url.GetOrigin() != view_page_.GetOrigin())) { | 148 if (attached() && (params.url.GetOrigin() != view_page_.GetOrigin())) { |
| 142 base::RecordAction(base::UserMetricsAction("BadMessageTerminate_EVG")); | 149 base::RecordAction(base::UserMetricsAction("BadMessageTerminate_EVG")); |
| 143 web_contents()->GetRenderProcessHost()->Shutdown( | 150 web_contents()->GetRenderProcessHost()->Shutdown( |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 161 web_contents()->GetRenderViewHost()); | 168 web_contents()->GetRenderViewHost()); |
| 162 } | 169 } |
| 163 | 170 |
| 164 void ExtensionViewGuest::ApplyAttributes(const base::DictionaryValue& params) { | 171 void ExtensionViewGuest::ApplyAttributes(const base::DictionaryValue& params) { |
| 165 std::string src; | 172 std::string src; |
| 166 params.GetString(extensionview::kAttributeSrc, &src); | 173 params.GetString(extensionview::kAttributeSrc, &src); |
| 167 NavigateGuest(src, false /* force_navigation */); | 174 NavigateGuest(src, false /* force_navigation */); |
| 168 } | 175 } |
| 169 | 176 |
| 170 } // namespace extensions | 177 } // namespace extensions |
| OLD | NEW |