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 "base/strings/stringprintf.h" |
8 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 9 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
9 #include "chrome/browser/extensions/extension_renderer_state.h" | 10 #include "chrome/browser/extensions/extension_renderer_state.h" |
10 #include "chrome/browser/extensions/extension_web_contents_observer.h" | 11 #include "chrome/browser/extensions/extension_web_contents_observer.h" |
11 #include "chrome/browser/extensions/script_executor.h" | 12 #include "chrome/browser/extensions/script_executor.h" |
12 #include "chrome/browser/favicon/favicon_tab_helper.h" | 13 #include "chrome/browser/favicon/favicon_tab_helper.h" |
13 #include "chrome/browser/guestview/guestview_constants.h" | 14 #include "chrome/browser/guestview/guestview_constants.h" |
14 #include "chrome/browser/guestview/webview/webview_constants.h" | 15 #include "chrome/browser/guestview/webview/webview_constants.h" |
15 #include "chrome/browser/guestview/webview/webview_permission_types.h" | 16 #include "chrome/browser/guestview/webview/webview_permission_types.h" |
16 #include "chrome/common/chrome_version_info.h" | 17 #include "chrome/common/chrome_version_info.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/native_web_keyboard_event.h" | 19 #include "content/public/browser/native_web_keyboard_event.h" |
19 #include "content/public/browser/notification_details.h" | 20 #include "content/public/browser/notification_details.h" |
20 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
21 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
22 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
23 #include "content/public/browser/resource_request_details.h" | 24 #include "content/public/browser/resource_request_details.h" |
24 #include "content/public/browser/site_instance.h" | 25 #include "content/public/browser/site_instance.h" |
25 #include "content/public/browser/storage_partition.h" | 26 #include "content/public/browser/storage_partition.h" |
26 #include "content/public/browser/user_metrics.h" | 27 #include "content/public/browser/user_metrics.h" |
27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
28 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
29 #include "content/public/common/result_codes.h" | 30 #include "content/public/common/result_codes.h" |
| 31 #include "extensions/common/constants.h" |
30 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
31 | 33 |
32 #if defined(ENABLE_PLUGINS) | 34 #if defined(ENABLE_PLUGINS) |
33 #include "chrome/browser/guestview/webview/plugin_permission_helper.h" | 35 #include "chrome/browser/guestview/webview/plugin_permission_helper.h" |
34 #endif | 36 #endif |
35 | 37 |
36 using content::WebContents; | 38 using content::WebContents; |
37 | 39 |
38 namespace { | 40 namespace { |
39 | 41 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 WebContents* web_contents) { | 553 WebContents* web_contents) { |
552 content::BrowserThread::PostTask( | 554 content::BrowserThread::PostTask( |
553 content::BrowserThread::IO, FROM_HERE, | 555 content::BrowserThread::IO, FROM_HERE, |
554 base::Bind( | 556 base::Bind( |
555 &ExtensionRendererState::RemoveWebView, | 557 &ExtensionRendererState::RemoveWebView, |
556 base::Unretained(ExtensionRendererState::GetInstance()), | 558 base::Unretained(ExtensionRendererState::GetInstance()), |
557 web_contents->GetRenderProcessHost()->GetID(), | 559 web_contents->GetRenderProcessHost()->GetID(), |
558 web_contents->GetRoutingID())); | 560 web_contents->GetRoutingID())); |
559 } | 561 } |
560 | 562 |
| 563 GURL WebViewGuest::ResolveURL(const std::string& src) { |
| 564 if (extension_id().empty()) { |
| 565 NOTREACHED(); |
| 566 return GURL(src); |
| 567 } |
| 568 GURL default_url(base::StringPrintf("%s://%s/", |
| 569 extensions::kExtensionScheme, |
| 570 extension_id().c_str())); |
| 571 return default_url.Resolve(src); |
| 572 } |
| 573 |
561 void WebViewGuest::SizeChanged(const gfx::Size& old_size, | 574 void WebViewGuest::SizeChanged(const gfx::Size& old_size, |
562 const gfx::Size& new_size) { | 575 const gfx::Size& new_size) { |
563 scoped_ptr<DictionaryValue> args(new DictionaryValue()); | 576 scoped_ptr<DictionaryValue> args(new DictionaryValue()); |
564 args->SetInteger(webview::kOldHeight, old_size.height()); | 577 args->SetInteger(webview::kOldHeight, old_size.height()); |
565 args->SetInteger(webview::kOldWidth, old_size.width()); | 578 args->SetInteger(webview::kOldWidth, old_size.width()); |
566 args->SetInteger(webview::kNewHeight, new_size.height()); | 579 args->SetInteger(webview::kNewHeight, new_size.height()); |
567 args->SetInteger(webview::kNewWidth, new_size.width()); | 580 args->SetInteger(webview::kNewWidth, new_size.width()); |
568 DispatchEvent(new GuestView::Event(webview::kEventSizeChanged, args.Pass())); | 581 DispatchEvent(new GuestView::Event(webview::kEventSizeChanged, args.Pass())); |
569 } | 582 } |
570 | 583 |
571 WebViewGuest::PermissionResponseInfo::PermissionResponseInfo() | 584 WebViewGuest::PermissionResponseInfo::PermissionResponseInfo() |
572 : allowed_by_default(false) { | 585 : allowed_by_default(false) { |
573 } | 586 } |
574 | 587 |
575 WebViewGuest::PermissionResponseInfo::PermissionResponseInfo( | 588 WebViewGuest::PermissionResponseInfo::PermissionResponseInfo( |
576 const PermissionResponseCallback& callback, | 589 const PermissionResponseCallback& callback, |
577 bool allowed_by_default) | 590 bool allowed_by_default) |
578 : callback(callback), | 591 : callback(callback), |
579 allowed_by_default(allowed_by_default) { | 592 allowed_by_default(allowed_by_default) { |
580 } | 593 } |
581 | 594 |
582 WebViewGuest::PermissionResponseInfo::~PermissionResponseInfo() { | 595 WebViewGuest::PermissionResponseInfo::~PermissionResponseInfo() { |
583 } | 596 } |
OLD | NEW |