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

Unified Diff: chrome/browser/extensions/extension_tab_util.cc

Issue 2434063002: Move extensions code from WebContents::GetURL to GetLastCommittedURL.
Patch Set: Refactor to simplify. Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_tab_util.cc
diff --git a/chrome/browser/extensions/extension_tab_util.cc b/chrome/browser/extensions/extension_tab_util.cc
index f1ef9c051915e1d24062eb971a72d40fa3165e1e..f6774e7c06ca3c3c567324115f173e7699bae5b0 100644
--- a/chrome/browser/extensions/extension_tab_util.cc
+++ b/chrome/browser/extensions/extension_tab_util.cc
@@ -333,7 +333,8 @@ std::unique_ptr<api::tabs::Tab> ExtensionTabUtil::CreateTabObject(
WebContents* contents,
TabStripModel* tab_strip,
int tab_index,
- const Extension* extension) {
+ const Extension* extension,
+ UrlType url_type) {
// If we have a matching AppWindow with a controller, get the tab value
// from its controller instead.
WindowController* controller = GetAppWindowController(contents);
@@ -342,7 +343,7 @@ std::unique_ptr<api::tabs::Tab> ExtensionTabUtil::CreateTabObject(
return controller->CreateTabObject(extension, tab_index);
}
std::unique_ptr<api::tabs::Tab> result =
- CreateTabObject(contents, tab_strip, tab_index);
+ CreateTabObject(contents, tab_strip, tab_index, url_type);
ScrubTabForExtension(extension, contents, result.get());
return result;
}
@@ -365,7 +366,8 @@ std::unique_ptr<base::ListValue> ExtensionTabUtil::CreateTabList(
std::unique_ptr<api::tabs::Tab> ExtensionTabUtil::CreateTabObject(
content::WebContents* contents,
TabStripModel* tab_strip,
- int tab_index) {
+ int tab_index,
+ UrlType url_type) {
// If we have a matching AppWindow with a controller, get the tab value
// from its controller instead.
WindowController* controller = GetAppWindowController(contents);
@@ -396,7 +398,14 @@ std::unique_ptr<api::tabs::Tab> ExtensionTabUtil::CreateTabObject(
tab_object->height.reset(
new int(contents->GetContainerBounds().size().height()));
- tab_object->url.reset(new std::string(contents->GetURL().spec()));
+ GURL url;
+ switch (url_type) {
+ case LastCommitted:
+ url = contents->GetLastCommittedURL();
+ case Visible:
+ url = contents->GetVisibleURL();
+ }
+ tab_object->url.reset(new std::string(url.spec()));
tab_object->title.reset(
new std::string(base::UTF16ToUTF8(contents->GetTitle())));
NavigationEntry* entry = contents->GetController().GetVisibleEntry();

Powered by Google App Engine
This is Rietveld 408576698