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 "content/browser/browser_plugin/browser_plugin_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 : PermissionRequest(guest), | 91 : PermissionRequest(guest), |
92 instance_id_(instance_id) { | 92 instance_id_(instance_id) { |
93 RecordAction( | 93 RecordAction( |
94 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.NewWindow
")); | 94 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.NewWindow
")); |
95 } | 95 } |
96 | 96 |
97 virtual void RespondImpl(bool should_allow, | 97 virtual void RespondImpl(bool should_allow, |
98 const std::string& user_input) OVERRIDE { | 98 const std::string& user_input) OVERRIDE { |
99 int embedder_render_process_id = | 99 int embedder_render_process_id = |
100 guest_->embedder_web_contents()->GetRenderProcessHost()->GetID(); | 100 guest_->embedder_web_contents()->GetRenderProcessHost()->GetID(); |
101 BrowserPluginGuest* guest = guest_->GetBrowserPluginGuestManager()-> | 101 guest_->GetBrowserPluginGuestManager()-> |
102 GetGuestByInstanceID(instance_id_, embedder_render_process_id); | 102 MaybeGetGuestByInstanceIDOrKill( |
| 103 instance_id_, |
| 104 embedder_render_process_id, |
| 105 base::Bind(&BrowserPluginGuest::NewWindowRequest::RespondInternal, |
| 106 base::Unretained(this), |
| 107 should_allow)); |
| 108 } |
| 109 |
| 110 private: |
| 111 virtual ~NewWindowRequest() {} |
| 112 |
| 113 void RespondInternal(bool should_allow, |
| 114 BrowserPluginGuest* guest) { |
103 if (!guest) { | 115 if (!guest) { |
104 VLOG(0) << "Guest not found. Instance ID: " << instance_id_; | 116 VLOG(0) << "Guest not found. Instance ID: " << instance_id_; |
105 return; | 117 return; |
106 } | 118 } |
107 | 119 |
108 // If we do not destroy the guest then we allow the new window. | 120 // If we do not destroy the guest then we allow the new window. |
109 if (!should_allow) | 121 if (!should_allow) |
110 guest->Destroy(); | 122 guest->Destroy(); |
111 } | 123 } |
112 | 124 |
113 private: | |
114 virtual ~NewWindowRequest() {} | |
115 int instance_id_; | 125 int instance_id_; |
116 }; | 126 }; |
117 | 127 |
118 namespace { | 128 namespace { |
119 std::string WindowOpenDispositionToString( | 129 std::string WindowOpenDispositionToString( |
120 WindowOpenDisposition window_open_disposition) { | 130 WindowOpenDisposition window_open_disposition) { |
121 switch (window_open_disposition) { | 131 switch (window_open_disposition) { |
122 case IGNORE_ACTION: | 132 case IGNORE_ACTION: |
123 return "ignore"; | 133 return "ignore"; |
124 case SAVE_TO_DISK: | 134 case SAVE_TO_DISK: |
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 const GURL& url) { | 1550 const GURL& url) { |
1541 if (!url.is_valid()) { | 1551 if (!url.is_valid()) { |
1542 callback.Run(false); | 1552 callback.Run(false); |
1543 return; | 1553 return; |
1544 } | 1554 } |
1545 | 1555 |
1546 delegate_->CanDownload(request_method, url, callback); | 1556 delegate_->CanDownload(request_method, url, callback); |
1547 } | 1557 } |
1548 | 1558 |
1549 } // namespace content | 1559 } // namespace content |
OLD | NEW |