diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-09 15:29:17 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-09 15:29:17 +0000 |
commit | bd14784bcadf8cf55ae92e713a2545245bb02826 (patch) | |
tree | 7cf74d7dfa33e0dd46f4c0b0e32d788f53143e29 /chrome/browser/cocoa | |
parent | 94d2c4067766e532bfd7b61a9b7f0a0616325642 (diff) | |
download | chromium_src-bd14784bcadf8cf55ae92e713a2545245bb02826.zip chromium_src-bd14784bcadf8cf55ae92e713a2545245bb02826.tar.gz chromium_src-bd14784bcadf8cf55ae92e713a2545245bb02826.tar.bz2 |
Disable remember option in cookie prompt and content blocked notification bubbles when running OTR.
BUG=37525
TEST=Manual, check cookie prompt and bubbles in OTR session
Review URL: http://codereview.chromium.org/1629011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
4 files changed, 36 insertions, 12 deletions
diff --git a/chrome/browser/cocoa/content_blocked_bubble_controller.mm b/chrome/browser/cocoa/content_blocked_bubble_controller.mm index fd4d979..8b88c0c 100644 --- a/chrome/browser/cocoa/content_blocked_bubble_controller.mm +++ b/chrome/browser/cocoa/content_blocked_bubble_controller.mm @@ -178,9 +178,10 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) { const ContentSettingBubbleModel::RadioGroup& radioGroup = contentSettingBubbleModel_->bubble_content().radio_group; - // Select appropriate radio button.. + // Initialize radio group state. [allowBlockRadioGroup_ selectCellWithTag: radioGroup.default_item == 0 ? kAllowTag : kBlockTag]; + [allowBlockRadioGroup_ setEnabled:radioGroup.is_mutable]; // Copy |host_| into radio group label. NSCell* radioCell = [allowBlockRadioGroup_ cellWithTag:kAllowTag]; diff --git a/chrome/browser/cocoa/cookie_prompt_window_controller.h b/chrome/browser/cocoa/cookie_prompt_window_controller.h index 6ae68b4..3f440db 100644 --- a/chrome/browser/cocoa/cookie_prompt_window_controller.h +++ b/chrome/browser/cocoa/cookie_prompt_window_controller.h @@ -39,6 +39,7 @@ class CookieTreeNode; IBOutlet NSView* disclosureButtonSuperView_; IBOutlet NSMatrix* radioGroupMatrix_; IBOutlet NSButtonCell* rememberChoiceCell_; + IBOutlet NSButtonCell* askChoiceCell_; } // Designated initializer. diff --git a/chrome/browser/cocoa/cookie_prompt_window_controller.mm b/chrome/browser/cocoa/cookie_prompt_window_controller.mm index 779d506..f3dbcc0 100644 --- a/chrome/browser/cocoa/cookie_prompt_window_controller.mm +++ b/chrome/browser/cocoa/cookie_prompt_window_controller.mm @@ -138,6 +138,10 @@ static const CGFloat kExtraMarginForDetailsView = 10; [self doLayoutTweaks]; [self replaceCookieDetailsView]; + bool rememberEnabled = dialog_->DecisionPersistable(); + [radioGroupMatrix_ setEnabled:rememberEnabled]; + [radioGroupMatrix_ selectCell:( + rememberEnabled ? rememberChoiceCell_ : askChoiceCell_)]; [[detailsViewController_ view] setHidden:YES]; } diff --git a/chrome/browser/cocoa/cookie_prompt_window_controller_unittest.mm b/chrome/browser/cocoa/cookie_prompt_window_controller_unittest.mm index ea20982..123b96d 100644 --- a/chrome/browser/cocoa/cookie_prompt_window_controller_unittest.mm +++ b/chrome/browser/cocoa/cookie_prompt_window_controller_unittest.mm @@ -6,6 +6,7 @@ #include "chrome/browser/cocoa/cocoa_test_helper.h" #include "chrome/browser/cocoa/cookie_prompt_window_controller.h" #include "chrome/browser/cookie_modal_dialog.h" +#include "chrome/test/testing_profile.h" // A mock class which implements just enough functionality to // act as a radio with a pre-specified selected button. @@ -40,7 +41,8 @@ namespace { class CookiePromptModalDialogMock : public CookiePromptModalDialog { public: CookiePromptModalDialogMock(const GURL& origin, - const std::string& cookie_line); + const std::string& cookieLine, + HostContentSettingsMap* hostContentSettingsMap); virtual void AllowSiteData(bool remember, bool session_expire); virtual void BlockSiteData(bool remember); @@ -59,8 +61,10 @@ class CookiePromptModalDialogMock : public CookiePromptModalDialog { CookiePromptModalDialogMock::CookiePromptModalDialogMock( const GURL& origin, - const std::string& cookie_line) - : CookiePromptModalDialog(NULL, NULL, origin, cookie_line, NULL), + const std::string& cookieLine, + HostContentSettingsMap* hostContentSettingsMap) + : CookiePromptModalDialog(NULL, hostContentSettingsMap, origin, cookieLine, + NULL), allow_(false), remember_(false) { } @@ -77,6 +81,13 @@ void CookiePromptModalDialogMock::BlockSiteData(bool remember) { } class CookiePromptWindowControllerTest : public CocoaTest { + public: + CookiePromptWindowControllerTest() { + hostContentSettingsMap_ = profile_.GetHostContentSettingsMap(); + } + + TestingProfile profile_; + scoped_refptr<HostContentSettingsMap> hostContentSettingsMap_; }; TEST_F(CookiePromptWindowControllerTest, CreateForCookie) { @@ -84,7 +95,8 @@ TEST_F(CookiePromptWindowControllerTest, CreateForCookie) { std::string cookieLine( "PHPSESSID=0123456789abcdef0123456789abcdef; path=/"); scoped_ptr<CookiePromptModalDialog> dialog( - new CookiePromptModalDialog(NULL, NULL, url, cookieLine, NULL)); + new CookiePromptModalDialog(NULL, hostContentSettingsMap_, url, + cookieLine, NULL)); scoped_nsobject<CookiePromptWindowController> controller( [[CookiePromptWindowController alloc] initWithDialog:dialog.get()]); EXPECT_TRUE(controller.get()); @@ -96,8 +108,9 @@ TEST_F(CookiePromptWindowControllerTest, CreateForDatabase) { string16 databaseName(base::SysNSStringToUTF16(@"some database")); string16 databaseDescription(base::SysNSStringToUTF16(@"some desc")); scoped_ptr<CookiePromptModalDialog> dialog( - new CookiePromptModalDialog(NULL, NULL, url, databaseName, - databaseDescription, 3456, NULL)); + new CookiePromptModalDialog(NULL, hostContentSettingsMap_, + url, databaseName, databaseDescription, 3456, + NULL)); scoped_nsobject<CookiePromptWindowController> controller( [[CookiePromptWindowController alloc] initWithDialog:dialog.get()]); EXPECT_TRUE(controller.get()); @@ -109,7 +122,8 @@ TEST_F(CookiePromptWindowControllerTest, CreateForLocalStorage) { string16 key(base::SysNSStringToUTF16(@"key")); string16 value(base::SysNSStringToUTF16(@"value")); scoped_ptr<CookiePromptModalDialog> dialog( - new CookiePromptModalDialog(NULL, NULL, url, key, value, NULL)); + new CookiePromptModalDialog(NULL, hostContentSettingsMap_, url, key, + value, NULL)); scoped_nsobject<CookiePromptWindowController> controller( [[CookiePromptWindowController alloc] initWithDialog:dialog.get()]); EXPECT_TRUE(controller.get()); @@ -121,7 +135,8 @@ TEST_F(CookiePromptWindowControllerTest, RememberMyChoiceAllow) { std::string cookieLine( "PHPSESSID=0123456789abcdef0123456789abcdef; path=/"); scoped_ptr<CookiePromptModalDialogMock> dialog( - new CookiePromptModalDialogMock(url, cookieLine)); + new CookiePromptModalDialogMock(url, cookieLine, + hostContentSettingsMap_)); scoped_nsobject<CookiePromptWindowController> controller( [[CookiePromptWindowController alloc] initWithDialog:dialog.get()]); scoped_nsobject<MockRadioButtonMatrix> checkbox([[MockRadioButtonMatrix alloc] @@ -146,7 +161,8 @@ TEST_F(CookiePromptWindowControllerTest, RememberMyChoiceBlock) { std::string cookieLine( "PHPSESSID=0123456789abcdef0123456789abcdef; path=/"); scoped_ptr<CookiePromptModalDialogMock> dialog( - new CookiePromptModalDialogMock(url, cookieLine)); + new CookiePromptModalDialogMock(url, cookieLine, + hostContentSettingsMap_)); scoped_nsobject<CookiePromptWindowController> controller( [[CookiePromptWindowController alloc] initWithDialog:dialog.get()]); scoped_nsobject<MockRadioButtonMatrix> checkbox([[MockRadioButtonMatrix alloc] @@ -171,7 +187,8 @@ TEST_F(CookiePromptWindowControllerTest, DontRememberMyChoiceAllow) { std::string cookieLine( "PHPSESSID=0123456789abcdef0123456789abcdef; path=/"); scoped_ptr<CookiePromptModalDialogMock> dialog( - new CookiePromptModalDialogMock(url, cookieLine)); + new CookiePromptModalDialogMock(url, cookieLine, + hostContentSettingsMap_)); scoped_nsobject<CookiePromptWindowController> controller( [[CookiePromptWindowController alloc] initWithDialog:dialog.get()]); scoped_nsobject<MockRadioButtonMatrix> checkbox([[MockRadioButtonMatrix alloc] @@ -196,7 +213,8 @@ TEST_F(CookiePromptWindowControllerTest, DontRememberMyChoiceBlock) { std::string cookieLine( "PHPSESSID=0123456789abcdef0123456789abcdef; path=/"); scoped_ptr<CookiePromptModalDialogMock> dialog( - new CookiePromptModalDialogMock(url, cookieLine)); + new CookiePromptModalDialogMock(url, cookieLine, + hostContentSettingsMap_)); scoped_nsobject<CookiePromptWindowController> controller( [[CookiePromptWindowController alloc] initWithDialog:dialog.get()]); scoped_nsobject<MockRadioButtonMatrix> checkbox([[MockRadioButtonMatrix alloc] |