diff options
author | nasko@chromium.org <nasko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-13 11:53:18 +0000 |
---|---|---|
committer | nasko@chromium.org <nasko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-13 11:53:18 +0000 |
commit | 4e3c752307b8a68f8d279aa4612662f8684f5363 (patch) | |
tree | 9db812137ad3acc1c6562853fb0838d448aa38e1 | |
parent | c0101c75c353ec1d932e1d531617b963714ac17d (diff) | |
download | chromium_src-4e3c752307b8a68f8d279aa4612662f8684f5363.zip chromium_src-4e3c752307b8a68f8d279aa4612662f8684f5363.tar.gz chromium_src-4e3c752307b8a68f8d279aa4612662f8684f5363.tar.bz2 |
Content changes for GetURL refactor.
The GetURL method doesn't cover the different use cases for it, so it is being split up and the original will be removed.
This CL is converting content code to use the proper version of WebContents::GetURL API.
BUG=237908
Review URL: https://chromiumcodereview.appspot.com/21173002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217237 0039d316-1c4b-4281-b951-d872f2087c98
14 files changed, 45 insertions, 35 deletions
diff --git a/content/browser/android/web_contents_observer_android.cc b/content/browser/android/web_contents_observer_android.cc index 67d8482..d9a1507 100644 --- a/content/browser/android/web_contents_observer_android.cc +++ b/content/browser/android/web_contents_observer_android.cc @@ -66,8 +66,8 @@ void WebContentsObserverAndroid::DidStartLoading( ScopedJavaLocalRef<jobject> obj(weak_java_observer_.get(env)); if (obj.is_null()) return; - ScopedJavaLocalRef<jstring> jstring_url( - ConvertUTF8ToJavaString(env, web_contents()->GetURL().spec())); + ScopedJavaLocalRef<jstring> jstring_url(ConvertUTF8ToJavaString( + env, web_contents()->GetVisibleURL().spec())); Java_WebContentsObserverAndroid_didStartLoading( env, obj.obj(), jstring_url.obj()); } @@ -78,8 +78,8 @@ void WebContentsObserverAndroid::DidStopLoading( ScopedJavaLocalRef<jobject> obj(weak_java_observer_.get(env)); if (obj.is_null()) return; - ScopedJavaLocalRef<jstring> jstring_url( - ConvertUTF8ToJavaString(env, web_contents()->GetURL().spec())); + ScopedJavaLocalRef<jstring> jstring_url(ConvertUTF8ToJavaString( + env, web_contents()->GetLastCommittedURL().spec())); Java_WebContentsObserverAndroid_didStopLoading( env, obj.obj(), jstring_url.obj()); } diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc index a8d164a..c0652dd 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.cc +++ b/content/browser/browser_plugin/browser_plugin_guest.cc @@ -127,7 +127,7 @@ class BrowserPluginGuest::GeolocationRequest : public PermissionRequest { // in the fact whether the embedder/app has geolocation // permission. Therefore we use an invalid |bridge_id|. -1 /* bridge_id */, - web_contents->GetURL(), + web_contents->GetLastCommittedURL(), geolocation_callback); return; } @@ -1260,7 +1260,7 @@ void BrowserPluginGuest::OnLockMouse(bool user_gesture, base::Value::CreateBooleanValue(last_unlocked_by_target)); request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue( - web_contents()->GetURL().spec())); + web_contents()->GetLastCommittedURL().spec())); RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_POINTER_LOCK, new PointerLockRequest(this), diff --git a/content/browser/device_orientation/device_orientation_browsertest.cc b/content/browser/device_orientation/device_orientation_browsertest.cc index 17d9446..095e85f 100644 --- a/content/browser/device_orientation/device_orientation_browsertest.cc +++ b/content/browser/device_orientation/device_orientation_browsertest.cc @@ -71,7 +71,7 @@ IN_PROC_BROWSER_TEST_F(DeviceOrientationBrowserTest, BasicTest) { // Check that the page got the event it expected and that the provider // saw requests for adding and removing an observer. - EXPECT_EQ("pass", shell()->web_contents()->GetURL().ref()); + EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); EXPECT_TRUE(provider->added_observer_); EXPECT_TRUE(provider->removed_observer_); } diff --git a/content/browser/dom_storage/dom_storage_browsertest.cc b/content/browser/dom_storage/dom_storage_browsertest.cc index 54da50a..79955a8 100644 --- a/content/browser/dom_storage/dom_storage_browsertest.cc +++ b/content/browser/dom_storage/dom_storage_browsertest.cc @@ -25,7 +25,8 @@ class DOMStorageBrowserTest : public ContentBrowserTest { // a #pass or #fail ref. Shell* the_browser = incognito ? CreateOffTheRecordBrowser() : shell(); NavigateToURLBlockUntilNavigationsComplete(the_browser, test_url, 2); - std::string result = the_browser->web_contents()->GetURL().ref(); + std::string result = + the_browser->web_contents()->GetLastCommittedURL().ref(); if (result != "pass") { std::string js_result; ASSERT_TRUE(ExecuteScriptAndExtractString( diff --git a/content/browser/download/save_package_unittest.cc b/content/browser/download/save_package_unittest.cc index 9c8f29f..c0aa3f8 100644 --- a/content/browser/download/save_package_unittest.cc +++ b/content/browser/download/save_package_unittest.cc @@ -434,7 +434,7 @@ TEST_F(SavePackageTest, TestGetUrlToBeSavedViewSource) { base::FilePath(kTestDir).Append(file_name)); NavigateAndCommit(view_source_url); EXPECT_EQ(actual_url, GetUrlToBeSaved()); - EXPECT_EQ(view_source_url, contents()->GetURL()); + EXPECT_EQ(view_source_url, contents()->GetLastCommittedURL()); } } // namespace content diff --git a/content/browser/fileapi/file_system_browsertest.cc b/content/browser/fileapi/file_system_browsertest.cc index 7c464a3..6a79a40 100644 --- a/content/browser/fileapi/file_system_browsertest.cc +++ b/content/browser/fileapi/file_system_browsertest.cc @@ -36,7 +36,8 @@ class FileSystemBrowserTest : public ContentBrowserTest { LOG(INFO) << "Navigating to URL and blocking."; NavigateToURLBlockUntilNavigationsComplete(the_browser, test_url, 2); LOG(INFO) << "Navigation done."; - std::string result = the_browser->web_contents()->GetURL().ref(); + std::string result = + the_browser->web_contents()->GetLastCommittedURL().ref(); if (result != "pass") { std::string js_result; ASSERT_TRUE(ExecuteScriptAndExtractString( diff --git a/content/browser/indexed_db/indexed_db_browsertest.cc b/content/browser/indexed_db/indexed_db_browsertest.cc index ab010cb..ac541e7 100644 --- a/content/browser/indexed_db/indexed_db_browsertest.cc +++ b/content/browser/indexed_db/indexed_db_browsertest.cc @@ -46,7 +46,8 @@ class IndexedDBBrowserTest : public ContentBrowserTest { LOG(INFO) << "Navigating to URL and blocking."; NavigateToURLBlockUntilNavigationsComplete(the_browser, test_url, 2); LOG(INFO) << "Navigation done."; - std::string result = the_browser->web_contents()->GetURL().ref(); + std::string result = + the_browser->web_contents()->GetLastCommittedURL().ref(); if (result != "pass") { std::string js_result; ASSERT_TRUE(ExecuteScriptAndExtractString( diff --git a/content/browser/indexed_db/indexed_db_internals_ui.cc b/content/browser/indexed_db/indexed_db_internals_ui.cc index f6f3bce..230b788 100644 --- a/content/browser/indexed_db/indexed_db_internals_ui.cc +++ b/content/browser/indexed_db/indexed_db_internals_ui.cc @@ -278,7 +278,7 @@ void IndexedDBInternalsUI::OnDownloadDataReady( DownloadUrlParameters::FromWebContents(web_ui()->GetWebContents(), url)); DownloadManager* dlm = BrowserContext::GetDownloadManager(browser_context); - const GURL referrer(web_ui()->GetWebContents()->GetURL()); + const GURL referrer(web_ui()->GetWebContents()->GetLastCommittedURL()); dl_params->set_referrer( content::Referrer(referrer, WebKit::WebReferrerPolicyDefault)); diff --git a/content/browser/renderer_host/render_view_host_manager_browsertest.cc b/content/browser/renderer_host/render_view_host_manager_browsertest.cc index 4053d65..f5ebb76 100644 --- a/content/browser/renderer_host/render_view_host_manager_browsertest.cc +++ b/content/browser/renderer_host/render_view_host_manager_browsertest.cc @@ -86,7 +86,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, // Wait for the navigation in the new window to finish, if it hasn't. WaitForLoadStop(new_shell->web_contents()); EXPECT_EQ("/files/navigate_opener.html", - new_shell->web_contents()->GetURL().path()); + new_shell->web_contents()->GetLastCommittedURL().path()); // Should have the same SiteInstance. scoped_refptr<SiteInstance> blank_site_instance( @@ -153,7 +153,8 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, // Wait for the window to open. Shell* new_shell = new_shell_observer.GetShell(); - EXPECT_EQ("/files/title2.html", new_shell->web_contents()->GetURL().path()); + EXPECT_EQ("/files/title2.html", + new_shell->web_contents()->GetVisibleURL().path()); // Wait for the cross-site transition in the new tab to finish. WaitForLoadStop(new_shell->web_contents()); @@ -207,7 +208,8 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, Shell* new_shell = new_shell_observer.GetShell(); // Opens in new window. - EXPECT_EQ("/files/title2.html", new_shell->web_contents()->GetURL().path()); + EXPECT_EQ("/files/title2.html", + new_shell->web_contents()->GetVisibleURL().path()); // Wait for the cross-site transition in the new tab to finish. WaitForLoadStop(new_shell->web_contents()); @@ -262,7 +264,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, // Wait for the cross-site transition in the new tab to finish. WaitForLoadStop(new_shell->web_contents()); EXPECT_EQ("/files/title2.html", - new_shell->web_contents()->GetURL().path()); + new_shell->web_contents()->GetLastCommittedURL().path()); // Should have the same SiteInstance. scoped_refptr<SiteInstance> blank_site_instance( @@ -308,7 +310,8 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, // Opens in same window. EXPECT_EQ(1u, Shell::windows().size()); - EXPECT_EQ("/files/title2.html", shell()->web_contents()->GetURL().path()); + EXPECT_EQ("/files/title2.html", + shell()->web_contents()->GetLastCommittedURL().path()); // Should have the same SiteInstance. scoped_refptr<SiteInstance> noref_site_instance( @@ -376,7 +379,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, // Wait for the navigation in the new tab to finish, if it hasn't. WaitForLoadStop(new_shell->web_contents()); EXPECT_EQ("/files/navigate_opener.html", - new_shell->web_contents()->GetURL().path()); + new_shell->web_contents()->GetLastCommittedURL().path()); // Should have the same SiteInstance. scoped_refptr<SiteInstance> blank_site_instance( @@ -456,7 +459,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, DisownOpener) { // Wait for the navigation in the new tab to finish, if it hasn't. WaitForLoadStop(new_shell->web_contents()); EXPECT_EQ("/files/title2.html", - new_shell->web_contents()->GetURL().path()); + new_shell->web_contents()->GetLastCommittedURL().path()); // Should have the same SiteInstance. scoped_refptr<SiteInstance> blank_site_instance( @@ -562,7 +565,8 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, // send it to post_message.html on a different site. WebContents* foo_contents = new_shell->web_contents(); WaitForLoadStop(foo_contents); - EXPECT_EQ("/files/navigate_opener.html", foo_contents->GetURL().path()); + EXPECT_EQ("/files/navigate_opener.html", + foo_contents->GetLastCommittedURL().path()); NavigateToURL(new_shell, https_server.GetURL("files/post_message.html")); scoped_refptr<SiteInstance> foo_site_instance( foo_contents->GetSiteInstance()); @@ -581,7 +585,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, Shell* new_shell2 = new_shell_observer2.GetShell(); WebContents* new_contents = new_shell2->web_contents(); WaitForLoadStop(new_contents); - EXPECT_EQ("/files/title2.html", new_contents->GetURL().path()); + EXPECT_EQ("/files/title2.html", new_contents->GetLastCommittedURL().path()); NavigateToURL(new_shell2, test_server()->GetURL("files/post_message.html")); EXPECT_EQ(orig_site_instance, new_contents->GetSiteInstance()); RenderViewHostManager* new_manager = @@ -698,7 +702,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, // Wait for the navigation in the new window to finish, if it hasn't. WaitForLoadStop(new_shell->web_contents()); EXPECT_EQ("/files/navigate_opener.html", - new_shell->web_contents()->GetURL().path()); + new_shell->web_contents()->GetLastCommittedURL().path()); // Should have the same SiteInstance. scoped_refptr<SiteInstance> blank_site_instance( @@ -765,7 +769,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, // Wait for the navigation in the new window to finish, if it hasn't. WaitForLoadStop(new_shell->web_contents()); EXPECT_EQ("/files/navigate_opener.html", - new_shell->web_contents()->GetURL().path()); + new_shell->web_contents()->GetLastCommittedURL().path()); // Should have the same SiteInstance. scoped_refptr<SiteInstance> opened_site_instance( @@ -829,7 +833,8 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, ClickLinkAfter204Error) { scoped_refptr<SiteInstance> post_nav_site_instance( shell()->web_contents()->GetSiteInstance()); EXPECT_EQ(orig_site_instance, post_nav_site_instance); - EXPECT_EQ("/nocontent", shell()->web_contents()->GetURL().path()); + EXPECT_EQ("/nocontent", + shell()->web_contents()->GetVisibleURL().path()); EXPECT_EQ("/files/click-noreferrer-links.html", shell()->web_contents()->GetController(). GetLastCommittedEntry()->GetVirtualURL().path()); @@ -847,7 +852,8 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, ClickLinkAfter204Error) { // Opens in same tab. EXPECT_EQ(1u, Shell::windows().size()); - EXPECT_EQ("/files/title2.html", shell()->web_contents()->GetURL().path()); + EXPECT_EQ("/files/title2.html", + shell()->web_contents()->GetLastCommittedURL().path()); // Should have the same SiteInstance. scoped_refptr<SiteInstance> noref_site_instance( @@ -1073,7 +1079,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, // Wait for the navigation in the new tab to finish, if it hasn't. WaitForLoadStop(new_shell->web_contents()); EXPECT_EQ("/files/navigate_opener.html", - new_shell->web_contents()->GetURL().path()); + new_shell->web_contents()->GetLastCommittedURL().path()); RenderViewHost* rvh = new_shell->web_contents()->GetRenderViewHost(); @@ -1104,7 +1110,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, } EXPECT_EQ("/files/navigate_opener.html", - new_shell->web_contents()->GetURL().path()); + new_shell->web_contents()->GetLastCommittedURL().path()); EXPECT_EQ(rvh, new_shell->web_contents()->GetRenderViewHost()); @@ -1187,7 +1193,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, LeakingRenderViewHosts) { // view-source URL, we create a new SiteInstance. RenderViewHost* blank_rvh = shell()->web_contents()->GetRenderViewHost(); SiteInstance* blank_site_instance = blank_rvh->GetSiteInstance(); - EXPECT_EQ(shell()->web_contents()->GetURL(), GURL::EmptyGURL()); + EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), GURL::EmptyGURL()); EXPECT_EQ(blank_site_instance->GetSiteURL(), GURL::EmptyGURL()); rvh_observers.AddObserverToRVH(blank_rvh); @@ -1269,7 +1275,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, // Wait for the navigation in the new window to finish, if it hasn't. WaitForLoadStop(new_shell->web_contents()); EXPECT_EQ("/files/title1.html", - new_shell->web_contents()->GetURL().path()); + new_shell->web_contents()->GetLastCommittedURL().path()); // Should have the same SiteInstance. EXPECT_EQ(orig_site_instance, new_shell->web_contents()->GetSiteInstance()); @@ -1286,7 +1292,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, // Make sure it ends up at the right page. WaitForLoadStop(shell()->web_contents()); EXPECT_EQ(https_server.GetURL("files/title1.html"), - shell()->web_contents()->GetURL()); + shell()->web_contents()->GetLastCommittedURL()); EXPECT_EQ(new_site_instance, shell()->web_contents()->GetSiteInstance()); } diff --git a/content/browser/session_history_browsertest.cc b/content/browser/session_history_browsertest.cc index d0bd950..966ccc7 100644 --- a/content/browser/session_history_browsertest.cc +++ b/content/browser/session_history_browsertest.cc @@ -89,7 +89,7 @@ class SessionHistoryTest : public ContentBrowserTest { } GURL GetTabURL() { - return shell()->web_contents()->GetURL(); + return shell()->web_contents()->GetLastCommittedURL(); } GURL GetURL(const std::string file) { diff --git a/content/browser/speech/speech_recognition_browsertest.cc b/content/browser/speech/speech_recognition_browsertest.cc index 8e4c7a8..e532bc7 100644 --- a/content/browser/speech/speech_recognition_browsertest.cc +++ b/content/browser/speech/speech_recognition_browsertest.cc @@ -69,7 +69,7 @@ class SpeechRecognitionBrowserTest : public ContentBrowserTest { // then sets the URL fragment as 'pass' if it received the expected string. LoadAndStartSpeechRecognitionTest(filename); - EXPECT_EQ("pass", shell()->web_contents()->GetURL().ref()); + EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); } // ContentBrowserTest methods. diff --git a/content/browser/web_contents/web_contents_drag_win.cc b/content/browser/web_contents/web_contents_drag_win.cc index 68e2788..cb24210 100644 --- a/content/browser/web_contents/web_contents_drag_win.cc +++ b/content/browser/web_contents/web_contents_drag_win.cc @@ -163,7 +163,7 @@ void WebContentsDragWin::StartDragging(const DropData& drop_data, drag_source_ = new WebDragSource(source_window_, web_contents_); - const GURL& page_url = web_contents_->GetURL(); + const GURL& page_url = web_contents_->GetLastCommittedURL(); const std::string& page_encoding = web_contents_->GetEncoding(); // If it is not drag-out, do the drag-and-drop in the current UI thread. diff --git a/content/browser/web_contents/web_drag_source_mac.mm b/content/browser/web_contents/web_drag_source_mac.mm index f523323..6a31fe2 100644 --- a/content/browser/web_contents/web_drag_source_mac.mm +++ b/content/browser/web_contents/web_drag_source_mac.mm @@ -383,7 +383,8 @@ NSString* GetDropLocation(NSPasteboard* pboard) { filePath, fileStream.Pass(), downloadURL_, - content::Referrer(contents_->GetURL(), dropData_->referrer_policy), + content::Referrer(contents_->GetLastCommittedURL(), + dropData_->referrer_policy), contents_->GetEncoding(), contents_)); diff --git a/content/shell/shell.cc b/content/shell/shell.cc index 0fadcf8..93f13bf 100644 --- a/content/shell/shell.cc +++ b/content/shell/shell.cc @@ -306,7 +306,7 @@ void Shell::WebContentsCreated(WebContents* source_contents, } void Shell::DidNavigateMainFramePostCommit(WebContents* web_contents) { - PlatformSetAddressBarURL(web_contents->GetURL()); + PlatformSetAddressBarURL(web_contents->GetLastCommittedURL()); } JavaScriptDialogManager* Shell::GetJavaScriptDialogManager() { |