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

Issue 2434063002: Move extensions code from WebContents::GetURL to GetLastCommittedURL.

Created:
4 years, 2 months ago by nasko
Modified:
4 years, 2 months ago
Reviewers:
Devlin
CC:
chromium-reviews, chromium-apps-reviews_chromium.org, extensions-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Move extensions code from WebContents::GetURL to GetLastCommittedURL. WebContents::GetURL has been deprecated for a while and is hard to use correctly. This CL is moving some extensions code to use GetLastCommittedURL instead, which is the proper replacement. BUG=237908

Patch Set 1 #

Patch Set 2 : Add URL type enum to CreateTabObject. #

Patch Set 3 : Refactor to simplify. #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+44 lines, -9 lines) Patch
M chrome/browser/extensions/api/tabs/tabs_api.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/extensions/extension_tab_util.h View 1 2 2 chunks +30 lines, -4 lines 3 comments Download
M chrome/browser/extensions/extension_tab_util.cc View 1 2 4 chunks +13 lines, -4 lines 0 comments Download

Messages

Total messages: 16 (14 generated)
nasko
Hey Devlin, How does this look for first stab at moving Tab object creation to ...
4 years, 2 months ago (2016-10-20 00:48:43 UTC) #11
Devlin
4 years, 2 months ago (2016-10-20 17:27:24 UTC) #16
Two questions:
- How does this not break the test where we create a tab and expect the url to
be what we just updated it to in the test? [1]  That is,
chrome.tabs.create({url: 'example.com'}, function(tab) {
  assertEq('example.com', tab.url);
});

- We return the visible url in the response to update(), but not in the
onUpdated method.  Does that mean that if I update a tab and listen to
onUpdated, the tabs passed are different?  e.g. let's say we start on
example.com:

chrome.tabs.onUpdated.addListener(function(tab) {
  tab.url  // Is this the last committed url, which would be example.com?
});

chrome.tabs.update({tabId: 1, url: 'google.com'}, function(tab) {
  tab.url  // Is this the last visible url, which would be google.com?
});

The mismatch between those two seems rather odd... :/

[1]
https://cs.chromium.org/chromium/src/chrome/test/data/extensions/api_test/tab...

https://codereview.chromium.org/2434063002/diff/40001/chrome/browser/extensio...
File chrome/browser/extensions/extension_tab_util.h (right):

https://codereview.chromium.org/2434063002/diff/40001/chrome/browser/extensio...
chrome/browser/extensions/extension_tab_util.h:87: enum UrlType { LastCommitted,
Visible };
On 2016/10/20 00:48:42, nasko (slow) wrote:
> This along with the methods taking it can potentially move into the anonymous
> namespace in the .cc file. I did hit some linker errors when I tried that, but
> didn't dig further.

I'm fine with it here (and think it should be; see below).  But we should use an
enum class, and unfortunately chrome requires SCREAMING_STYLE enums (even though
it hurts my ears).

https://codereview.chromium.org/2434063002/diff/40001/chrome/browser/extensio...
chrome/browser/extensions/extension_tab_util.h:107: static
std::unique_ptr<api::tabs::Tab> CreateTabObjectVisibleUrl(
In the tabs API, we'll also scrub the tab object of private data (like urls and
favicons) if the extension doesn't have the "tabs" permission. As such, I think
in this context, "VisibleUrl" is a little ambiguous (visible vs last committed,
or visible meaning present?).  Overall, I'd probably just recommend using the
overload that takes the UrlType in the places we want to specify using the
visible url, rather than adding this separate method.

Powered by Google App Engine
This is Rietveld 408576698