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

Unified Diff: extensions/browser/guest_view/app_view/app_view_guest.cc

Issue 1181893003: Kill bad apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/guest_view/app_view/app_view_guest.cc
diff --git a/extensions/browser/guest_view/app_view/app_view_guest.cc b/extensions/browser/guest_view/app_view/app_view_guest.cc
index 9c157d0406f694458235df1fbbd91fad21a978fa..a4b82c8cd7b9832b93002701c90fbc91f167dcba 100644
--- a/extensions/browser/guest_view/app_view/app_view_guest.cc
+++ b/extensions/browser/guest_view/app_view/app_view_guest.cc
@@ -6,8 +6,10 @@
#include "base/command_line.h"
#include "components/guest_view/browser/guest_view_manager.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/common/renderer_preferences.h"
+#include "content/public/common/result_codes.h"
#include "extensions/browser/api/app_runtime/app_runtime_api.h"
#include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/app_window/app_delegate.h"
@@ -63,12 +65,15 @@ bool AppViewGuest::CompletePendingRequest(
content::BrowserContext* browser_context,
const GURL& url,
int guest_instance_id,
- const std::string& guest_extension_id) {
+ const std::string& guest_extension_id,
+ int guest_render_process_host_id) {
lfg 2015/06/12 21:43:47 Add a DCHECK that the render process host passed h
EhsanK 2015/06/25 16:19:50 I am not sure if I understand this comment correct
lfg 2015/06/26 21:46:05 Ah, I see. Please, add a comment explaining why we
EhsanK 2015/06/30 16:53:10 Done.
PendingResponseMap* response_map = pending_response_map.Pointer();
PendingResponseMap::iterator it = response_map->find(guest_instance_id);
if (it == response_map->end()) {
// TODO(fsamuel): An app is sending invalid responses. We should probably
// kill it.
lfg 2015/06/12 21:43:47 Remove the TODO.
EhsanK 2015/06/25 16:19:50 Done.
+ content::RenderProcessHost::FromID(guest_render_process_host_id)
+ ->Shutdown(-1, false);
lfg 2015/06/12 21:43:47 We should add UMA metrics to track the kills here.
EhsanK 2015/06/25 16:19:50 Done.
return false;
}
@@ -77,6 +82,8 @@ bool AppViewGuest::CompletePendingRequest(
(response_info->guest_extension->id() != guest_extension_id)) {
// TODO(fsamuel): An app is trying to respond to an <appview> that didn't
// initiate communication with it. We should kill the app here.
+ content::RenderProcessHost::FromID(guest_render_process_host_id)
+ ->Shutdown(-1, false);
lfg 2015/06/12 21:43:47 Same as above.
EhsanK 2015/06/25 16:19:50 Done.
return false;
}
@@ -115,8 +122,8 @@ content::WebContents* AppViewGuest::GetAssociatedWebContents() const {
bool AppViewGuest::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(AppViewGuest, message)
- IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
- IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
+ IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
@@ -198,12 +205,10 @@ void AppViewGuest::CreateWebContents(
return;
}
- pending_response_map.Get().insert(
- std::make_pair(guest_instance_id(),
- make_linked_ptr(new ResponseInfo(
- guest_extension,
- weak_ptr_factory_.GetWeakPtr(),
- callback))));
+ pending_response_map.Get().insert(std::make_pair(
+ guest_instance_id(),
+ make_linked_ptr(new ResponseInfo(
+ guest_extension, weak_ptr_factory_.GetWeakPtr(), callback))));
LazyBackgroundTaskQueue* queue =
LazyBackgroundTaskQueue::Get(browser_context());
@@ -293,4 +298,17 @@ void AppViewGuest::SetAppDelegateForTest(AppDelegate* delegate) {
app_delegate_.reset(delegate);
}
+// static
+void AppViewGuest::AddFakeRequestInfoForTesting(
+ const Extension* guest_extension,
+ AppViewGuest* app_view_guest,
+ GuestViewBase::WebContentsCreatedCallback& callback,
+ int guest_instance_id) {
+ pending_response_map.Get().insert(std::make_pair(
+ guest_instance_id,
+ make_linked_ptr(new ResponseInfo(
+ guest_extension, app_view_guest->weak_ptr_factory_.GetWeakPtr(),
+ callback))));
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698