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

Issue 224733018: Changes to content/ to facilitate new zoom extension API (Closed)

Created:
6 years, 8 months ago by paulmeyer
Modified:
6 years, 5 months ago
Reviewers:
Fady Samuel, jam
CC:
chromium-reviews, darin-cc_chromium.org, nasko+codewatch_chromium.org, jam, creis+watch_chromium.org, miu+watch_chromium.org, Charlie Reis
Visibility:
Public.

Description

A number of changes to content/ needed to facilitate the new zoom extension API, which is outlined in: https://docs.google.com/a/chromium.org/document/d/1sCZjx1J3_M2a02T8NXd-ufGKZDoBHI5Ixis1DaGLQCA/edit?usp=sharing. The changes are: 1. Each WebContents now has a zoom mode. This zoom mode affects the zoom behavior when WebContents::SetZoomMode is called. REASON: The zoom API needs the ability to override default zoom behavior. One big use case of this API is for the new PDF viewer extension, which needs to be able to override chrome's default zooming and rescale PDF pages in a custom way. Also, a big feature of the zoom extension API is to allow extensions to control the scale of zoom changes, e.g. to be able to override the default per-origin zooming in favor of a temporary zoom that is limited to a single tab. These zoom modes provide a way to specify what kind of zoom behavior each WebContents should have. 2. WebContents::SetZoomLevel now has an optional callback function that can be provided. REASON: This API needs to be able to tell when a zoom change has actually finished (i.e. the page has actually finished rescaling and so on), and so this callback nicely provides that functionality. Moreover, I believe that this functionality is very useful in general; other entities that call SetZoomLevel may also want to know when the zooming has completed, or take some specific action when it has completed. 3. Every zoom change initiated from WebContents::SetZoomLevel is given a unique zoom ID. This allows each zoom change to be uniquely identified. This zoom ID is carried along the path from WebContents to HostZoomMap so, where the callback associated with that zoom change will be called. REASON: When an extension uses the zoom API to zoom a page, ZoomController associates that zoom change's zoom ID with the extension that initiated the zoom. Then, when HostZoomMap notifies the ZoomController that a zoom change has been completed, ZoomController will know exactly which extension, if any, caused that zoom, so that when the zoom bubble appears, the correct extension's icon can be added to the zoom bubble to attribute the zoom to the extension. 4. Two new notifications are created that are both sent out from WebContents. One is sent out from when a zoom change is initiated, and contains all of the details of that zoom change. The other is sent out when a WebContents returns to the default zoom mode. REASON: The zoom API includes a new |onZoomChange| event that contains all of the details of the zoom change, including which tab zoomed, and the zoom factor before and after the zoom changed. The first notification sends out this information so that the TabsEventRouter can use it to dispatch the |onZoomChange| event. The second notification is picked up be the HostZoomMap simply to tell it that it no longer needs to maintain a special zoom level for the WebContents that send it. BUG=30583

Patch Set 1 #

Total comments: 10

Patch Set 2 : Now zoom IDs never leave content; SetZoomLevel now has an optional callback. #

Patch Set 3 : Addressed Comments. #

Total comments: 10

Patch Set 4 : No longer using notifications. #

Patch Set 5 : Addressed comments. #

Total comments: 12

Patch Set 6 : Addressed comments. #

Total comments: 10
Unified diffs Side-by-side diffs Delta from patch set Stats (+300 lines, -66 lines) Patch
M content/browser/host_zoom_map_impl.h View 1 2 3 3 chunks +31 lines, -0 lines 0 comments Download
M content/browser/host_zoom_map_impl.cc View 1 2 3 4 11 chunks +66 lines, -33 lines 0 comments Download
M content/browser/renderer_host/render_view_host_impl.h View 1 chunk +2 lines, -1 line 0 comments Download
M content/browser/renderer_host/render_view_host_impl.cc View 1 chunk +6 lines, -3 lines 0 comments Download
M content/browser/web_contents/web_contents_impl.h View 1 3 chunks +11 lines, -0 lines 0 comments Download
M content/browser/web_contents/web_contents_impl.cc View 1 2 3 4 5 5 chunks +95 lines, -3 lines 0 comments Download
M content/common/view_messages.h View 1 2 4 chunks +12 lines, -6 lines 0 comments Download
M content/public/browser/web_contents.h View 1 3 chunks +13 lines, -0 lines 1 comment Download
M content/public/browser/web_contents_observer.h View 1 2 3 2 chunks +6 lines, -0 lines 1 comment Download
M content/public/common/page_zoom.h View 1 2 3 4 5 1 chunk +21 lines, -0 lines 6 comments Download
M content/renderer/render_thread_impl.h View 1 chunk +2 lines, -1 line 0 comments Download
M content/renderer/render_thread_impl.cc View 1 2 3 chunks +19 lines, -12 lines 0 comments Download
M content/renderer/render_view_impl.h View 2 chunks +3 lines, -1 line 2 comments Download
M content/renderer/render_view_impl.cc View 1 2 3 4 5 2 chunks +13 lines, -6 lines 0 comments Download

Messages

Total messages: 12 (0 generated)
paulmeyer
+fsamuel@
6 years, 8 months ago (2014-04-07 19:39:47 UTC) #1
Fady Samuel
Initial set of comments. It would be nice to clean up the content API a ...
6 years, 8 months ago (2014-04-07 21:27:24 UTC) #2
paulmeyer
ptal https://codereview.chromium.org/224733018/diff/1/content/browser/host_zoom_map_impl.h File content/browser/host_zoom_map_impl.h (right): https://codereview.chromium.org/224733018/diff/1/content/browser/host_zoom_map_impl.h#newcode57 content/browser/host_zoom_map_impl.h:57: // Passes a zoom ID along to the ...
6 years, 8 months ago (2014-04-08 21:13:20 UTC) #3
Fady Samuel
https://codereview.chromium.org/224733018/diff/40001/content/browser/host_zoom_map_impl.cc File content/browser/host_zoom_map_impl.cc (right): https://codereview.chromium.org/224733018/diff/40001/content/browser/host_zoom_map_impl.cc#newcode286 content/browser/host_zoom_map_impl.cc:286: if (it != zoom_callback_map_.end()) { Preferred early exit. if ...
6 years, 8 months ago (2014-04-10 14:27:25 UTC) #4
paulmeyer
ptal https://codereview.chromium.org/224733018/diff/40001/content/browser/host_zoom_map_impl.cc File content/browser/host_zoom_map_impl.cc (right): https://codereview.chromium.org/224733018/diff/40001/content/browser/host_zoom_map_impl.cc#newcode286 content/browser/host_zoom_map_impl.cc:286: if (it != zoom_callback_map_.end()) { On 2014/04/10 14:27:25, ...
6 years, 8 months ago (2014-04-10 15:11:49 UTC) #5
Fady Samuel
https://codereview.chromium.org/224733018/diff/80001/content/browser/web_contents/web_contents_impl.cc File content/browser/web_contents/web_contents_impl.cc (right): https://codereview.chromium.org/224733018/diff/80001/content/browser/web_contents/web_contents_impl.cc#newcode2102 content/browser/web_contents/web_contents_impl.cc:2102: FOR_EACH_OBSERVER(WebContentsObserver, observers_, Can this go at the bottom after ...
6 years, 8 months ago (2014-04-10 17:09:02 UTC) #6
paulmeyer
ptal https://codereview.chromium.org/224733018/diff/80001/content/browser/web_contents/web_contents_impl.cc File content/browser/web_contents/web_contents_impl.cc (right): https://codereview.chromium.org/224733018/diff/80001/content/browser/web_contents/web_contents_impl.cc#newcode2102 content/browser/web_contents/web_contents_impl.cc:2102: FOR_EACH_OBSERVER(WebContentsObserver, observers_, On 2014/04/10 17:09:03, Fady Samuel wrote: ...
6 years, 8 months ago (2014-04-10 17:24:37 UTC) #7
Fady Samuel
lgtm. Please add creis@ as a reviewer.
6 years, 8 months ago (2014-04-10 17:26:28 UTC) #8
paulmeyer
+creis@ as content/ owner.
6 years, 8 months ago (2014-04-10 17:28:01 UTC) #9
Charlie Reis
Sorry, this is a pretty big design-level change that I'm not comfortable reviewing on my ...
6 years, 8 months ago (2014-04-10 18:57:48 UTC) #10
paulmeyer
-creis@ +jam@ for content/ owner
6 years, 8 months ago (2014-04-10 19:48:37 UTC) #11
jam
6 years, 8 months ago (2014-04-10 21:45:44 UTC) #12
initial comments

my first impression is that this appears to duplicate functionality from
HostZoomMap and you can get similar functionality by calling it instead of
adding this zoom mode concept to the content api.

https://codereview.chromium.org/224733018/diff/100001/content/public/browser/...
File content/public/browser/web_contents.h (right):

https://codereview.chromium.org/224733018/diff/100001/content/public/browser/...
content/public/browser/web_contents.h:512: const base::Callback<void(void)>&
callback) = 0;
why exactly does the extensions api need this callback?

also note that you can subscribe to zoom level changes through HostZoomMap's
callbacks (AddZoomLevelChangedCallback). have you looked into using that instead
of this? this is how chrome updates its UI

https://codereview.chromium.org/224733018/diff/100001/content/public/browser/...
File content/public/browser/web_contents_observer.h (right):

https://codereview.chromium.org/224733018/diff/100001/content/public/browser/...
content/public/browser/web_contents_observer.h:326: ZoomMode zoom_mode) {}
see http://www.chromium.org/developers/content-module/content-api, specifically:

"methods in the API should be there because either content is calling out to its
embedder, or the embedder is calling to content. There shouldn't be any methods
which are used to call from the embedder to the embedder."

since the chrome layer is calling WebContents::SetZoomLevel, we shouldn't have
to tell it back again that it did. whatever code it needs to be done as a result
it should do at the callsites.

https://codereview.chromium.org/224733018/diff/100001/content/public/common/p...
File content/public/common/page_zoom.h (right):

https://codereview.chromium.org/224733018/diff/100001/content/public/common/p...
content/public/common/page_zoom.h:50: //    
NOTIFICATION_WEB_CONTENTS_ZOOM_CHANGE notification will still be
this seems like an old comment since you switched to the observer. but more
importantly, i think this concept needs to be removed from the api per my other
comment with the link to the content api guidelines. we shouldn't have a mode
where content doesn't know anything. if a webcontents is in that mode, then
chrome layer should just not call that webcontents.

https://codereview.chromium.org/224733018/diff/100001/content/public/common/p...
content/public/common/page_zoom.h:58: kZoomModeIsolated,
this really seems like the same concept of
HostZoomMapImpl::SetTemporaryZoomLevel, which we can promote to the public
interface (HostZoomMap).

https://codereview.chromium.org/224733018/diff/100001/content/public/common/p...
content/public/common/page_zoom.h:60: kZoomModeDisabled,
this appears to have the same problem as the above comment, namely it's set on a
webcontents by chrome, and used to ignore method calls from chrome afterwards.
if chrome layer wants to disable zooming on a webcontents, it shouldn't call
setzoom on it.

https://codereview.chromium.org/224733018/diff/100001/content/renderer/render...
File content/renderer/render_view_impl.h (right):

https://codereview.chromium.org/224733018/diff/100001/content/renderer/render...
content/renderer/render_view_impl.h:495: virtual void zoomLevelChanged(int
zoom_id, double zoom_level, bool remember);
this is not a WebViewClient method, so move it out of this section and no need
for virtual.

put it in the private section, and call it something like ChangeZoomLevel(...)

https://codereview.chromium.org/224733018/diff/100001/content/renderer/render...
content/renderer/render_view_impl.h:911: content::ZoomMode zoom_mode);
nit: no content:: needed inside content namespace. this comment applies here and
in all the other files in content

Powered by Google App Engine
This is Rietveld 408576698