diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 20:55:15 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 20:55:15 +0000 |
commit | 91c7fcaec1bec76a05d938e4e436d1efaa7eee8c (patch) | |
tree | e1173aa6da34adda9034cae6d13bc5dba8c6a6c5 | |
parent | ca25209a0338e538e0199b07bbd5c2411f52e906 (diff) | |
download | chromium_src-91c7fcaec1bec76a05d938e4e436d1efaa7eee8c.zip chromium_src-91c7fcaec1bec76a05d938e4e436d1efaa7eee8c.tar.gz chromium_src-91c7fcaec1bec76a05d938e4e436d1efaa7eee8c.tar.bz2 |
Revert 39756 - Mac: Cookie confirmation dialog.
This is not the final UI (the "more info" disclosure triangle is missing), but it's pretty close and, more importantly, functional.
BUG=34894
TEST=Go to Preferences>under the hood>content settings>cookies and select "ask me every time". Then browser around and note that a message box pops up all the time. All the buttons on the message box should do what they claim.
Review URL: http://codereview.chromium.org/650206
TBR=thakis@chromium.org
Review URL: http://codereview.chromium.org/652150
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39766 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/app_modal_dialog_queue.cc | 4 | ||||
-rw-r--r-- | chrome/browser/cookie_modal_dialog.cc | 1 | ||||
-rw-r--r-- | chrome/browser/cookie_modal_dialog.h | 3 | ||||
-rw-r--r-- | chrome/browser/cookie_modal_dialog_mac.mm | 145 | ||||
-rw-r--r-- | chrome/browser/js_modal_dialog_mac.mm | 2 | ||||
-rw-r--r-- | chrome/browser/message_box_handler.cc | 9 | ||||
-rwxr-xr-x | chrome/chrome_browser.gypi | 2 |
7 files changed, 9 insertions, 157 deletions
diff --git a/chrome/browser/app_modal_dialog_queue.cc b/chrome/browser/app_modal_dialog_queue.cc index f10cab1..3d4f2da 100644 --- a/chrome/browser/app_modal_dialog_queue.cc +++ b/chrome/browser/app_modal_dialog_queue.cc @@ -28,10 +28,8 @@ void AppModalDialogQueue::ActivateModalDialog() { } void AppModalDialogQueue::ShowModalDialog(AppModalDialog* dialog) { - // Must happen before |ShowModalDialog()| is called, because - // |ShowModalDialog()| might end up calling |ShowNextDialog()|. - active_dialog_ = dialog; dialog->ShowModalDialog(); + active_dialog_ = dialog; } AppModalDialog* AppModalDialogQueue::GetNextDialog() { diff --git a/chrome/browser/cookie_modal_dialog.cc b/chrome/browser/cookie_modal_dialog.cc index e655d3a..a744fdf 100644 --- a/chrome/browser/cookie_modal_dialog.cc +++ b/chrome/browser/cookie_modal_dialog.cc @@ -8,6 +8,7 @@ #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/views/cookie_prompt_view.h" #include "chrome/common/pref_names.h" // Cookies diff --git a/chrome/browser/cookie_modal_dialog.h b/chrome/browser/cookie_modal_dialog.h index 11b35a1..04fedae 100644 --- a/chrome/browser/cookie_modal_dialog.h +++ b/chrome/browser/cookie_modal_dialog.h @@ -50,9 +50,6 @@ class CookiePromptModalDialog : public AppModalDialog { static void RegisterPrefs(PrefService* prefs); // AppModalDialog overrides. -#if defined(OS_LINUX) || defined(OS_MACOSX) - virtual void CreateAndShowDialog(); -#endif virtual int GetDialogButtons(); virtual void AcceptWindow(); virtual void CancelWindow(); diff --git a/chrome/browser/cookie_modal_dialog_mac.mm b/chrome/browser/cookie_modal_dialog_mac.mm deleted file mode 100644 index b41437c..0000000 --- a/chrome/browser/cookie_modal_dialog_mac.mm +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/cookie_modal_dialog.h" - -#import <Cocoa/Cocoa.h> - -#include "app/l10n_util_mac.h" -#import "base/cocoa_protocols_mac.h" -#include "base/scoped_nsobject.h" -#include "base/logging.h" -#include "chrome/browser/tab_contents/tab_contents.h" -#include "grit/generated_resources.h" - -// Helper object that will become a real NSWindowController in the future. -@interface CookiePromptModalDialogHelper : NSObject<NSAlertDelegate> { - @private - scoped_nsobject<NSAlert> alert_; - scoped_nsobject<NSMatrix> matrix_; -} - -- (id)initWithBridge:(CookiePromptModalDialog*)bridge; -- (NSAlert*)alert; -- (void)alertDidEnd:(NSAlert*)alert - returnCode:(int)returnCode - contextInfo:(void*)contextInfo; -@end - -@implementation CookiePromptModalDialogHelper - -- (id)initWithBridge:(CookiePromptModalDialog*)bridge { - // The cookie confirmation dialog needs both a radio group and a disclosure - // triangle, so it's too complex to be shown as an NSAlert -- a custom window - // is required. However, that requires small modifications to the parent class - // AppModalDialog, so I'll do that in another CL. - if ((self = [super init])) { - alert_.reset([[NSAlert alloc] init]); - - string16 displayHost = UTF8ToUTF16(bridge->origin().host()); - int descriptionStringId = - bridge->dialog_type() == CookiePromptModalDialog::DIALOG_TYPE_COOKIE ? - IDS_COOKIE_ALERT_LABEL : IDS_DATA_ALERT_LABEL; - NSString* description = - l10n_util::GetNSStringF(descriptionStringId, displayHost); - NSString* allow = - l10n_util::GetNSStringWithFixup(IDS_COOKIE_ALERT_ALLOW_BUTTON); - NSString* block = - l10n_util::GetNSStringWithFixup(IDS_COOKIE_ALERT_BLOCK_BUTTON); - - NSString* remember = - l10n_util::GetNSStringF(IDS_COOKIE_ALERT_REMEMBER_RADIO, displayHost); - NSString* ask = l10n_util::GetNSStringWithFixup(IDS_COOKIE_ALERT_ASK_RADIO); - - scoped_nsobject<NSButtonCell> prototype([[NSButtonCell alloc] init]); - [prototype.get() setButtonType:NSRadioButton]; - matrix_.reset( - [[NSMatrix alloc] initWithFrame:NSZeroRect - mode:NSRadioModeMatrix - prototype:prototype - numberOfRows:2 - numberOfColumns:1]); - NSArray *cellArray = [matrix_.get() cells]; - [[cellArray objectAtIndex:0] setTitle:remember]; - [[cellArray objectAtIndex:1] setTitle:ask]; - [matrix_.get() sizeToFit]; - [alert_.get() setAccessoryView:matrix_.get()]; - - [alert_.get() setMessageText:description]; - [alert_.get() addButtonWithTitle:allow]; - [alert_.get() addButtonWithTitle:block]; - } - return self; -} - -- (NSAlert*)alert { - return alert_.get(); -} - -// |contextInfo| is the bridge back to the C++ CookiePromptModalDialog. -- (void)alertDidEnd:(NSAlert*)alert - returnCode:(int)returnCode - contextInfo:(void*)contextInfo { - CookiePromptModalDialog* bridge = - reinterpret_cast<CookiePromptModalDialog*>(contextInfo); - bool remember = [matrix_.get() selectedRow] == 0; - switch (returnCode) { - case NSAlertFirstButtonReturn: { // OK - bool sessionExpire = false; - bridge->AllowSiteData(remember, sessionExpire); - break; - } - case NSAlertSecondButtonReturn: { // Cancel - bridge->BlockSiteData(remember); - break; - } - case NSRunStoppedResponse: { // Window was closed underneath us - remember = false; - bridge->BlockSiteData(remember); - break; - } - default: { - NOTREACHED(); - remember = false; - bridge->BlockSiteData(remember); - } - } -} -@end - -void CookiePromptModalDialog::CreateAndShowDialog() { - scoped_nsobject<CookiePromptModalDialogHelper> helper( - [[CookiePromptModalDialogHelper alloc] initWithBridge:this]); - NSAlert* alert = [helper alert]; - DCHECK(alert); - - NSInteger result = [alert runModal]; - [helper.get() alertDidEnd:alert returnCode:result contextInfo:this]; - - // Other than JavaScriptAppModalDialog, the cross-platform part of this class - // does not call |CompleteDialog()|, an explicit call is required. - CompleteDialog(); - Cleanup(); - delete this; -} - -// The functions below are used by the (windows-only) automation framework. -int CookiePromptModalDialog::GetDialogButtons() { - NOTIMPLEMENTED(); - return 0; -} - -void CookiePromptModalDialog::AcceptWindow() { - NOTIMPLEMENTED(); -} - -void CookiePromptModalDialog::CancelWindow() { - NOTIMPLEMENTED(); -} - -// This is only used by the app-modal dialog machinery on windows. -NativeDialog CookiePromptModalDialog::CreateNativeDialog() { - NOTIMPLEMENTED(); - return nil; -} diff --git a/chrome/browser/js_modal_dialog_mac.mm b/chrome/browser/js_modal_dialog_mac.mm index dad34ae..8519433 100644 --- a/chrome/browser/js_modal_dialog_mac.mm +++ b/chrome/browser/js_modal_dialog_mac.mm @@ -151,7 +151,6 @@ void JavaScriptAppModalDialog::CreateAndShowDialog() { [[alert window] makeFirstResponder:field]; } -// The functions below are used by the (windows-only) automation framework. int JavaScriptAppModalDialog::GetDialogButtons() { NOTIMPLEMENTED(); return 0; @@ -165,7 +164,6 @@ void JavaScriptAppModalDialog::CancelWindow() { NOTIMPLEMENTED(); } -// This is only used by the app-modal dialog machinery on windows. NativeDialog JavaScriptAppModalDialog::CreateNativeDialog() { NOTIMPLEMENTED(); return nil; diff --git a/chrome/browser/message_box_handler.cc b/chrome/browser/message_box_handler.cc index a92bbf7..3c249d2 100644 --- a/chrome/browser/message_box_handler.cc +++ b/chrome/browser/message_box_handler.cc @@ -63,12 +63,13 @@ void RunCookiePrompt(TabContents* tab_contents, const GURL& origin, const std::string& cookie_line, CookiePromptModalDialogDelegate* delegate) { -#if defined(OS_WIN) || defined(OS_MACOSX) +#if defined(OS_WIN) Singleton<AppModalDialogQueue>()->AddDialog( new CookiePromptModalDialog(tab_contents, host_content_settings_map, origin, cookie_line, delegate)); #else // Linux: http://crbug.com/35178 + // Mac: http://crbug.com/34894 NOTIMPLEMENTED(); delegate->BlockSiteData(); #endif @@ -81,12 +82,13 @@ void RunLocalStoragePrompt( const string16& key, const string16& value, CookiePromptModalDialogDelegate* delegate) { -#if defined(OS_WIN) || defined(OS_MACOSX) +#if defined(OS_WIN) Singleton<AppModalDialogQueue>()->AddDialog( new CookiePromptModalDialog(tab_contents, host_content_settings_map, origin, key, value, delegate)); #else // Linux: http://crbug.com/35178 + // Mac: http://crbug.com/34894 NOTIMPLEMENTED(); delegate->BlockSiteData(); #endif @@ -98,12 +100,13 @@ void RunDatabasePrompt( const GURL& origin, const string16& database_name, CookiePromptModalDialogDelegate* delegate) { -#if defined(OS_WIN) || defined(OS_MACOSX) +#if defined(OS_WIN) Singleton<AppModalDialogQueue>()->AddDialog( new CookiePromptModalDialog(tab_contents, host_content_settings_map, origin, database_name, delegate)); #else // Linux: http://crbug.com/35178 + // Mac: http://crbug.com/34894 NOTIMPLEMENTED(); delegate->BlockSiteData(); #endif diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 5dfa345..2a19c89 100755 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -713,7 +713,6 @@ 'browser/content_exceptions_table_model.h', 'browser/cookie_modal_dialog.cc', 'browser/cookie_modal_dialog.h', - 'browser/cookie_modal_dialog_mac.mm', 'browser/cookie_modal_dialog_views.cc', 'browser/cookie_prompt_modal_dialog_delegate.h', 'browser/cookies_tree_model.cc', @@ -2261,6 +2260,7 @@ 'browser/automation/automation_provider_list_generic.cc', 'browser/bookmarks/bookmark_context_menu.cc', 'browser/bookmarks/bookmark_drop_info.cc', + 'browser/cookie_modal_dialog.cc', 'browser/dock_info.cc', 'browser/jankometer.cc', 'browser/password_manager/password_store_gnome.h', |