Commit 9cc98cde authored by edchin's avatar edchin Committed by Commit Bot

[ios] Tab grid clean up.

1) Uses the proper title for tab grid tab cells.
2) Properly sets snapshot image. It was previously 
setting the button's image rather than the imageView.

Bug: 686770
Change-Id: I1f400f9b543528355f3014f3e1503e50166b33e9
Reviewed-on: https://chromium-review.googlesource.com/564346
Commit-Queue: Ed Chin <edchin@chromium.org>
Reviewed-by: default avatarEd Chin <edchin@chromium.org>
Reviewed-by: default avatarJean-François Geyelin <jif@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485449}
parent 5dc28900
......@@ -29,11 +29,13 @@ source_set("tab_collection_ui") {
]
deps = [
"//base",
"//components/strings:components_strings_grit",
"//ios/chrome/app/theme:theme_grit",
"//ios/chrome/browser/snapshots",
"//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/tab_switcher",
"//ios/clean/chrome/browser/ui/commands",
"//ui/base",
]
configs += [ "//build/config/compiler:enable_arc" ]
}
......
......@@ -4,6 +4,10 @@
#import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_item.h"
#include "base/logging.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
......@@ -11,4 +15,19 @@
@implementation TabCollectionItem
@synthesize tabID = _tabID;
@synthesize title = _title;
#pragma mark - Public properties
- (void)setTabID:(NSString*)tabID {
DCHECK_GE(tabID.length, 0U);
_tabID = tabID;
}
- (void)setTitle:(NSString*)title {
_title = title;
if (title.length == 0) {
_title = l10n_util::GetNSString(IDS_DEFAULT_TAB_TITLE);
}
}
@end
......@@ -139,18 +139,12 @@
// Constructs a TabCollectionItem from a |webState|.
- (TabCollectionItem*)tabCollectionItemFromWebState:(web::WebState*)webState {
// PLACEHOLDER: Use real webstate title in the future.
DCHECK(webState);
GURL url = webState->GetVisibleURL();
NSString* urlText = @"<New Tab>";
if (url.is_valid()) {
urlText = base::SysUTF8ToNSString(url.spec());
}
TabIdTabHelper* tabHelper = TabIdTabHelper::FromWebState(webState);
DCHECK(tabHelper);
TabCollectionItem* item = [[TabCollectionItem alloc] init];
item.tabID = tabHelper->tab_id();
item.title = urlText;
item.title = base::SysUTF16ToNSString(webState->GetTitle());
return item;
}
......
......@@ -64,9 +64,7 @@ const CGFloat kSelectedBorderWidth = 4.0f;
callback:^(UIImage* snapshot) {
// PLACEHOLDER: This operation will be cancellable.
if ([weakSelf.item.tabID isEqualToString:item.tabID]) {
[weakSelf.snapshotButton
setImage:snapshot
forState:UIControlStateNormal];
[weakSelf setSnapshot:snapshot];
}
}];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment