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

Side by Side Diff: chrome/browser/guestview/webview/webview_guest.cc

Issue 22793018: <webview>: Implement support for package-local chrome-extension:// URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a test to verify that a privileged partition can access a local resource Created 7 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/guestview/webview/webview_guest.h" 5 #include "chrome/browser/guestview/webview/webview_guest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/extensions/api/web_request/web_request_api.h" 8 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
9 #include "chrome/browser/extensions/extension_renderer_state.h" 9 #include "chrome/browser/extensions/extension_renderer_state.h"
10 #include "chrome/browser/extensions/script_executor.h" 10 #include "chrome/browser/extensions/script_executor.h"
11 #include "chrome/browser/favicon/favicon_tab_helper.h" 11 #include "chrome/browser/favicon/favicon_tab_helper.h"
12 #include "chrome/browser/guestview/guestview_constants.h" 12 #include "chrome/browser/guestview/guestview_constants.h"
13 #include "chrome/browser/guestview/webview/webview_constants.h" 13 #include "chrome/browser/guestview/webview/webview_constants.h"
14 #include "chrome/common/chrome_version_info.h" 14 #include "chrome/common/chrome_version_info.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/native_web_keyboard_event.h" 16 #include "content/public/browser/native_web_keyboard_event.h"
17 #include "content/public/browser/notification_details.h" 17 #include "content/public/browser/notification_details.h"
18 #include "content/public/browser/notification_source.h" 18 #include "content/public/browser/notification_source.h"
19 #include "content/public/browser/notification_types.h" 19 #include "content/public/browser/notification_types.h"
20 #include "content/public/browser/render_process_host.h" 20 #include "content/public/browser/render_process_host.h"
21 #include "content/public/browser/resource_request_details.h" 21 #include "content/public/browser/resource_request_details.h"
22 #include "content/public/browser/site_instance.h"
22 #include "content/public/browser/storage_partition.h" 23 #include "content/public/browser/storage_partition.h"
23 #include "content/public/browser/user_metrics.h" 24 #include "content/public/browser/user_metrics.h"
24 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
25 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
26 #include "content/public/common/result_codes.h" 27 #include "content/public/common/result_codes.h"
27 #include "net/base/net_errors.h" 28 #include "net/base/net_errors.h"
28 29
29 using content::WebContents; 30 using content::WebContents;
30 31
31 namespace { 32 namespace {
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 const GURL& new_url, 446 const GURL& new_url,
446 bool is_top_level) { 447 bool is_top_level) {
447 scoped_ptr<DictionaryValue> args(new DictionaryValue()); 448 scoped_ptr<DictionaryValue> args(new DictionaryValue());
448 args->SetBoolean(guestview::kIsTopLevel, is_top_level); 449 args->SetBoolean(guestview::kIsTopLevel, is_top_level);
449 args->SetString(webview::kNewURL, new_url.spec()); 450 args->SetString(webview::kNewURL, new_url.spec());
450 args->SetString(webview::kOldURL, old_url.spec()); 451 args->SetString(webview::kOldURL, old_url.spec());
451 DispatchEvent(new GuestView::Event(webview::kEventLoadRedirect, args.Pass())); 452 DispatchEvent(new GuestView::Event(webview::kEventLoadRedirect, args.Pass()));
452 } 453 }
453 454
454 void WebViewGuest::AddWebViewToExtensionRendererState() { 455 void WebViewGuest::AddWebViewToExtensionRendererState() {
456 const GURL& site_url = web_contents()->GetSiteInstance()->GetSiteURL();
455 ExtensionRendererState::WebViewInfo webview_info; 457 ExtensionRendererState::WebViewInfo webview_info;
456 webview_info.embedder_process_id = embedder_render_process_id(); 458 webview_info.embedder_process_id = embedder_render_process_id();
457 webview_info.instance_id = view_instance_id(); 459 webview_info.instance_id = view_instance_id();
460 // TODO(fsamuel): Partition IDs should probably be a chrome-only concept. They
461 // should probably be passed in via attach args.
462 webview_info.partition_id = site_url.query();
458 463
459 content::BrowserThread::PostTask( 464 content::BrowserThread::PostTask(
460 content::BrowserThread::IO, FROM_HERE, 465 content::BrowserThread::IO, FROM_HERE,
461 base::Bind( 466 base::Bind(
462 &ExtensionRendererState::AddWebView, 467 &ExtensionRendererState::AddWebView,
463 base::Unretained(ExtensionRendererState::GetInstance()), 468 base::Unretained(ExtensionRendererState::GetInstance()),
464 guest_web_contents()->GetRenderProcessHost()->GetID(), 469 guest_web_contents()->GetRenderProcessHost()->GetID(),
465 guest_web_contents()->GetRoutingID(), 470 guest_web_contents()->GetRoutingID(),
466 webview_info)); 471 webview_info));
467 } 472 }
(...skipping 12 matching lines...) Expand all
480 485
481 void WebViewGuest::SizeChanged(const gfx::Size& old_size, 486 void WebViewGuest::SizeChanged(const gfx::Size& old_size,
482 const gfx::Size& new_size) { 487 const gfx::Size& new_size) {
483 scoped_ptr<DictionaryValue> args(new DictionaryValue()); 488 scoped_ptr<DictionaryValue> args(new DictionaryValue());
484 args->SetInteger(webview::kOldHeight, old_size.height()); 489 args->SetInteger(webview::kOldHeight, old_size.height());
485 args->SetInteger(webview::kOldWidth, old_size.width()); 490 args->SetInteger(webview::kOldWidth, old_size.width());
486 args->SetInteger(webview::kNewHeight, new_size.height()); 491 args->SetInteger(webview::kNewHeight, new_size.height());
487 args->SetInteger(webview::kNewWidth, new_size.width()); 492 args->SetInteger(webview::kNewWidth, new_size.width());
488 DispatchEvent(new GuestView::Event(webview::kEventSizeChanged, args.Pass())); 493 DispatchEvent(new GuestView::Event(webview::kEventSizeChanged, args.Pass()));
489 } 494 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698