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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 264943006: BrowserPlugin: Simplify content/public API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@guestview_manager_v1
Patch Set: Fixed nit Created 6 years, 7 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) 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
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 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 const GURL& url) { 1557 const GURL& url) {
1548 if (!url.is_valid()) { 1558 if (!url.is_valid()) {
1549 callback.Run(false); 1559 callback.Run(false);
1550 return; 1560 return;
1551 } 1561 }
1552 1562
1553 delegate_->CanDownload(request_method, url, callback); 1563 delegate_->CanDownload(request_method, url, callback);
1554 } 1564 }
1555 1565
1556 } // namespace content 1566 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698