| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_options/extension_options_gues
t.h" | 5 #include "extensions/browser/guest_view/extension_options/extension_options_gues
t.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 "base/values.h" | 10 #include "base/values.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 WebContents* ExtensionOptionsGuest::OpenURLFromTab( | 161 WebContents* ExtensionOptionsGuest::OpenURLFromTab( |
| 162 WebContents* source, | 162 WebContents* source, |
| 163 const content::OpenURLParams& params) { | 163 const content::OpenURLParams& params) { |
| 164 if (!extension_options_guest_delegate_) | 164 if (!extension_options_guest_delegate_) |
| 165 return nullptr; | 165 return nullptr; |
| 166 | 166 |
| 167 // Don't allow external URLs with the CURRENT_TAB disposition be opened in | 167 // Don't allow external URLs with the CURRENT_TAB disposition be opened in |
| 168 // this guest view, change the disposition to NEW_FOREGROUND_TAB. | 168 // this guest view, change the disposition to NEW_FOREGROUND_TAB. |
| 169 if ((!params.url.SchemeIs(extensions::kExtensionScheme) || | 169 if ((!params.url.SchemeIs(extensions::kExtensionScheme) || |
| 170 params.url.host() != options_page_.host()) && | 170 params.url.host() != options_page_.host()) && |
| 171 params.disposition == CURRENT_TAB) { | 171 params.disposition == WindowOpenDisposition::CURRENT_TAB) { |
| 172 return extension_options_guest_delegate_->OpenURLInNewTab( | 172 return extension_options_guest_delegate_->OpenURLInNewTab( |
| 173 content::OpenURLParams(params.url, | 173 content::OpenURLParams( |
| 174 params.referrer, | 174 params.url, params.referrer, params.frame_tree_node_id, |
| 175 params.frame_tree_node_id, | 175 WindowOpenDisposition::NEW_FOREGROUND_TAB, params.transition, |
| 176 NEW_FOREGROUND_TAB, | 176 params.is_renderer_initiated)); |
| 177 params.transition, | |
| 178 params.is_renderer_initiated)); | |
| 179 } | 177 } |
| 180 return extension_options_guest_delegate_->OpenURLInNewTab(params); | 178 return extension_options_guest_delegate_->OpenURLInNewTab(params); |
| 181 } | 179 } |
| 182 | 180 |
| 183 void ExtensionOptionsGuest::CloseContents(WebContents* source) { | 181 void ExtensionOptionsGuest::CloseContents(WebContents* source) { |
| 184 DispatchEventToView(base::MakeUnique<GuestViewEvent>( | 182 DispatchEventToView(base::MakeUnique<GuestViewEvent>( |
| 185 extension_options_internal::OnClose::kEventName, | 183 extension_options_internal::OnClose::kEventName, |
| 186 base::WrapUnique(new base::DictionaryValue()))); | 184 base::WrapUnique(new base::DictionaryValue()))); |
| 187 } | 185 } |
| 188 | 186 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 206 content::SessionStorageNamespace* session_storage_namespace) { | 204 content::SessionStorageNamespace* session_storage_namespace) { |
| 207 // This method handles opening links from within the guest. Since this guest | 205 // This method handles opening links from within the guest. Since this guest |
| 208 // view is used for displaying embedded extension options, we want any | 206 // view is used for displaying embedded extension options, we want any |
| 209 // external links to be opened in a new tab, not in a new guest view. | 207 // external links to be opened in a new tab, not in a new guest view. |
| 210 // Therefore we just open the URL in a new tab, and since we aren't handling | 208 // Therefore we just open the URL in a new tab, and since we aren't handling |
| 211 // the new web contents, we return false. | 209 // the new web contents, we return false. |
| 212 // TODO(ericzeng): Open the tab in the background if the click was a | 210 // TODO(ericzeng): Open the tab in the background if the click was a |
| 213 // ctrl-click or middle mouse button click | 211 // ctrl-click or middle mouse button click |
| 214 if (extension_options_guest_delegate_) { | 212 if (extension_options_guest_delegate_) { |
| 215 extension_options_guest_delegate_->OpenURLInNewTab( | 213 extension_options_guest_delegate_->OpenURLInNewTab( |
| 216 content::OpenURLParams(target_url, | 214 content::OpenURLParams(target_url, content::Referrer(), |
| 217 content::Referrer(), | 215 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 218 NEW_FOREGROUND_TAB, | 216 ui::PAGE_TRANSITION_LINK, false)); |
| 219 ui::PAGE_TRANSITION_LINK, | |
| 220 false)); | |
| 221 } | 217 } |
| 222 return false; | 218 return false; |
| 223 } | 219 } |
| 224 | 220 |
| 225 void ExtensionOptionsGuest::DidNavigateMainFrame( | 221 void ExtensionOptionsGuest::DidNavigateMainFrame( |
| 226 const content::LoadCommittedDetails& details, | 222 const content::LoadCommittedDetails& details, |
| 227 const content::FrameNavigateParams& params) { | 223 const content::FrameNavigateParams& params) { |
| 228 if (attached()) { | 224 if (attached()) { |
| 229 auto* guest_zoom_controller = | 225 auto* guest_zoom_controller = |
| 230 zoom::ZoomController::FromWebContents(web_contents()); | 226 zoom::ZoomController::FromWebContents(web_contents()); |
| 231 guest_zoom_controller->SetZoomMode( | 227 guest_zoom_controller->SetZoomMode( |
| 232 zoom::ZoomController::ZOOM_MODE_ISOLATED); | 228 zoom::ZoomController::ZOOM_MODE_ISOLATED); |
| 233 SetGuestZoomLevelToMatchEmbedder(); | 229 SetGuestZoomLevelToMatchEmbedder(); |
| 234 | 230 |
| 235 if (!url::IsSameOriginWith(params.url, options_page_)) { | 231 if (!url::IsSameOriginWith(params.url, options_page_)) { |
| 236 bad_message::ReceivedBadMessage(web_contents()->GetRenderProcessHost(), | 232 bad_message::ReceivedBadMessage(web_contents()->GetRenderProcessHost(), |
| 237 bad_message::EOG_BAD_ORIGIN); | 233 bad_message::EOG_BAD_ORIGIN); |
| 238 } | 234 } |
| 239 } | 235 } |
| 240 } | 236 } |
| 241 | 237 |
| 242 } // namespace extensions | 238 } // namespace extensions |
| OLD | NEW |