OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/extensions/dispatcher.h" | 5 #include "chrome/renderer/extensions/dispatcher.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/sha1.h" | 12 #include "base/sha1.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
15 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "chrome/common/child_process_logging.h" | 17 #include "chrome/common/child_process_logging.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/chrome_version_info.h" | 19 #include "chrome/common/chrome_version_info.h" |
20 #include "chrome/common/extensions/api/extension_api.h" | 20 #include "chrome/common/extensions/api/extension_api.h" |
21 #include "chrome/common/extensions/api/runtime.h" | 21 #include "chrome/common/extensions/api/runtime.h" |
22 #include "chrome/common/extensions/api/url_handlers/url_handlers_parser.h" | |
22 #include "chrome/common/extensions/background_info.h" | 23 #include "chrome/common/extensions/background_info.h" |
23 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
24 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
25 #include "chrome/common/extensions/extension_messages.h" | 26 #include "chrome/common/extensions/extension_messages.h" |
26 #include "chrome/common/extensions/features/feature_channel.h" | 27 #include "chrome/common/extensions/features/feature_channel.h" |
27 #include "chrome/common/extensions/manifest_handlers/externally_connectable.h" | 28 #include "chrome/common/extensions/manifest_handlers/externally_connectable.h" |
28 #include "chrome/common/extensions/manifest_handlers/sandboxed_page_info.h" | 29 #include "chrome/common/extensions/manifest_handlers/sandboxed_page_info.h" |
29 #include "chrome/common/extensions/message_bundle.h" | 30 #include "chrome/common/extensions/message_bundle.h" |
30 #include "chrome/common/extensions/permissions/permission_set.h" | 31 #include "chrome/common/extensions/permissions/permission_set.h" |
31 #include "chrome/common/extensions/permissions/permissions_data.h" | 32 #include "chrome/common/extensions/permissions/permissions_data.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 #include "grit/renderer_resources.h" | 88 #include "grit/renderer_resources.h" |
88 #include "third_party/WebKit/public/platform/WebString.h" | 89 #include "third_party/WebKit/public/platform/WebString.h" |
89 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 90 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
90 #include "third_party/WebKit/public/web/WebCustomElement.h" | 91 #include "third_party/WebKit/public/web/WebCustomElement.h" |
91 #include "third_party/WebKit/public/web/WebDataSource.h" | 92 #include "third_party/WebKit/public/web/WebDataSource.h" |
92 #include "third_party/WebKit/public/web/WebDocument.h" | 93 #include "third_party/WebKit/public/web/WebDocument.h" |
93 #include "third_party/WebKit/public/web/WebFrame.h" | 94 #include "third_party/WebKit/public/web/WebFrame.h" |
94 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 95 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
95 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" | 96 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" |
96 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 97 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
98 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | |
97 #include "third_party/WebKit/public/web/WebView.h" | 99 #include "third_party/WebKit/public/web/WebView.h" |
98 #include "ui/base/layout.h" | 100 #include "ui/base/layout.h" |
99 #include "ui/base/resource/resource_bundle.h" | 101 #include "ui/base/resource/resource_bundle.h" |
100 #include "v8/include/v8.h" | 102 #include "v8/include/v8.h" |
101 | 103 |
102 using WebKit::WebDataSource; | 104 using WebKit::WebDataSource; |
103 using WebKit::WebDocument; | 105 using WebKit::WebDocument; |
104 using WebKit::WebFrame; | 106 using WebKit::WebFrame; |
105 using WebKit::WebScopedUserGesture; | 107 using WebKit::WebScopedUserGesture; |
106 using WebKit::WebSecurityPolicy; | 108 using WebKit::WebSecurityPolicy; |
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1561 function_name == kEventDispatchFunction) { | 1563 function_name == kEventDispatchFunction) { |
1562 RenderView* background_view = | 1564 RenderView* background_view = |
1563 ExtensionHelper::GetBackgroundPage(extension_id); | 1565 ExtensionHelper::GetBackgroundPage(extension_id); |
1564 if (background_view) { | 1566 if (background_view) { |
1565 background_view->Send(new ExtensionHostMsg_EventAck( | 1567 background_view->Send(new ExtensionHostMsg_EventAck( |
1566 background_view->GetRoutingID())); | 1568 background_view->GetRoutingID())); |
1567 } | 1569 } |
1568 } | 1570 } |
1569 } | 1571 } |
1570 | 1572 |
1573 bool Dispatcher::MaybeRedirectUrlToApp( | |
benwells
2013/09/04 23:54:20
It doesn't feel good to have this code here. Did y
sergeygs
2013/09/05 09:19:03
Obsolete.
| |
1574 WebKit::WebFrame* frame, | |
1575 const WebKit::WebURLRequest& request, | |
1576 WebKit::WebNavigationType type, | |
1577 WebKit::WebNavigationPolicy default_policy) { | |
1578 // Limit redirection to top-level frames only. | |
1579 if (frame != frame->top()) | |
1580 return false; | |
1581 | |
1582 // Exclude Ignore and Download. | |
1583 const bool policy_ok = | |
1584 (default_policy == WebKit::WebNavigationPolicyCurrentTab) || | |
1585 (default_policy == WebKit::WebNavigationPolicyNewBackgroundTab) || | |
1586 (default_policy == WebKit::WebNavigationPolicyNewForegroundTab) || | |
1587 (default_policy == WebKit::WebNavigationPolicyNewWindow) || | |
1588 (default_policy == WebKit::WebNavigationPolicyNewPopup); | |
1589 if (!policy_ok) | |
1590 return false; | |
1591 | |
1592 bool navigation_type_ok = false; | |
1593 if (IsWithinPlatformApp()) { | |
not at google - send to devlin
2013/09/04 15:37:21
I didn't think you could navigate within platform
sergeygs
2013/09/05 09:19:03
To answer the question: this is ultimately called
| |
1594 // Exclude reloads (shouldn't happen anyway), back/forward, form submits, | |
1595 // and regular links (without target='_blank'). The latter are not supposed | |
1596 // to work in apps at all: an error message is normally printed to console | |
1597 // if one is clicked, so fall back to that default behavior here. | |
1598 navigation_type_ok = | |
1599 (type == WebKit::WebNavigationTypeOther && frame->opener()); | |
1600 } else { | |
1601 // Exclude reloads (shouldn't happen anyway), back/forward, form submits. | |
1602 navigation_type_ok = | |
1603 WebKit::WebUserGestureIndicator::isProcessingUserGesture() || | |
1604 (type == WebKit::WebNavigationTypeOther && frame->opener()) || | |
1605 (type == WebKit::WebNavigationTypeLinkClicked); | |
1606 } | |
1607 if (!navigation_type_ok) | |
1608 return false; | |
1609 | |
1610 const GURL url(request.url()); | |
1611 const GURL ref_url(request.httpHeaderField(WebString::fromUTF8("Referer"))); | |
1612 | |
1613 // Find out if there is an extension that can handle the URL. | |
1614 bool some_extension_can_handle = false; | |
1615 for (ExtensionSet::const_iterator it = extensions_.begin(); | |
1616 it != extensions_.end(); ++it) { | |
1617 if (UrlHandlers::CanExtensionHandleUrl(*it, url)) { | |
1618 some_extension_can_handle = true; | |
1619 break; | |
1620 } | |
1621 } | |
1622 if (!some_extension_can_handle) | |
1623 return false; | |
1624 | |
1625 // Get the correct RenderView (tab or app window) so that we can send a | |
1626 // routed IPC to the correct listener. | |
1627 content::RenderView* render_view = NULL; | |
1628 if (IsWithinPlatformApp()) { | |
not at google - send to devlin
2013/09/04 15:37:21
likewise
sergeygs
2013/09/05 09:19:03
See the answer above.
| |
1629 render_view = content::RenderView::FromWebView(frame->opener()->view()); | |
1630 } else { | |
1631 render_view = frame->opener() ? | |
1632 content::RenderView::FromWebView(frame->opener()->view()) : | |
1633 content::RenderView::FromWebView(frame->view()); | |
not at google - send to devlin
2013/09/04 15:37:21
does this mean that you redirect the opener frame
sergeygs
2013/09/05 09:19:03
I used the opener frame's routing ID to reach the
| |
1634 } | |
1635 if (!render_view) | |
1636 return false; | |
1637 | |
1638 return RenderThread::Get()->Send( | |
1639 new ExtensionHostMsg_RedirectUrl( | |
1640 render_view->GetRoutingID(), url, ref_url)); | |
1641 } | |
1642 | |
1571 } // namespace extensions | 1643 } // namespace extensions |
OLD | NEW |