OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extensions/api/webview/webview_api.h" | 5 #include "chrome/browser/extensions/api/webview/webview_api.h" |
6 | 6 |
7 #include "chrome/browser/extensions/tab_helper.h" | 7 #include "chrome/browser/extensions/tab_helper.h" |
8 #include "chrome/browser/guestview/webview/webview_guest.h" | 8 #include "chrome/browser/guestview/webview/webview_guest.h" |
9 #include "chrome/common/extensions/api/webview.h" | 9 #include "chrome/common/extensions/api/webview.h" |
10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 WebViewGuest* guest = WebViewGuest::From( | 102 WebViewGuest* guest = WebViewGuest::From( |
103 render_view_host()->GetProcess()->GetID(), instance_id); | 103 render_view_host()->GetProcess()->GetID(), instance_id); |
104 if (!guest) | 104 if (!guest) |
105 return false; | 105 return false; |
106 | 106 |
107 guest->Go(relative_index); | 107 guest->Go(relative_index); |
108 return true; | 108 return true; |
109 } | 109 } |
110 | 110 |
111 WebviewStopFunction::WebviewStopFunction() { | 111 WebviewReloadFunction::WebviewReloadFunction() { |
112 } | 112 } |
113 | 113 |
114 WebviewStopFunction::~WebviewStopFunction() { | 114 WebviewReloadFunction::~WebviewReloadFunction() { |
115 } | 115 } |
116 | 116 |
117 bool WebviewStopFunction::RunImpl() { | 117 bool WebviewReloadFunction::RunImpl() { |
118 int instance_id = 0; | 118 int instance_id = 0; |
119 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &instance_id)); | 119 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &instance_id)); |
120 | 120 |
121 WebViewGuest* guest = WebViewGuest::From( | 121 WebViewGuest* guest = WebViewGuest::From( |
122 render_view_host()->GetProcess()->GetID(), instance_id); | 122 render_view_host()->GetProcess()->GetID(), instance_id); |
123 if (!guest) | 123 if (!guest) |
124 return false; | 124 return false; |
125 | 125 |
126 guest->Stop(); | 126 guest->Reload(); |
127 return true; | 127 return true; |
128 } | 128 } |
129 | 129 |
130 WebviewReloadFunction::WebviewReloadFunction() { | 130 WebviewSetPermissionFunction::WebviewSetPermissionFunction() { |
131 } | 131 } |
132 | 132 |
133 WebviewReloadFunction::~WebviewReloadFunction() { | 133 WebviewSetPermissionFunction::~WebviewSetPermissionFunction() { |
134 } | 134 } |
135 | 135 |
136 bool WebviewReloadFunction::RunImpl() { | 136 bool WebviewSetPermissionFunction::RunImpl() { |
| 137 int instance_id = 0; |
| 138 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &instance_id)); |
| 139 |
| 140 int request_id = 0; |
| 141 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &request_id)); |
| 142 |
| 143 bool should_allow = false; |
| 144 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(2, &should_allow)); |
| 145 |
| 146 std::string user_input; |
| 147 EXTENSION_FUNCTION_VALIDATE(args_->GetString(3, &user_input)); |
| 148 |
| 149 WebViewGuest* guest = WebViewGuest::From( |
| 150 render_view_host()->GetProcess()->GetID(), instance_id); |
| 151 if (!guest) |
| 152 return false; |
| 153 |
| 154 EXTENSION_FUNCTION_VALIDATE( |
| 155 guest->SetPermission(request_id, should_allow, user_input)); |
| 156 return true; |
| 157 } |
| 158 |
| 159 WebviewStopFunction::WebviewStopFunction() { |
| 160 } |
| 161 |
| 162 WebviewStopFunction::~WebviewStopFunction() { |
| 163 } |
| 164 |
| 165 bool WebviewStopFunction::RunImpl() { |
137 int instance_id = 0; | 166 int instance_id = 0; |
138 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &instance_id)); | 167 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &instance_id)); |
139 | 168 |
140 WebViewGuest* guest = WebViewGuest::From( | 169 WebViewGuest* guest = WebViewGuest::From( |
141 render_view_host()->GetProcess()->GetID(), instance_id); | 170 render_view_host()->GetProcess()->GetID(), instance_id); |
142 if (!guest) | 171 if (!guest) |
143 return false; | 172 return false; |
144 | 173 |
145 guest->Reload(); | 174 guest->Stop(); |
146 return true; | 175 return true; |
147 } | 176 } |
148 | 177 |
149 WebviewTerminateFunction::WebviewTerminateFunction() { | 178 WebviewTerminateFunction::WebviewTerminateFunction() { |
150 } | 179 } |
151 | 180 |
152 WebviewTerminateFunction::~WebviewTerminateFunction() { | 181 WebviewTerminateFunction::~WebviewTerminateFunction() { |
153 } | 182 } |
154 | 183 |
155 bool WebviewTerminateFunction::RunImpl() { | 184 bool WebviewTerminateFunction::RunImpl() { |
156 int instance_id = 0; | 185 int instance_id = 0; |
157 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &instance_id)); | 186 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &instance_id)); |
158 | 187 |
159 WebViewGuest* guest = WebViewGuest::From( | 188 WebViewGuest* guest = WebViewGuest::From( |
160 render_view_host()->GetProcess()->GetID(), instance_id); | 189 render_view_host()->GetProcess()->GetID(), instance_id); |
161 if (!guest) | 190 if (!guest) |
162 return false; | 191 return false; |
163 | 192 |
164 guest->Terminate(); | 193 guest->Terminate(); |
165 return true; | 194 return true; |
166 } | 195 } |
OLD | NEW |