Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(781)

Side by Side Diff: chrome/browser/renderer_host/render_view_host.cc

Issue 251093: Modify extension request IPC messages to pass a ListValue instead of a string. (Closed)
Patch Set: notreached messages Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/renderer_host/render_view_host.h" 5 #include "chrome/browser/renderer_host/render_view_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "app/resource_bundle.h" 11 #include "app/resource_bundle.h"
12 #include "base/gfx/native_widget_types.h" 12 #include "base/gfx/native_widget_types.h"
13 #include "base/json_reader.h"
13 #include "base/string_util.h" 14 #include "base/string_util.h"
14 #include "base/time.h" 15 #include "base/time.h"
15 #include "base/waitable_event.h" 16 #include "base/waitable_event.h"
16 #include "chrome/browser/child_process_security_policy.h" 17 #include "chrome/browser/child_process_security_policy.h"
17 #include "chrome/browser/cross_site_request_manager.h" 18 #include "chrome/browser/cross_site_request_manager.h"
18 #include "chrome/browser/debugger/devtools_manager.h" 19 #include "chrome/browser/debugger/devtools_manager.h"
19 #include "chrome/browser/dom_operation_notification_details.h" 20 #include "chrome/browser/dom_operation_notification_details.h"
20 #include "chrome/browser/extensions/extension_message_service.h" 21 #include "chrome/browser/extensions/extension_message_service.h"
21 #include "chrome/browser/metrics/user_metrics.h" 22 #include "chrome/browser/metrics/user_metrics.h"
22 #include "chrome/browser/profile.h" 23 #include "chrome/browser/profile.h"
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 HasDOMUIBindings(process()->id())) { 1211 HasDOMUIBindings(process()->id())) {
1211 NOTREACHED() << "Blocked unauthorized use of DOMUIBindings."; 1212 NOTREACHED() << "Blocked unauthorized use of DOMUIBindings.";
1212 return; 1213 return;
1213 } 1214 }
1214 1215
1215 // DOMUI doesn't use these values yet. 1216 // DOMUI doesn't use these values yet.
1216 // TODO(aa): When DOMUI is ported to ExtensionFunctionDispatcher, send real 1217 // TODO(aa): When DOMUI is ported to ExtensionFunctionDispatcher, send real
1217 // values here. 1218 // values here.
1218 const int kRequestId = -1; 1219 const int kRequestId = -1;
1219 const bool kHasCallback = false; 1220 const bool kHasCallback = false;
1221 scoped_ptr<Value> value;
1222 if (!content.empty()) {
1223 value.reset(JSONReader::Read(content, false));
1224 if (!value.get()) {
1225 // The page sent us something that we didn't understand.
1226 // This probably indicates a programming error.
1227 NOTREACHED() << "Invalid JSON argument in OnMsgDOMUISend.";
1228 return;
1229 }
1230 }
1220 1231
1221 delegate_->ProcessDOMUIMessage(message, content, kRequestId, kHasCallback); 1232 delegate_->ProcessDOMUIMessage(message, value.get(),
1233 kRequestId, kHasCallback);
1222 } 1234 }
1223 1235
1224 void RenderViewHost::OnMsgForwardMessageToExternalHost( 1236 void RenderViewHost::OnMsgForwardMessageToExternalHost(
1225 const std::string& message, const std::string& origin, 1237 const std::string& message, const std::string& origin,
1226 const std::string& target) { 1238 const std::string& target) {
1227 delegate_->ProcessExternalHostMessage(message, origin, target); 1239 delegate_->ProcessExternalHostMessage(message, origin, target);
1228 } 1240 }
1229 1241
1230 void RenderViewHost::OnMsgDocumentLoadedInFrame() { 1242 void RenderViewHost::OnMsgDocumentLoadedInFrame() {
1231 RenderViewHostDelegate::Resource* resource_delegate = 1243 RenderViewHostDelegate::Resource* resource_delegate =
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 } 1636 }
1625 1637
1626 void RenderViewHost::ForwardMessageFromExternalHost(const std::string& message, 1638 void RenderViewHost::ForwardMessageFromExternalHost(const std::string& message,
1627 const std::string& origin, 1639 const std::string& origin,
1628 const std::string& target) { 1640 const std::string& target) {
1629 Send(new ViewMsg_HandleMessageFromExternalHost(routing_id(), message, origin, 1641 Send(new ViewMsg_HandleMessageFromExternalHost(routing_id(), message, origin,
1630 target)); 1642 target));
1631 } 1643 }
1632 1644
1633 void RenderViewHost::OnExtensionRequest(const std::string& name, 1645 void RenderViewHost::OnExtensionRequest(const std::string& name,
1634 const std::string& args, 1646 const ListValue& args_holder,
1635 int request_id, 1647 int request_id,
1636 bool has_callback) { 1648 bool has_callback) {
1637 if (!ChildProcessSecurityPolicy::GetInstance()-> 1649 if (!ChildProcessSecurityPolicy::GetInstance()->
1638 HasExtensionBindings(process()->id())) { 1650 HasExtensionBindings(process()->id())) {
1639 // This can happen if someone uses window.open() to open an extension URL 1651 // This can happen if someone uses window.open() to open an extension URL
1640 // from a non-extension context. 1652 // from a non-extension context.
1641 BlockExtensionRequest(request_id); 1653 BlockExtensionRequest(request_id);
1642 return; 1654 return;
1643 } 1655 }
1644 1656
1657 // The renderer sends the args in a 1-element list to make serialization
1658 // easier.
1659 Value* args = NULL;
1660 if (!args_holder.IsType(Value::TYPE_LIST) ||
1661 !static_cast<const ListValue*>(&args_holder)->Get(0, &args)) {
1662 NOTREACHED();
1663 return;
1664 }
1665
1645 delegate_->ProcessDOMUIMessage(name, args, request_id, has_callback); 1666 delegate_->ProcessDOMUIMessage(name, args, request_id, has_callback);
1646 } 1667 }
1647 1668
1648 void RenderViewHost::SendExtensionResponse(int request_id, bool success, 1669 void RenderViewHost::SendExtensionResponse(int request_id, bool success,
1649 const std::string& response, 1670 const std::string& response,
1650 const std::string& error) { 1671 const std::string& error) {
1651 Send(new ViewMsg_ExtensionResponse(routing_id(), request_id, success, 1672 Send(new ViewMsg_ExtensionResponse(routing_id(), request_id, success,
1652 response, error)); 1673 response, error));
1653 } 1674 }
1654 1675
(...skipping 23 matching lines...) Expand all
1678 #endif 1699 #endif
1679 } 1700 }
1680 1701
1681 void RenderViewHost::OnCSSInserted() { 1702 void RenderViewHost::OnCSSInserted() {
1682 delegate_->DidInsertCSS(); 1703 delegate_->DidInsertCSS();
1683 } 1704 }
1684 1705
1685 void RenderViewHost::UpdateBrowserWindowId(int window_id) { 1706 void RenderViewHost::UpdateBrowserWindowId(int window_id) {
1686 Send(new ViewMsg_UpdateBrowserWindowId(routing_id(), window_id)); 1707 Send(new ViewMsg_UpdateBrowserWindowId(routing_id(), window_id));
1687 } 1708 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_view_host.h ('k') | chrome/browser/renderer_host/render_view_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698