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

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

Issue 27408004: <webview>: Resolve relative paths as chrome-extension: URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't update src attribute with resolved URL. Created 7 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 (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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 last_seen_auto_size_enabled_(false), 358 last_seen_auto_size_enabled_(false),
359 is_in_destruction_(false) { 359 is_in_destruction_(false) {
360 DCHECK(web_contents); 360 DCHECK(web_contents);
361 web_contents->SetDelegate(this); 361 web_contents->SetDelegate(this);
362 if (opener) 362 if (opener)
363 opener_ = opener->AsWeakPtr(); 363 opener_ = opener->AsWeakPtr();
364 GetWebContents()->GetBrowserPluginGuestManager()->AddGuest(instance_id_, 364 GetWebContents()->GetBrowserPluginGuestManager()->AddGuest(instance_id_,
365 GetWebContents()); 365 GetWebContents());
366 } 366 }
367 367
368 SiteInstance* BrowserPluginGuest::GetEmbedderSiteInstance() const {
369 if (attached())
370 return embedder_web_contents()->GetSiteInstance();
371
372 if (!opener()) {
Charlie Reis 2013/10/18 17:37:55 How do we know this is true? Couldn't we have an
Fady Samuel 2013/10/25 21:10:31 I've removed this method. It's no longer necessary
373 NOTREACHED();
374 return NULL;
375 }
376
377 return opener()->embedder_web_contents()->GetSiteInstance();
Charlie Reis 2013/10/18 17:37:55 This seems confusing to me. There's no guarantee
Fady Samuel 2013/10/25 21:10:31 Removed.
378 }
379
368 bool BrowserPluginGuest::AddMessageToConsole(WebContents* source, 380 bool BrowserPluginGuest::AddMessageToConsole(WebContents* source,
369 int32 level, 381 int32 level,
370 const string16& message, 382 const string16& message,
371 int32 line_no, 383 int32 line_no,
372 const string16& source_id) { 384 const string16& source_id) {
373 if (!delegate_) 385 if (!delegate_)
374 return false; 386 return false;
375 387
376 delegate_->AddMessageToConsole(level, message, line_no, source_id); 388 delegate_->AddMessageToConsole(level, message, line_no, source_id);
377 return true; 389 return true;
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 void BrowserPluginGuest::OnLockMouseAck(int instance_id, bool succeeded) { 1347 void BrowserPluginGuest::OnLockMouseAck(int instance_id, bool succeeded) {
1336 Send(new ViewMsg_LockMouse_ACK(routing_id(), succeeded)); 1348 Send(new ViewMsg_LockMouse_ACK(routing_id(), succeeded));
1337 pending_lock_request_ = false; 1349 pending_lock_request_ = false;
1338 if (succeeded) 1350 if (succeeded)
1339 mouse_locked_ = true; 1351 mouse_locked_ = true;
1340 } 1352 }
1341 1353
1342 void BrowserPluginGuest::OnNavigateGuest( 1354 void BrowserPluginGuest::OnNavigateGuest(
1343 int instance_id, 1355 int instance_id,
1344 const std::string& src) { 1356 const std::string& src) {
1345 GURL url(src); 1357 GURL url = delegate_ ? delegate_->ResolveURL(src) : GURL(src);
1346 // We do not load empty urls in web_contents. 1358 // We do not load empty urls in web_contents.
1347 // If a guest sets empty src attribute after it has navigated to some 1359 // If a guest sets empty src attribute after it has navigated to some
1348 // non-empty page, the action is considered no-op. This empty src navigation 1360 // non-empty page, the action is considered no-op. This empty src navigation
1349 // should never be sent to BrowserPluginGuest (browser process). 1361 // should never be sent to BrowserPluginGuest (browser process).
1350 DCHECK(!src.empty()); 1362 DCHECK(!src.empty());
1351 if (src.empty()) 1363 if (src.empty())
1352 return; 1364 return;
1353 1365
1354 // Do not allow navigating a guest to schemes other than known safe schemes. 1366 // Do not allow navigating a guest to schemes other than known safe schemes.
1355 // This will block the embedder trying to load unwanted schemes, e.g. 1367 // This will block the embedder trying to load unwanted schemes, e.g.
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 request_info.Set(browser_plugin::kRequestMethod, 1744 request_info.Set(browser_plugin::kRequestMethod,
1733 base::Value::CreateStringValue(request_method)); 1745 base::Value::CreateStringValue(request_method));
1734 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); 1746 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url));
1735 1747
1736 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD, 1748 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD,
1737 new DownloadRequest(callback), 1749 new DownloadRequest(callback),
1738 request_info); 1750 request_info);
1739 } 1751 }
1740 1752
1741 } // namespace content 1753 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698