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 "chrome/browser/guest_view/web_view/web_view_guest.h" | 5 #include "chrome/browser/guest_view/web_view/web_view_guest.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 NOTREACHED(); | 328 NOTREACHED(); |
329 } | 329 } |
330 | 330 |
331 // Once a new guest is attached to the DOM of the embedder page, then the | 331 // Once a new guest is attached to the DOM of the embedder page, then the |
332 // lifetime of the new guest is no longer managed by the opener guest. | 332 // lifetime of the new guest is no longer managed by the opener guest. |
333 GetOpener()->pending_new_windows_.erase(this); | 333 GetOpener()->pending_new_windows_.erase(this); |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 void WebViewGuest::DidInitialize() { | 337 void WebViewGuest::DidInitialize() { |
338 script_executor_.reset(new extensions::ScriptExecutor(guest_web_contents(), | 338 script_executor_.reset( |
339 &script_observers_)); | 339 new ScriptExecutor(guest_web_contents(), &script_observers_)); |
Fady Samuel
2014/08/12 21:25:30
Can this go on the previous line?
Xi Han
2014/08/12 21:53:48
This line exceeds the limit.
| |
340 | 340 |
341 notification_registrar_.Add( | 341 notification_registrar_.Add( |
342 this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 342 this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
343 content::Source<WebContents>(guest_web_contents())); | 343 content::Source<WebContents>(guest_web_contents())); |
344 | 344 |
345 notification_registrar_.Add( | 345 notification_registrar_.Add( |
346 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, | 346 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, |
347 content::Source<WebContents>(guest_web_contents())); | 347 content::Source<WebContents>(guest_web_contents())); |
348 | 348 |
349 #if defined(OS_CHROMEOS) | 349 #if defined(OS_CHROMEOS) |
(...skipping 11 matching lines...) Expand all Loading... | |
361 void WebViewGuest::AttachWebViewHelpers(WebContents* contents) { | 361 void WebViewGuest::AttachWebViewHelpers(WebContents* contents) { |
362 // Create a zoom controller for the guest contents give it access to | 362 // Create a zoom controller for the guest contents give it access to |
363 // GetZoomLevel() and and SetZoomLevel() in WebViewGuest. | 363 // GetZoomLevel() and and SetZoomLevel() in WebViewGuest. |
364 // TODO(wjmaclean) This currently uses the same HostZoomMap as the browser | 364 // TODO(wjmaclean) This currently uses the same HostZoomMap as the browser |
365 // context, but we eventually want to isolate the guest contents from zoom | 365 // context, but we eventually want to isolate the guest contents from zoom |
366 // changes outside the guest (e.g. in the main browser), so we should | 366 // changes outside the guest (e.g. in the main browser), so we should |
367 // create a separate HostZoomMap for the guest. | 367 // create a separate HostZoomMap for the guest. |
368 ZoomController::CreateForWebContents(contents); | 368 ZoomController::CreateForWebContents(contents); |
369 | 369 |
370 FaviconTabHelper::CreateForWebContents(contents); | 370 FaviconTabHelper::CreateForWebContents(contents); |
371 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( | 371 ChromeExtensionWebContentsObserver::CreateForWebContents(contents); |
372 contents); | |
373 #if defined(ENABLE_PRINTING) | 372 #if defined(ENABLE_PRINTING) |
374 #if defined(ENABLE_FULL_PRINTING) | 373 #if defined(ENABLE_FULL_PRINTING) |
375 printing::PrintViewManager::CreateForWebContents(contents); | 374 printing::PrintViewManager::CreateForWebContents(contents); |
376 printing::PrintPreviewMessageHandler::CreateForWebContents(contents); | 375 printing::PrintPreviewMessageHandler::CreateForWebContents(contents); |
377 #else | 376 #else |
378 printing::PrintViewManagerBasic::CreateForWebContents(contents); | 377 printing::PrintViewManagerBasic::CreateForWebContents(contents); |
379 #endif // defined(ENABLE_FULL_PRINTING) | 378 #endif // defined(ENABLE_FULL_PRINTING) |
380 #endif // defined(ENABLE_PRINTING) | 379 #endif // defined(ENABLE_PRINTING) |
381 PDFTabHelper::CreateForWebContents(contents); | 380 PDFTabHelper::CreateForWebContents(contents); |
382 web_view_permission_helper_.reset(new WebViewPermissionHelper(this)); | 381 web_view_permission_helper_.reset(new WebViewPermissionHelper(this)); |
(...skipping 18 matching lines...) Expand all Loading... | |
401 FROM_HERE, | 400 FROM_HERE, |
402 base::Bind( | 401 base::Bind( |
403 &RemoveWebViewEventListenersOnIOThread, | 402 &RemoveWebViewEventListenersOnIOThread, |
404 browser_context(), embedder_extension_id(), | 403 browser_context(), embedder_extension_id(), |
405 embedder_render_process_id(), | 404 embedder_render_process_id(), |
406 view_instance_id())); | 405 view_instance_id())); |
407 } | 406 } |
408 | 407 |
409 void WebViewGuest::GuestDestroyed() { | 408 void WebViewGuest::GuestDestroyed() { |
410 // Clean up custom context menu items for this guest. | 409 // Clean up custom context menu items for this guest. |
411 extensions::MenuManager* menu_manager = extensions::MenuManager::Get( | 410 MenuManager* menu_manager = MenuManager::Get( |
412 Profile::FromBrowserContext(browser_context())); | 411 Profile::FromBrowserContext(browser_context())); |
413 menu_manager->RemoveAllContextItems(extensions::MenuItem::ExtensionKey( | 412 menu_manager->RemoveAllContextItems(MenuItem::ExtensionKey( |
414 embedder_extension_id(), view_instance_id())); | 413 embedder_extension_id(), view_instance_id())); |
415 | 414 |
416 RemoveWebViewStateFromIOThread(web_contents()); | 415 RemoveWebViewStateFromIOThread(web_contents()); |
417 } | 416 } |
418 | 417 |
419 void WebViewGuest::GuestReady() { | 418 void WebViewGuest::GuestReady() { |
420 // The guest RenderView should always live in an isolated guest process. | 419 // The guest RenderView should always live in an isolated guest process. |
421 CHECK(guest_web_contents()->GetRenderProcessHost()->IsIsolatedGuest()); | 420 CHECK(guest_web_contents()->GetRenderProcessHost()->IsIsolatedGuest()); |
422 Send(new ChromeViewMsg_SetName(guest_web_contents()->GetRoutingID(), name_)); | 421 Send(new ChromeViewMsg_SetName(guest_web_contents()->GetRoutingID(), name_)); |
423 } | 422 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 } | 633 } |
635 } | 634 } |
636 | 635 |
637 double WebViewGuest::GetZoom() { | 636 double WebViewGuest::GetZoom() { |
638 return current_zoom_factor_; | 637 return current_zoom_factor_; |
639 } | 638 } |
640 | 639 |
641 void WebViewGuest::Find( | 640 void WebViewGuest::Find( |
642 const base::string16& search_text, | 641 const base::string16& search_text, |
643 const blink::WebFindOptions& options, | 642 const blink::WebFindOptions& options, |
644 scoped_refptr<extensions::WebViewInternalFindFunction> find_function) { | 643 scoped_refptr<WebViewInternalFindFunction> find_function) { |
645 find_helper_.Find(guest_web_contents(), search_text, options, find_function); | 644 find_helper_.Find(guest_web_contents(), search_text, options, find_function); |
646 } | 645 } |
647 | 646 |
648 void WebViewGuest::StopFinding(content::StopFindAction action) { | 647 void WebViewGuest::StopFinding(content::StopFindAction action) { |
649 find_helper_.CancelAllFindSessions(); | 648 find_helper_.CancelAllFindSessions(); |
650 guest_web_contents()->StopFinding(action); | 649 guest_web_contents()->StopFinding(action); |
651 } | 650 } |
652 | 651 |
653 void WebViewGuest::Go(int relative_index) { | 652 void WebViewGuest::Go(int relative_index) { |
654 guest_web_contents()->GetController().GoToOffset(relative_index); | 653 guest_web_contents()->GetController().GoToOffset(relative_index); |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1237 DCHECK(pending_new_windows_.empty()); | 1236 DCHECK(pending_new_windows_.empty()); |
1238 } | 1237 } |
1239 | 1238 |
1240 GURL WebViewGuest::ResolveURL(const std::string& src) { | 1239 GURL WebViewGuest::ResolveURL(const std::string& src) { |
1241 if (!in_extension()) { | 1240 if (!in_extension()) { |
1242 NOTREACHED(); | 1241 NOTREACHED(); |
1243 return GURL(src); | 1242 return GURL(src); |
1244 } | 1243 } |
1245 | 1244 |
1246 GURL default_url(base::StringPrintf("%s://%s/", | 1245 GURL default_url(base::StringPrintf("%s://%s/", |
1247 extensions::kExtensionScheme, | 1246 kExtensionScheme, |
1248 embedder_extension_id().c_str())); | 1247 embedder_extension_id().c_str())); |
1249 return default_url.Resolve(src); | 1248 return default_url.Resolve(src); |
1250 } | 1249 } |
1251 | 1250 |
1252 void WebViewGuest::OnWebViewNewWindowResponse( | 1251 void WebViewGuest::OnWebViewNewWindowResponse( |
1253 int new_window_instance_id, | 1252 int new_window_instance_id, |
1254 bool allow, | 1253 bool allow, |
1255 const std::string& user_input) { | 1254 const std::string& user_input) { |
1256 WebViewGuest* guest = | 1255 WebViewGuest* guest = |
1257 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1256 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
1258 if (!guest) | 1257 if (!guest) |
1259 return; | 1258 return; |
1260 | 1259 |
1261 if (!allow) | 1260 if (!allow) |
1262 guest->Destroy(); | 1261 guest->Destroy(); |
1263 } | 1262 } |
1264 | 1263 |
1265 } // namespace extensions | 1264 } // namespace extensions |
OLD | NEW |