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

Issue 2247493003: [Mac] Clean up SadTabView and let SadTabController provide its content (Closed)

Created:
4 years, 4 months ago by Sidney San Martín
Modified:
4 years, 4 months ago
CC:
chromium-reviews, Mark Mentovai
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Mac] Clean up SadTabView and let SadTabController provide its content Prep for making the sad tab's content more dynamic, plus some touch-up and shuffling of responsibilities. - Adds methods to `SadTabView` to set the text of each interface element and the help URL, and makes `SadTabController` responsible for setting them. `SadTabView` still controls appearance and layout. - Gives `SadTabView` a delegate to signal clicks. The button is now private, and tests now use a `WebContentsDelegate` to detect a click on the help link instead of extending `NSApplication`. - Removes some uses of `scoped_nsobject` for instance variables that just need to be weak references. BUG=623690 Committed: https://crrev.com/7c635ed1edb8cbcb68fe5a0646cb554b8dd32b8a Cr-Commit-Position: refs/heads/master@{#411932}

Patch Set 1 #

Total comments: 25

Patch Set 2 : Address most of Avi’s first round of comments #

Patch Set 3 : Adopt NSMake*, cast message_.cell to NSCell #

Total comments: 4

Patch Set 4 : Use base::mac::ObjCCast #

Unified diffs Side-by-side diffs Delta from patch set Stats (+192 lines, -232 lines) Patch
M chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h View 1 chunk +1 line, -5 lines 0 comments Download
M chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm View 1 3 chunks +25 lines, -11 lines 0 comments Download
M chrome/browser/ui/cocoa/tab_contents/sad_tab_controller_unittest.mm View 1 3 chunks +22 lines, -21 lines 0 comments Download
M chrome/browser/ui/cocoa/tab_contents/sad_tab_view_cocoa.h View 1 chunk +15 lines, -11 lines 0 comments Download
M chrome/browser/ui/cocoa/tab_contents/sad_tab_view_cocoa.mm View 1 2 3 2 chunks +128 lines, -184 lines 0 comments Download
M ui/gfx/test/ui_cocoa_test_helper.h View 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 22 (10 generated)
Sidney San Martín
4 years, 4 months ago (2016-08-12 22:46:27 UTC) #4
Avi (use Gerrit)
https://codereview.chromium.org/2247493003/diff/1/chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm File chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm (right): https://codereview.chromium.org/2247493003/diff/1/chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm#newcode6 chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm:6: #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_view_cocoa.h" Put this down with the other includes. ...
4 years, 4 months ago (2016-08-12 23:06:23 UTC) #5
Sidney San Martín
This addresses the easy ones, need feedback on the others. https://codereview.chromium.org/2247493003/diff/1/chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm File chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm (right): https://codereview.chromium.org/2247493003/diff/1/chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm#newcode6 ...
4 years, 4 months ago (2016-08-12 23:35:11 UTC) #6
Avi (use Gerrit)
https://codereview.chromium.org/2247493003/diff/1/chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm File chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm (right): https://codereview.chromium.org/2247493003/diff/1/chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm#newcode46 chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm:46: } I'm working from https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html which in the section ...
4 years, 4 months ago (2016-08-12 23:43:17 UTC) #7
Sidney San Martín
https://codereview.chromium.org/2247493003/diff/1/chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm File chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm (right): https://codereview.chromium.org/2247493003/diff/1/chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm#newcode46 chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm:46: } On 2016/08/12 23:43:16, Avi wrote: > I'm working ...
4 years, 4 months ago (2016-08-14 00:34:33 UTC) #8
Avi (use Gerrit)
LGTM with nit. https://codereview.chromium.org/2247493003/diff/1/chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm File chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm (right): https://codereview.chromium.org/2247493003/diff/1/chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm#newcode46 chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.mm:46: } On 2016/08/14 00:34:32, Sidney San ...
4 years, 4 months ago (2016-08-14 04:54:29 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2247493003/60001
4 years, 4 months ago (2016-08-15 01:15:00 UTC) #13
commit-bot: I haz the power
Committed patchset #4 (id:60001)
4 years, 4 months ago (2016-08-15 01:52:27 UTC) #15
commit-bot: I haz the power
Patchset 4 (id:??) landed as https://crrev.com/7c635ed1edb8cbcb68fe5a0646cb554b8dd32b8a Cr-Commit-Position: refs/heads/master@{#411932}
4 years, 4 months ago (2016-08-15 01:54:37 UTC) #17
Sidney San Martín
Thanks for all of the quick replies. I definitely wasn't expecting a response over the ...
4 years, 4 months ago (2016-08-15 03:40:29 UTC) #18
Avi (use Gerrit)
https://codereview.chromium.org/2247493003/diff/40001/chrome/browser/ui/cocoa/tab_contents/sad_tab_view_cocoa.mm File chrome/browser/ui/cocoa/tab_contents/sad_tab_view_cocoa.mm (right): https://codereview.chromium.org/2247493003/diff/40001/chrome/browser/ui/cocoa/tab_contents/sad_tab_view_cocoa.mm#newcode92 chrome/browser/ui/cocoa/tab_contents/sad_tab_view_cocoa.mm:92: ((NSCell*)message_.cell).wraps = YES; On 2016/08/15 03:40:29, Sidney San Martín ...
4 years, 4 months ago (2016-08-15 03:43:59 UTC) #19
erikchen
4 years, 4 months ago (2016-08-15 21:03:03 UTC) #21
Message was sent while issue was closed.
https://codereview.chromium.org/2247493003/diff/40001/chrome/browser/ui/cocoa...
File chrome/browser/ui/cocoa/tab_contents/sad_tab_view_cocoa.mm (right):

https://codereview.chromium.org/2247493003/diff/40001/chrome/browser/ui/cocoa...
chrome/browser/ui/cocoa/tab_contents/sad_tab_view_cocoa.mm:92:
((NSCell*)message_.cell).wraps = YES;
On 2016/08/15 03:43:59, Avi wrote:
> On 2016/08/15 03:40:29, Sidney San Martín wrote:
> > On 2016/08/14 04:54:28, Avi wrote:
> > > base::mac::ObjCCast
> > 
> > Done. ObjCCast really surprises me though — it returns nil if the object
isn't
> > the expected type, and since a message send to nil is a noop it'll hide most
> > wrong casts. ObjCCastStrict just adds a DCHECK.
> > 
> > It's essentially dynamic_cast, but extra dangerous. Do you know why we use
it
> so
> > much?
> 
> Interesting way of thinking about it. Talk to Mark.

I think that downcasting is an appropriate use case for dynamic casting. We
don't use dynamic cast in C++ because it requires RTTI. 

So there are two possibilities here:
If the cast would have been safe, there is virtually no difference between
static and dynamic cast. (The performance difference is negligible).

If the cast would be unsafe, then with a static cast, the behavior is not well
defined. In this case, there is going to be memory corruption. If we used a
dynamic cast, then instead the call to .wraps = YES would become a no-op.
Neither outcome is great.

For this case, I don't think it matters because the cast should always be safe.
ObjCCastStrict seems appropriate, as it adds a DCHECK which will catch early
developer errors.

Powered by Google App Engine
This is Rietveld 408576698