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

Side by Side Diff: extensions/browser/guest_view/web_view/web_view_guest.cc

Issue 596003002: Allow declarative webrequest and webrequest in extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/guest_view/web_view/web_view_guest.h" 5 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 13 matching lines...) Expand all
24 #include "content/public/browser/storage_partition.h" 24 #include "content/public/browser/storage_partition.h"
25 #include "content/public/browser/user_metrics.h" 25 #include "content/public/browser/user_metrics.h"
26 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
27 #include "content/public/browser/web_contents_delegate.h" 27 #include "content/public/browser/web_contents_delegate.h"
28 #include "content/public/common/media_stream_request.h" 28 #include "content/public/common/media_stream_request.h"
29 #include "content/public/common/page_zoom.h" 29 #include "content/public/common/page_zoom.h"
30 #include "content/public/common/result_codes.h" 30 #include "content/public/common/result_codes.h"
31 #include "content/public/common/stop_find_action.h" 31 #include "content/public/common/stop_find_action.h"
32 #include "content/public/common/url_constants.h" 32 #include "content/public/common/url_constants.h"
33 #include "extensions/browser/api/extensions_api_client.h" 33 #include "extensions/browser/api/extensions_api_client.h"
34 #include "extensions/browser/api/web_request/web_request_api.h"
34 #include "extensions/browser/api/web_view/web_view_internal_api.h" 35 #include "extensions/browser/api/web_view/web_view_internal_api.h"
35 #include "extensions/browser/extension_system.h" 36 #include "extensions/browser/extension_system.h"
36 #include "extensions/browser/guest_view/guest_view_manager.h" 37 #include "extensions/browser/guest_view/guest_view_manager.h"
37 #include "extensions/browser/guest_view/web_view/web_view_constants.h" 38 #include "extensions/browser/guest_view/web_view/web_view_constants.h"
38 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" 39 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
39 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h" 40 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h"
40 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" 41 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
41 #include "extensions/common/constants.h" 42 #include "extensions/common/constants.h"
42 #include "extensions/common/extension_messages.h" 43 #include "extensions/common/extension_messages.h"
43 #include "extensions/common/guest_view/guest_view_constants.h" 44 #include "extensions/common/guest_view/guest_view_constants.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // TODO(lazyboy): Better way to deal with this error. 126 // TODO(lazyboy): Better way to deal with this error.
126 return; 127 return;
127 } 128 }
128 *persist_storage = true; 129 *persist_storage = true;
129 } else { 130 } else {
130 *storage_partition_id = partition_str; 131 *storage_partition_id = partition_str;
131 *persist_storage = false; 132 *persist_storage = false;
132 } 133 }
133 } 134 }
134 135
136 void RemoveWebViewEventListenersOnIOThread(
137 void* profile,
138 const std::string& extension_id,
139 int embedder_process_id,
140 int view_instance_id) {
141 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
142 ExtensionWebRequestEventRouter::GetInstance()->RemoveWebViewEventListeners(
143 profile,
144 extension_id,
145 embedder_process_id,
146 view_instance_id);
147 }
148
135 } // namespace 149 } // namespace
136 150
137 // static 151 // static
138 GuestViewBase* WebViewGuest::Create(content::BrowserContext* browser_context, 152 GuestViewBase* WebViewGuest::Create(content::BrowserContext* browser_context,
139 int guest_instance_id) { 153 int guest_instance_id) {
140 return new WebViewGuest(browser_context, guest_instance_id); 154 return new WebViewGuest(browser_context, guest_instance_id);
141 } 155 }
142 156
143 // static 157 // static
144 bool WebViewGuest::GetGuestPartitionConfigForSite( 158 bool WebViewGuest::GetGuestPartitionConfigForSite(
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 web_view_permission_helper_.reset(new WebViewPermissionHelper(this)); 343 web_view_permission_helper_.reset(new WebViewPermissionHelper(this));
330 } 344 }
331 345
332 void WebViewGuest::DidStopLoading() { 346 void WebViewGuest::DidStopLoading() {
333 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 347 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
334 DispatchEventToEmbedder( 348 DispatchEventToEmbedder(
335 new GuestViewBase::Event(webview::kEventLoadStop, args.Pass())); 349 new GuestViewBase::Event(webview::kEventLoadStop, args.Pass()));
336 } 350 }
337 351
338 void WebViewGuest::EmbedderDestroyed() { 352 void WebViewGuest::EmbedderDestroyed() {
339 if (web_view_guest_delegate_) 353 content::BrowserThread::PostTask(
340 web_view_guest_delegate_->OnEmbedderDestroyed(); 354 content::BrowserThread::IO,
355 FROM_HERE,
356 base::Bind(
357 &RemoveWebViewEventListenersOnIOThread,
358 browser_context(),
359 embedder_extension_id(),
360 embedder_render_process_id(),
361 view_instance_id()));
341 } 362 }
342 363
343 void WebViewGuest::GuestDestroyed() { 364 void WebViewGuest::GuestDestroyed() {
344 // Clean up custom context menu items for this guest. 365 // Clean up custom context menu items for this guest.
345 if (web_view_guest_delegate_) 366 if (web_view_guest_delegate_)
346 web_view_guest_delegate_->OnGuestDestroyed(); 367 web_view_guest_delegate_->OnGuestDestroyed();
347 RemoveWebViewStateFromIOThread(web_contents()); 368 RemoveWebViewStateFromIOThread(web_contents());
348 } 369 }
349 370
350 void WebViewGuest::GuestReady() { 371 void WebViewGuest::GuestReady() {
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 WebViewGuest* guest = 1210 WebViewGuest* guest =
1190 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); 1211 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id);
1191 if (!guest) 1212 if (!guest)
1192 return; 1213 return;
1193 1214
1194 if (!allow) 1215 if (!allow)
1195 guest->Destroy(); 1216 guest->Destroy();
1196 } 1217 }
1197 1218
1198 } // namespace extensions 1219 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/extensions_api_client.cc ('k') | extensions/browser/guest_view/web_view/web_view_guest_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698