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

Side by Side Diff: chrome/browser/cocoa/clear_browsing_data_controller.mm

Issue 151095: Added unit tests for ClearBrowsingDataController.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/cocoa/clear_browsing_data_controller.h" 5 #import "chrome/browser/cocoa/clear_browsing_data_controller.h"
6 6
7 #include "base/mac_util.h" 7 #include "base/mac_util.h"
8 #include "base/scoped_nsobject.h" 8 #include "base/scoped_nsobject.h"
9 #include "chrome/browser/browsing_data_remover.h" 9 #include "chrome/browser/browsing_data_remover.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 scoped_nsobject<NSImage> throbberImage( 71 scoped_nsobject<NSImage> throbberImage(
72 [[NSImage alloc] initWithContentsOfFile:imagePath]); 72 [[NSImage alloc] initWithContentsOfFile:imagePath]);
73 [progress_ setImage:throbberImage]; 73 [progress_ setImage:throbberImage];
74 } 74 }
75 75
76 // Run application modal. 76 // Run application modal.
77 - (void)runModalDialog { 77 - (void)runModalDialog {
78 [[NSApplication sharedApplication] runModalForWindow:[self window]]; 78 [[NSApplication sharedApplication] runModalForWindow:[self window]];
79 } 79 }
80 80
81 // Called when the user clicks the "clear" button. Do the work and persist 81 - (int)removeMask {
82 // the prefs for next time. We don't stop the modal session until we get
83 // the callback from the BrowsingDataRemover so the window stays on the screen.
84 // While we're working, dim the buttons so the user can't click them.
85 - (IBAction)clearData:(id)sender {
86 // Set that we're working so that the buttons disable.
87 [self setIsClearing:YES];
88
89 [self persistToPrefs];
90
91 int removeMask = 0L; 82 int removeMask = 0L;
92 if (clearBrowsingHistory_) 83 if (clearBrowsingHistory_)
93 removeMask |= BrowsingDataRemover::REMOVE_HISTORY; 84 removeMask |= BrowsingDataRemover::REMOVE_HISTORY;
94 if (clearDownloadHistory_) 85 if (clearDownloadHistory_)
95 removeMask |= BrowsingDataRemover::REMOVE_DOWNLOADS; 86 removeMask |= BrowsingDataRemover::REMOVE_DOWNLOADS;
96 if (emptyCache_) 87 if (emptyCache_)
97 removeMask |= BrowsingDataRemover::REMOVE_CACHE; 88 removeMask |= BrowsingDataRemover::REMOVE_CACHE;
98 if (deleteCookies_) 89 if (deleteCookies_)
99 removeMask |= BrowsingDataRemover::REMOVE_COOKIES; 90 removeMask |= BrowsingDataRemover::REMOVE_COOKIES;
100 if (clearSavedPasswords_) 91 if (clearSavedPasswords_)
101 removeMask |= BrowsingDataRemover::REMOVE_PASSWORDS; 92 removeMask |= BrowsingDataRemover::REMOVE_PASSWORDS;
102 if (clearFormData_) 93 if (clearFormData_)
103 removeMask |= BrowsingDataRemover::REMOVE_PASSWORDS; 94 removeMask |= BrowsingDataRemover::REMOVE_FORM_DATA;
95 return removeMask;
96 }
97
98 // Called when the user clicks the "clear" button. Do the work and persist
99 // the prefs for next time. We don't stop the modal session until we get
100 // the callback from the BrowsingDataRemover so the window stays on the screen.
101 // While we're working, dim the buttons so the user can't click them.
102 - (IBAction)clearData:(id)sender {
103 // Set that we're working so that the buttons disable.
104 [self setIsClearing:YES];
105
106 [self persistToPrefs];
104 107
105 // BrowsingDataRemover deletes itself when done. 108 // BrowsingDataRemover deletes itself when done.
106 remover_ = new BrowsingDataRemover(profile_, 109 remover_ = new BrowsingDataRemover(profile_,
107 static_cast<BrowsingDataRemover::TimePeriod>(timePeriod_), 110 static_cast<BrowsingDataRemover::TimePeriod>(timePeriod_),
108 base::Time()); 111 base::Time());
109 remover_->AddObserver(observer_.get()); 112 remover_->AddObserver(observer_.get());
110 remover_->Remove(removeMask); 113 remover_->Remove([self removeMask]);
111 } 114 }
112 115
113 // Called when the user clicks the cancel button. All we need to do is stop 116 // Called when the user clicks the cancel button. All we need to do is stop
114 // the modal session. 117 // the modal session.
115 - (IBAction)cancel:(id)sender { 118 - (IBAction)cancel:(id)sender {
116 [[NSApplication sharedApplication] stopModal]; 119 [[NSApplication sharedApplication] stopModal];
117 [[self window] orderOut:self]; 120 [[self window] orderOut:self];
118 } 121 }
119 122
120 // Initialize the bools from prefs using the setters to be KVO-compliant. 123 // Initialize the bools from prefs using the setters to be KVO-compliant.
(...skipping 27 matching lines...) Expand all
148 // Called when the data remover object is done with its work. Close the window. 151 // Called when the data remover object is done with its work. Close the window.
149 // The remover will delete itself. End the modal session at this point. 152 // The remover will delete itself. End the modal session at this point.
150 - (void)dataRemoverDidFinish { 153 - (void)dataRemoverDidFinish {
151 [[NSApplication sharedApplication] stopModal]; 154 [[NSApplication sharedApplication] stopModal];
152 [[self window] orderOut:self]; 155 [[self window] orderOut:self];
153 [self setIsClearing:NO]; 156 [self setIsClearing:NO];
154 remover_ = NULL; 157 remover_ = NULL;
155 } 158 }
156 159
157 @end 160 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698