diff options
author | danno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-29 08:20:10 +0000 |
---|---|---|
committer | danno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-29 08:20:10 +0000 |
commit | 04243eb48f35872996560660f8f31c298269fa0c (patch) | |
tree | c089ba4461e8fe6156dbd373c8ce41d011793640 /chrome/browser | |
parent | 53b154ca224b8c72ad5af70141732abf1eaba143 (diff) | |
download | chromium_src-04243eb48f35872996560660f8f31c298269fa0c.zip chromium_src-04243eb48f35872996560660f8f31c298269fa0c.tar.gz chromium_src-04243eb48f35872996560660f8f31c298269fa0c.tar.bz2 |
[Mac] Implement cookie prompt for appcaches
xib changes:
- Add a new subview to the details view for displaying appcache information in the cookie prompt. It is in the style of the existing views.
- The new view has a single info line for the manifest url.
- The label of this line is ^IDS_COOKIES_APPLICATION_CACHE_MANIFEST_LABEL
- The value is bound to content.details.manifestURL
- "hidden" binding set to content.details.shouldShowAppCachePromptDetailsView with a NSBNegateBoolean transformer OR selection.@count with a NSNegateBoolean transformer.
- Adjusted the layout of all of the details subviews, labels and values slightly to improve spacing and make it consistent
Screenshot of prompt for appcache available here:
http://img156.imageshack.us/img156/5941/picture2hj.png
http://img404.imageshack.us/img404/3747/picture3bi.png
Screenshot of adjusted cookie prompt with settable expiration:
http://img337.imageshack.us/img337/2296/picture4g.png
BUG=39288
TEST=manual testing, new unit tests
Review URL: http://codereview.chromium.org/1296005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42937 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/cocoa/cookie_details.h | 14 | ||||
-rw-r--r-- | chrome/browser/cocoa/cookie_details.mm | 28 | ||||
-rw-r--r-- | chrome/browser/cocoa/cookie_details_unittest.mm | 23 | ||||
-rw-r--r-- | chrome/browser/cocoa/cookie_details_view_controller.mm | 12 |
4 files changed, 69 insertions, 8 deletions
diff --git a/chrome/browser/cocoa/cookie_details.h b/chrome/browser/cocoa/cookie_details.h index e6ff00a..dbd51b8 100644 --- a/chrome/browser/cocoa/cookie_details.h +++ b/chrome/browser/cocoa/cookie_details.h @@ -36,7 +36,11 @@ enum CocoaCookieDetailsType { // Detailed information about local storage used for display // in the cookie prompt dialog. - kCocoaCookieDetailsTypePromptLocalStorage = 5 + kCocoaCookieDetailsTypePromptLocalStorage = 5, + + // Detailed information about app caches used for display + // in the cookie prompt dialog. + kCocoaCookieDetailsTypePromptAppCache = 6 }; // This class contains all of the information that can be displayed in @@ -86,6 +90,9 @@ enum CocoaCookieDetailsType { // Used only for type kCocoaCookieDetailsTypePromptLocalStorage scoped_nsobject<NSString> localStorageKey_; scoped_nsobject<NSString> localStorageValue_; + + // Used only for type kCocoaCookieDetailsTypePromptAppCache + scoped_nsobject<NSString> manifestURL_; } @property (readonly) BOOL canEditExpiration; @@ -106,6 +113,7 @@ enum CocoaCookieDetailsType { - (BOOL)shouldShowDatabaseTreeDetailsView; - (BOOL)shouldShowDatabasePromptDetailsView; - (BOOL)shouldShowLocalStoragePromptDetailsView; +- (BOOL)shouldShowAppCachePromptDetailsView; - (NSString*)name; - (NSString*)content; @@ -119,6 +127,7 @@ enum CocoaCookieDetailsType { - (NSString*)databaseDescription; - (NSString*)localStorageKey; - (NSString*)localStorageValue; +- (NSString*)manifestURL; // Used for folders in the cookie tree. - (id)initAsFolder; @@ -145,6 +154,9 @@ enum CocoaCookieDetailsType { key:(const string16&)key value:(const string16&)value; +// Used for app cache details in the cookie prompt dialog. +- (id)initWithAppCache:(const std::string&)manifestURL; + // A factory method to create a configured instance given a node from // the cookie tree in |treeNode|. + (CocoaCookieDetails*)createFromCookieTreeNode:(CookieTreeNode*)treeNode; diff --git a/chrome/browser/cocoa/cookie_details.mm b/chrome/browser/cocoa/cookie_details.mm index 49ff5d9..d62b5d0da 100644 --- a/chrome/browser/cocoa/cookie_details.mm +++ b/chrome/browser/cocoa/cookie_details.mm @@ -10,6 +10,7 @@ #include "grit/generated_resources.h" #include "chrome/browser/cookie_modal_dialog.h" #include "chrome/browser/cookies_tree_model.h" +#include "webkit/appcache/appcache_service.h" #pragma mark Cocoa Cookie Details @@ -40,6 +41,10 @@ return type_ == kCocoaCookieDetailsTypePromptLocalStorage; } +- (BOOL)shouldShowAppCachePromptDetailsView { + return type_ == kCocoaCookieDetailsTypePromptAppCache; +} + - (NSString*)name { return name_.get(); } @@ -88,6 +93,10 @@ return localStorageValue_.get(); } +- (NSString*)manifestURL { + return manifestURL_.get(); +} + - (id)initAsFolder { if ((self = [super init])) { type_ = kCocoaCookieDetailsTypeFolder; @@ -184,6 +193,15 @@ return self; } +- (id)initWithAppCache:(const std::string&)manifestURL { + if ((self = [super init])) { + type_ = kCocoaCookieDetailsTypePromptAppCache; + canEditExpiration_ = NO; + manifestURL_.reset([base::SysUTF8ToNSString(manifestURL) retain]); + } + return self; +} + + (CocoaCookieDetails*)createFromCookieTreeNode:(CookieTreeNode*)treeNode { CookieTreeNode::DetailedInfo info = treeNode->GetDetailedInfo(); CookieTreeNode::DetailedInfo::NodeType nodeType = info.node_type; @@ -198,6 +216,11 @@ } else if (nodeType == CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE) { return [[[CocoaCookieDetails alloc] initWithLocalStorage:info.local_storage_info] autorelease]; + } else if (nodeType == CookieTreeNode::DetailedInfo::TYPE_APPCACHE) { + // TODO(danno): For now just use the same view as the modal prompt in + // the cookie tree. http://crbug.com/37459 is for the missing functionality. + return [[[CocoaCookieDetails alloc] + initWithAppCache:info.appcache_info->manifest_url.spec()] autorelease]; } else { return [[[CocoaCookieDetails alloc] initAsFolder] autorelease]; } @@ -226,11 +249,8 @@ initWithDatabase:dialog->origin().host() name:dialog->database_name()]; } else if (type == CookiePromptModalDialog::DIALOG_TYPE_APPCACHE) { - // TODO(michaeln): Show an appropiate details view, for now we - // overload the database details view. details = [[CocoaCookieDetails alloc] - initWithDatabase:dialog->origin().host() - name:UTF8ToUTF16(dialog->appcache_manifest_url().spec())]; + initWithAppCache:dialog->appcache_manifest_url().spec()]; } else { NOTIMPLEMENTED(); } diff --git a/chrome/browser/cocoa/cookie_details_unittest.mm b/chrome/browser/cocoa/cookie_details_unittest.mm index 55cbe00..b5b82bf 100644 --- a/chrome/browser/cocoa/cookie_details_unittest.mm +++ b/chrome/browser/cocoa/cookie_details_unittest.mm @@ -46,6 +46,7 @@ TEST_F(CookiesDetailsTest, CreateForCookie) { EXPECT_FALSE([details.get() shouldShowDatabaseTreeDetailsView]); EXPECT_FALSE([details.get() shouldShowLocalStoragePromptDetailsView]); EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); + EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); } TEST_F(CookiesDetailsTest, CreateForTreeDatabase) { @@ -71,6 +72,7 @@ TEST_F(CookiesDetailsTest, CreateForTreeDatabase) { EXPECT_TRUE([details.get() shouldShowDatabaseTreeDetailsView]); EXPECT_FALSE([details.get() shouldShowLocalStoragePromptDetailsView]); EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); + EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); } TEST_F(CookiesDetailsTest, CreateForTreeLocalStorage) { @@ -97,6 +99,7 @@ TEST_F(CookiesDetailsTest, CreateForTreeLocalStorage) { EXPECT_FALSE([details.get() shouldShowDatabaseTreeDetailsView]); EXPECT_FALSE([details.get() shouldShowLocalStoragePromptDetailsView]); EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); + EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); } TEST_F(CookiesDetailsTest, CreateForPromptDatabase) { @@ -115,6 +118,7 @@ TEST_F(CookiesDetailsTest, CreateForPromptDatabase) { EXPECT_FALSE([details.get() shouldShowDatabaseTreeDetailsView]); EXPECT_FALSE([details.get() shouldShowLocalStoragePromptDetailsView]); EXPECT_TRUE([details.get() shouldShowDatabasePromptDetailsView]); + EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); } TEST_F(CookiesDetailsTest, CreateForPromptLocalStorage) { @@ -136,6 +140,25 @@ TEST_F(CookiesDetailsTest, CreateForPromptLocalStorage) { EXPECT_FALSE([details.get() shouldShowDatabaseTreeDetailsView]); EXPECT_TRUE([details.get() shouldShowLocalStoragePromptDetailsView]); EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); + EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); +} + +TEST_F(CookiesDetailsTest, CreateForPromptAppCache) { + scoped_nsobject<CocoaCookieDetails> details; + std::string manifestURL("http://html5demos.com/html5demo.manifest"); + details.reset([[CocoaCookieDetails alloc] + initWithAppCache:manifestURL.c_str()]); + + EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypePromptAppCache); + EXPECT_TRUE([@"http://html5demos.com/html5demo.manifest" + isEqualToString:[details.get() manifestURL]]); + + EXPECT_TRUE([details.get() shouldHideCookieDetailsView]); + EXPECT_FALSE([details.get() shouldShowLocalStorageTreeDetailsView]); + EXPECT_FALSE([details.get() shouldShowDatabaseTreeDetailsView]); + EXPECT_FALSE([details.get() shouldShowLocalStoragePromptDetailsView]); + EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); + EXPECT_TRUE([details.get() shouldShowAppCachePromptDetailsView]); } } diff --git a/chrome/browser/cocoa/cookie_details_view_controller.mm b/chrome/browser/cocoa/cookie_details_view_controller.mm index 1c97d19..01341d5 100644 --- a/chrome/browser/cocoa/cookie_details_view_controller.mm +++ b/chrome/browser/cocoa/cookie_details_view_controller.mm @@ -13,7 +13,7 @@ #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" namespace { -static const int kMinimalLabelOffsetFromViewBottom = 20; +static const int kExtraMarginBelowWhenExpirationEditable = 5; } #pragma mark View Controller @@ -72,8 +72,14 @@ static const int kMinimalLabelOffsetFromViewBottom = 20; float lowestLabelPosition = frame.origin.y + frame.size.height; [self getLowestLabelVerticalPosition:view lowestLabelPosition:lowestLabelPosition]; - float verticalDelta = lowestLabelPosition - frame.origin.y - - kMinimalLabelOffsetFromViewBottom; + float verticalDelta = lowestLabelPosition - frame.origin.y; + + // Popup menu for the expiration is taller than the plain + // text, give it some more room. + if ([[[objectController_ content] details] canEditExpiration]) { + verticalDelta -= kExtraMarginBelowWhenExpirationEditable; + } + frame.origin.y += verticalDelta; frame.size.height -= verticalDelta; [[self view] setFrame:frame]; |