| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/guestview/webview/webview_guest.h" | 5 #include "chrome/browser/guestview/webview/webview_guest.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 8 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| 9 #include "chrome/browser/extensions/extension_renderer_state.h" | 9 #include "chrome/browser/extensions/extension_renderer_state.h" |
| 10 #include "chrome/browser/extensions/script_executor.h" | 10 #include "chrome/browser/extensions/script_executor.h" |
| 11 #include "chrome/browser/favicon/favicon_tab_helper.h" | 11 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 12 #include "chrome/browser/guestview/guestview_constants.h" | 12 #include "chrome/browser/guestview/guestview_constants.h" |
| 13 #include "chrome/browser/guestview/webview/webview_constants.h" | 13 #include "chrome/browser/guestview/webview/webview_constants.h" |
| 14 #include "chrome/common/chrome_version_info.h" | 14 #include "chrome/common/chrome_version_info.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/native_web_keyboard_event.h" | 16 #include "content/public/browser/native_web_keyboard_event.h" |
| 17 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
| 18 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
| 19 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
| 20 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
| 21 #include "content/public/browser/resource_request_details.h" | 21 #include "content/public/browser/resource_request_details.h" |
| 22 #include "content/public/browser/site_instance.h" |
| 22 #include "content/public/browser/storage_partition.h" | 23 #include "content/public/browser/storage_partition.h" |
| 23 #include "content/public/browser/user_metrics.h" | 24 #include "content/public/browser/user_metrics.h" |
| 24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 25 #include "content/public/common/content_switches.h" | 26 #include "content/public/common/content_switches.h" |
| 26 #include "content/public/common/result_codes.h" | 27 #include "content/public/common/result_codes.h" |
| 27 #include "net/base/net_errors.h" | 28 #include "net/base/net_errors.h" |
| 28 | 29 |
| 29 using content::WebContents; | 30 using content::WebContents; |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 const GURL& new_url, | 465 const GURL& new_url, |
| 465 bool is_top_level) { | 466 bool is_top_level) { |
| 466 scoped_ptr<DictionaryValue> args(new DictionaryValue()); | 467 scoped_ptr<DictionaryValue> args(new DictionaryValue()); |
| 467 args->SetBoolean(guestview::kIsTopLevel, is_top_level); | 468 args->SetBoolean(guestview::kIsTopLevel, is_top_level); |
| 468 args->SetString(webview::kNewURL, new_url.spec()); | 469 args->SetString(webview::kNewURL, new_url.spec()); |
| 469 args->SetString(webview::kOldURL, old_url.spec()); | 470 args->SetString(webview::kOldURL, old_url.spec()); |
| 470 DispatchEvent(new GuestView::Event(webview::kEventLoadRedirect, args.Pass())); | 471 DispatchEvent(new GuestView::Event(webview::kEventLoadRedirect, args.Pass())); |
| 471 } | 472 } |
| 472 | 473 |
| 473 void WebViewGuest::AddWebViewToExtensionRendererState() { | 474 void WebViewGuest::AddWebViewToExtensionRendererState() { |
| 475 const GURL& site_url = web_contents()->GetSiteInstance()->GetSiteURL(); |
| 474 ExtensionRendererState::WebViewInfo webview_info; | 476 ExtensionRendererState::WebViewInfo webview_info; |
| 475 webview_info.embedder_process_id = embedder_render_process_id(); | 477 webview_info.embedder_process_id = embedder_render_process_id(); |
| 476 webview_info.instance_id = view_instance_id(); | 478 webview_info.instance_id = view_instance_id(); |
| 479 // TODO(fsamuel): Partition IDs should probably be a chrome-only concept. They |
| 480 // should probably be passed in via attach args. |
| 481 webview_info.partition_id = site_url.query(); |
| 477 | 482 |
| 478 content::BrowserThread::PostTask( | 483 content::BrowserThread::PostTask( |
| 479 content::BrowserThread::IO, FROM_HERE, | 484 content::BrowserThread::IO, FROM_HERE, |
| 480 base::Bind( | 485 base::Bind( |
| 481 &ExtensionRendererState::AddWebView, | 486 &ExtensionRendererState::AddWebView, |
| 482 base::Unretained(ExtensionRendererState::GetInstance()), | 487 base::Unretained(ExtensionRendererState::GetInstance()), |
| 483 guest_web_contents()->GetRenderProcessHost()->GetID(), | 488 guest_web_contents()->GetRenderProcessHost()->GetID(), |
| 484 guest_web_contents()->GetRoutingID(), | 489 guest_web_contents()->GetRoutingID(), |
| 485 webview_info)); | 490 webview_info)); |
| 486 } | 491 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 499 | 504 |
| 500 void WebViewGuest::SizeChanged(const gfx::Size& old_size, | 505 void WebViewGuest::SizeChanged(const gfx::Size& old_size, |
| 501 const gfx::Size& new_size) { | 506 const gfx::Size& new_size) { |
| 502 scoped_ptr<DictionaryValue> args(new DictionaryValue()); | 507 scoped_ptr<DictionaryValue> args(new DictionaryValue()); |
| 503 args->SetInteger(webview::kOldHeight, old_size.height()); | 508 args->SetInteger(webview::kOldHeight, old_size.height()); |
| 504 args->SetInteger(webview::kOldWidth, old_size.width()); | 509 args->SetInteger(webview::kOldWidth, old_size.width()); |
| 505 args->SetInteger(webview::kNewHeight, new_size.height()); | 510 args->SetInteger(webview::kNewHeight, new_size.height()); |
| 506 args->SetInteger(webview::kNewWidth, new_size.width()); | 511 args->SetInteger(webview::kNewWidth, new_size.width()); |
| 507 DispatchEvent(new GuestView::Event(webview::kEventSizeChanged, args.Pass())); | 512 DispatchEvent(new GuestView::Event(webview::kEventSizeChanged, args.Pass())); |
| 508 } | 513 } |
| OLD | NEW |