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/script_executor.h" | 11 #include "chrome/browser/extensions/script_executor.h" |
11 #include "chrome/browser/favicon/favicon_tab_helper.h" | 12 #include "chrome/browser/favicon/favicon_tab_helper.h" |
12 #include "chrome/browser/guestview/guestview_constants.h" | 13 #include "chrome/browser/guestview/guestview_constants.h" |
13 #include "chrome/browser/guestview/webview/webview_constants.h" | 14 #include "chrome/browser/guestview/webview/webview_constants.h" |
14 #include "chrome/browser/guestview/webview/webview_permission_types.h" | 15 #include "chrome/browser/guestview/webview/webview_permission_types.h" |
15 #include "chrome/common/chrome_version_info.h" | 16 #include "chrome/common/chrome_version_info.h" |
16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/native_web_keyboard_event.h" | 18 #include "content/public/browser/native_web_keyboard_event.h" |
18 #include "content/public/browser/notification_details.h" | 19 #include "content/public/browser/notification_details.h" |
19 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
20 #include "content/public/browser/notification_types.h" | 21 #include "content/public/browser/notification_types.h" |
21 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
22 #include "content/public/browser/resource_request_details.h" | 23 #include "content/public/browser/resource_request_details.h" |
23 #include "content/public/browser/site_instance.h" | 24 #include "content/public/browser/site_instance.h" |
24 #include "content/public/browser/storage_partition.h" | 25 #include "content/public/browser/storage_partition.h" |
25 #include "content/public/browser/user_metrics.h" | 26 #include "content/public/browser/user_metrics.h" |
26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
27 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
28 #include "content/public/common/result_codes.h" | 29 #include "content/public/common/result_codes.h" |
30 #include "extensions/common/constants.h" | |
29 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
30 | 32 |
31 #if defined(ENABLE_PLUGINS) | 33 #if defined(ENABLE_PLUGINS) |
32 #include "chrome/browser/guestview/webview/plugin_permission_helper.h" | 34 #include "chrome/browser/guestview/webview/plugin_permission_helper.h" |
33 #endif | 35 #endif |
34 | 36 |
35 using content::WebContents; | 37 using content::WebContents; |
36 | 38 |
37 namespace { | 39 namespace { |
38 | 40 |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
541 WebContents* web_contents) { | 543 WebContents* web_contents) { |
542 content::BrowserThread::PostTask( | 544 content::BrowserThread::PostTask( |
543 content::BrowserThread::IO, FROM_HERE, | 545 content::BrowserThread::IO, FROM_HERE, |
544 base::Bind( | 546 base::Bind( |
545 &ExtensionRendererState::RemoveWebView, | 547 &ExtensionRendererState::RemoveWebView, |
546 base::Unretained(ExtensionRendererState::GetInstance()), | 548 base::Unretained(ExtensionRendererState::GetInstance()), |
547 web_contents->GetRenderProcessHost()->GetID(), | 549 web_contents->GetRenderProcessHost()->GetID(), |
548 web_contents->GetRoutingID())); | 550 web_contents->GetRoutingID())); |
549 } | 551 } |
550 | 552 |
553 GURL WebViewGuest::ResolveURL(const std::string& src) { | |
554 if (!attached()) | |
555 return GURL(src); | |
556 const content::SiteInstance* embedder_site_instance = | |
557 embedder_web_contents()->GetSiteInstance(); | |
558 const GURL& embedder_site_url = embedder_site_instance->GetSiteURL(); | |
559 GURL default_url(base::StringPrintf("%s://%s/", | |
560 extensions::kExtensionScheme, | |
561 embedder_site_url.host().c_str())); | |
Charlie Reis
2013/10/18 17:37:55
What will this do in Hui's case, when we have a we
Fady Samuel
2013/10/25 21:10:31
I now base this on the extension_id which is alway
Charlie Reis
2013/10/29 21:11:39
Thanks.
| |
562 return default_url.Resolve(src); | |
563 } | |
564 | |
551 void WebViewGuest::SizeChanged(const gfx::Size& old_size, | 565 void WebViewGuest::SizeChanged(const gfx::Size& old_size, |
552 const gfx::Size& new_size) { | 566 const gfx::Size& new_size) { |
553 scoped_ptr<DictionaryValue> args(new DictionaryValue()); | 567 scoped_ptr<DictionaryValue> args(new DictionaryValue()); |
554 args->SetInteger(webview::kOldHeight, old_size.height()); | 568 args->SetInteger(webview::kOldHeight, old_size.height()); |
555 args->SetInteger(webview::kOldWidth, old_size.width()); | 569 args->SetInteger(webview::kOldWidth, old_size.width()); |
556 args->SetInteger(webview::kNewHeight, new_size.height()); | 570 args->SetInteger(webview::kNewHeight, new_size.height()); |
557 args->SetInteger(webview::kNewWidth, new_size.width()); | 571 args->SetInteger(webview::kNewWidth, new_size.width()); |
558 DispatchEvent(new GuestView::Event(webview::kEventSizeChanged, args.Pass())); | 572 DispatchEvent(new GuestView::Event(webview::kEventSizeChanged, args.Pass())); |
559 } | 573 } |
560 | 574 |
561 WebViewGuest::PermissionResponseInfo::PermissionResponseInfo() | 575 WebViewGuest::PermissionResponseInfo::PermissionResponseInfo() |
562 : allowed_by_default(false) { | 576 : allowed_by_default(false) { |
563 } | 577 } |
564 | 578 |
565 WebViewGuest::PermissionResponseInfo::PermissionResponseInfo( | 579 WebViewGuest::PermissionResponseInfo::PermissionResponseInfo( |
566 const PermissionResponseCallback& callback, | 580 const PermissionResponseCallback& callback, |
567 bool allowed_by_default) | 581 bool allowed_by_default) |
568 : callback(callback), | 582 : callback(callback), |
569 allowed_by_default(allowed_by_default) { | 583 allowed_by_default(allowed_by_default) { |
570 } | 584 } |
571 | 585 |
572 WebViewGuest::PermissionResponseInfo::~PermissionResponseInfo() { | 586 WebViewGuest::PermissionResponseInfo::~PermissionResponseInfo() { |
573 } | 587 } |
OLD | NEW |