Implement Clear Browser Data for Mac as an app modal dialog. Uses the profile...

Implement Clear Browser Data for Mac as an app modal dialog. Uses the profile of the given window or the default profile if run with no windows open. Add a setter to the throbber so it can be used in a nib file.
BUG=none
TEST=clear browser functionality (note that clearing passwords doesn't work) and checkbox persistance.
Review URL: http://codereview.chromium.org/112065

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17186 0039d316-1c4b-4281-b951-d872f2087c98
parent 2946da15
......@@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="81"/>
<integer value="515"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
......@@ -103,6 +103,7 @@
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="353210768"/>
<reference key="NSMixedImage" ref="549394948"/>
<int key="NSTag">40013</int>
</object>
<object class="NSMenuItem" id="481834944">
<reference key="NSMenu" ref="110575045"/>
......@@ -905,25 +906,6 @@
<reference key="NSOnImage" ref="353210768"/>
<reference key="NSMixedImage" ref="549394948"/>
</object>
<object class="NSMenuItem" id="761864546">
<reference key="NSMenu" ref="436720301"/>
<bool key="NSIsDisabled">YES</bool>
<bool key="NSIsSeparator">YES</bool>
<string key="NSTitle"/>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="353210768"/>
<reference key="NSMixedImage" ref="549394948"/>
</object>
<object class="NSMenuItem" id="854840957">
<reference key="NSMenu" ref="436720301"/>
<string key="NSTitle">Clear Browsing Data</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="353210768"/>
<reference key="NSMixedImage" ref="549394948"/>
<int key="NSTag">40013</int>
</object>
</object>
</object>
</object>
......@@ -1492,14 +1474,6 @@
</object>
<int key="connectionID">543</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">commandDispatch:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="854840957"/>
</object>
<int key="connectionID">548</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">commandDispatch:</string>
......@@ -1588,6 +1562,14 @@
</object>
<int key="connectionID">623</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">commandDispatch:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="52470633"/>
</object>
<int key="connectionID">624</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">orderFrontStandardAboutPanel:</string>
......@@ -1951,13 +1933,13 @@
<reference ref="632727374"/>
<reference ref="646227648"/>
<reference ref="609285721"/>
<reference ref="481834944"/>
<reference ref="304266470"/>
<reference ref="1046388886"/>
<reference ref="1056857174"/>
<reference ref="342932134"/>
<reference ref="52470633"/>
<reference ref="446911629"/>
<reference ref="481834944"/>
<reference ref="52470633"/>
</object>
<reference key="parent" ref="694149608"/>
</object>
......@@ -1991,11 +1973,6 @@
<reference key="object" ref="609285721"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">143</int>
<reference key="object" ref="481834944"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">236</int>
<reference key="object" ref="304266470"/>
......@@ -2267,11 +2244,6 @@
<reference key="object" ref="168151378"/>
<reference key="parent" ref="1049"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">491</int>
<reference key="object" ref="52470633"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">492</int>
<reference key="object" ref="446911629"/>
......@@ -2361,8 +2333,6 @@
<reference ref="792145602"/>
<reference ref="64100325"/>
<reference ref="517951834"/>
<reference ref="761864546"/>
<reference ref="854840957"/>
</object>
<reference key="parent" ref="445514911"/>
</object>
......@@ -2426,16 +2396,6 @@
<reference key="object" ref="517951834"/>
<reference key="parent" ref="436720301"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">546</int>
<reference key="object" ref="761864546"/>
<reference key="parent" ref="436720301"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">547</int>
<reference key="object" ref="854840957"/>
<reference key="parent" ref="436720301"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">550</int>
<reference key="object" ref="238061183"/>
......@@ -2446,6 +2406,16 @@
<reference key="object" ref="710833675"/>
<reference key="parent" ref="835318025"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">143</int>
<reference key="object" ref="481834944"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">491</int>
<reference key="object" ref="52470633"/>
<reference key="parent" ref="110575045"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
......@@ -2641,8 +2611,6 @@
<string>541.IBPluginDependency</string>
<string>544.IBPluginDependency</string>
<string>545.IBPluginDependency</string>
<string>546.IBPluginDependency</string>
<string>547.IBPluginDependency</string>
<string>550.IBPluginDependency</string>
<string>551.IBPluginDependency</string>
<string>56.IBPluginDependency</string>
......@@ -2745,7 +2713,7 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{603, 458}, {243, 263}}</string>
<string>{{687, 801}, {243, 263}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{197, 734}, {243, 243}}</string>
......@@ -2855,9 +2823,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{697, 568}, {230, 153}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{781, 941}, {188, 123}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
......@@ -2875,7 +2841,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{467, 508}, {244, 213}}</string>
<string>{{551, 851}, {244, 213}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{23, 794}, {245, 183}}</string>
......@@ -2927,7 +2893,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">623</int>
<int key="maxID">624</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
......
......@@ -14,6 +14,7 @@
#include "chrome/browser/browser_shutdown.h"
#import "chrome/browser/cocoa/about_window_controller.h"
#import "chrome/browser/cocoa/bookmark_menu_bridge.h"
#import "chrome/browser/cocoa/clear_browsing_data_controller.h"
#import "chrome/browser/cocoa/encoding_menu_controller_delegate_mac.h"
#import "chrome/browser/cocoa/menu_localizer.h"
#import "chrome/browser/cocoa/preferences_window_controller.h"
......@@ -289,21 +290,28 @@
// command is supported and doesn't check, otherwise it would have been disabled
// in the UI in validateUserInterfaceItem:.
- (void)commandDispatch:(id)sender {
Profile* default_profile = [self defaultProfile];
Profile* defaultProfile = [self defaultProfile];
NSInteger tag = [sender tag];
switch (tag) {
case IDC_NEW_WINDOW:
Browser::OpenEmptyWindow(default_profile);
Browser::OpenEmptyWindow(defaultProfile);
break;
case IDC_NEW_INCOGNITO_WINDOW:
Browser::OpenURLOffTheRecord(default_profile, GURL());
Browser::OpenURLOffTheRecord(defaultProfile, GURL());
break;
case IDC_OPEN_FILE:
Browser::OpenEmptyWindow(default_profile);
Browser::OpenEmptyWindow(defaultProfile);
BrowserList::GetLastActive()->
ExecuteCommandWithDisposition(IDC_OPEN_FILE, CURRENT_TAB);
break;
case IDC_CLEAR_BROWSING_DATA:
// There may not be a browser open, so use the default profile.
scoped_nsobject<ClearBrowsingDataController> controller(
[[ClearBrowsingDataController alloc]
initWithProfile:defaultProfile]);
[controller runModalDialog];
break;
};
}
......@@ -330,6 +338,7 @@
menuState_->UpdateCommandEnabled(IDC_NEW_WINDOW, true);
menuState_->UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, true);
menuState_->UpdateCommandEnabled(IDC_OPEN_FILE, true);
menuState_->UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, true);
// TODO(pinkerton): ...more to come...
}
......
......@@ -1135,12 +1135,10 @@ void Browser::OpenPasswordManager() {
}
#endif
#if defined(OS_WIN) || defined(OS_LINUX)
void Browser::OpenImportSettingsDialog() {
UserMetrics::RecordAction(L"Import_ShowDlg", profile_);
window_->ShowImportDialog();
}
#endif
void Browser::OpenAboutChromeDialog() {
UserMetrics::RecordAction(L"AboutChrome", profile_);
......@@ -1359,10 +1357,8 @@ void Browser::ExecuteCommandWithDisposition(
case IDC_EDIT_SEARCH_ENGINES: OpenKeywordEditor(); break;
case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break;
#endif
#if defined(OS_WIN) || defined(OS_LINUX)
case IDC_CLEAR_BROWSING_DATA: OpenClearBrowsingDataDialog(); break;
case IDC_IMPORT_SETTINGS: OpenImportSettingsDialog(); break;
#endif
case IDC_ABOUT: OpenAboutChromeDialog(); break;
case IDC_HELP_PAGE: OpenHelpTab(); break;
......
......@@ -376,9 +376,7 @@ class Browser : public TabStripModelDelegate,
void OpenKeywordEditor();
void OpenPasswordManager();
#endif
#if defined(OS_WIN) || defined(OS_LINUX)
void OpenImportSettingsDialog();
#endif
void OpenAboutChromeDialog();
void OpenHelpTab();
......
......@@ -7,7 +7,8 @@
#include "base/sys_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/cocoa/browser_window_cocoa.h"
#include "chrome/browser/cocoa/browser_window_controller.h"
#import "chrome/browser/cocoa/browser_window_controller.h"
#import "chrome/browser/cocoa/clear_browsing_data_controller.h"
#include "chrome/browser/browser.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
......@@ -186,7 +187,10 @@ void BrowserWindowCocoa::ShowReportBugDialog() {
}
void BrowserWindowCocoa::ShowClearBrowsingDataDialog() {
NOTIMPLEMENTED();
scoped_nsobject<ClearBrowsingDataController> controller(
[[ClearBrowsingDataController alloc]
initWithProfile:browser_->profile()]);
[controller runModalDialog];
}
void BrowserWindowCocoa::ShowImportDialog() {
......
// Copyright (c) 2009 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.
#ifndef CHROME_BROWSER_COCOA_CLEAR_BROWSING_DATA_CONTROLLER_
#define CHROME_BROWSER_COCOA_CLEAR_BROWSING_DATA_CONTROLLER_
#import <Cocoa/Cocoa.h>
#include "base/scoped_ptr.h"
class BrowsingDataRemover;
class ClearBrowsingObserver;
class Profile;
@class ThrobberView;
// A window controller for managing the "Clear Browsing Data" feature. Modally
// presents a dialog offering the user a set of choices of what browsing data
// to delete and does so if the user chooses.
@interface ClearBrowsingDataController : NSWindowController {
@private
Profile* profile_; // Weak, owned by browser.
// If non-null means there is a removal in progress. Member used mainly for
// automated tests. The remove deletes itself when it's done, so this is a
// weak reference.
BrowsingDataRemover* remover_;
scoped_ptr<ClearBrowsingObserver> observer_;
BOOL isClearing_; // YES while clearing data is ongoing.
IBOutlet ThrobberView* progress_;
// Values for checkboxes, kept in sync with bindings. These values get
// persisted into prefs if the user accepts the dialog.
BOOL clearBrowsingHistory_;
BOOL clearDownloadHistory_;
BOOL emptyCache_;
BOOL deleteCookies_;
BOOL clearSavedPasswords_;
BOOL clearFormData_;
NSInteger timePeriod_;
}
// Create the controller with the given profile (which must not be NULL).
- (id)initWithProfile:(Profile*)profile;
// Run the dialog with an application-modal event loop. If the user accepts,
// performs the deletion of the selected browsing data. The values of the
// checkboxes will be persisted into prefs for next time.
- (void)runModalDialog;
// IBActions for the dialog buttons
- (IBAction)clearData:(id)sender;
- (IBAction)cancel:(id)sender;
// Properties for bindings
@property BOOL clearBrowsingHistory;
@property BOOL clearDownloadHistory;
@property BOOL emptyCache;
@property BOOL deleteCookies;
@property BOOL clearSavedPasswords;
@property BOOL clearFormData;
@property NSInteger timePeriod;
@property BOOL isClearing;
@end
#endif // CHROME_BROWSER_COCOA_CLEAR_BROWSING_DATA_CONTROLLER_
// Copyright (c) 2009 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.
#import "chrome/browser/cocoa/clear_browsing_data_controller.h"
#include "base/mac_util.h"
#include "base/scoped_nsobject.h"
#include "chrome/browser/browsing_data_remover.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/browser/profile.h"
@interface ClearBrowsingDataController(Private)
- (void)initFromPrefs;
- (void)persistToPrefs;
- (void)dataRemoverDidFinish;
@end
class ClearBrowsingObserver : public BrowsingDataRemover::Observer {
public:
ClearBrowsingObserver(ClearBrowsingDataController* controller)
: controller_(controller) { }
void OnBrowsingDataRemoverDone() { [controller_ dataRemoverDidFinish]; }
private:
ClearBrowsingDataController* controller_;
};
@implementation ClearBrowsingDataController
@synthesize clearBrowsingHistory = clearBrowsingHistory_;
@synthesize clearDownloadHistory = clearDownloadHistory_;
@synthesize emptyCache = emptyCache_;
@synthesize deleteCookies = deleteCookies_;
@synthesize clearSavedPasswords = clearSavedPasswords_;
@synthesize clearFormData = clearFormData_;
@synthesize timePeriod = timePeriod_;
@synthesize isClearing = isClearing_;
- (id)initWithProfile:(Profile*)profile {
DCHECK(profile);
// Use initWithWindowNibPath:: instead of initWithWindowNibName: so we
// can override it in a unit test.
NSString *nibpath = [mac_util::MainAppBundle()
pathForResource:@"ClearBrowsingData"
ofType:@"nib"];
if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
profile_ = profile;
observer_.reset(new ClearBrowsingObserver(self));
[self initFromPrefs];
}
return self;
}
- (void)dealloc {
if (remover_) {
// We were destroyed while clearing history was in progress. This can only
// occur during automated tests (normally the user can't close the dialog
// while clearing is in progress as the dialog is modal and not closeable).
remover_->RemoveObserver(observer_.get());
}
[super dealloc];
}
// Called when outlets are available. Set the throbber icon.
- (void)awakeFromNib {
NSString *imagePath = [mac_util::MainAppBundle()
pathForResource:@"throbber"
ofType:@"png"];
scoped_nsobject<NSImage> throbberImage(
[[NSImage alloc] initWithContentsOfFile:imagePath]);
[progress_ setImage:throbberImage];
}
// Run application modal.
- (void)runModalDialog {
[[NSApplication sharedApplication] runModalForWindow:[self window]];
}
// Called when the user clicks the "clear" button. Do the work and persist
// the prefs for next time. We don't stop the modal session until we get
// the callback from the BrowsingDataRemover so the window stays on the screen.
// While we're working, dim the buttons so the user can't click them.
- (IBAction)clearData:(id)sender {
// Set that we're working so that the buttons disable.
[self setIsClearing:YES];
[self persistToPrefs];
int removeMask = 0L;
if (clearBrowsingHistory_)
removeMask |= BrowsingDataRemover::REMOVE_HISTORY;
if (clearDownloadHistory_)
removeMask |= BrowsingDataRemover::REMOVE_DOWNLOADS;
if (emptyCache_)
removeMask |= BrowsingDataRemover::REMOVE_CACHE;
if (deleteCookies_)
removeMask |= BrowsingDataRemover::REMOVE_COOKIES;
if (clearSavedPasswords_)
removeMask |= BrowsingDataRemover::REMOVE_PASSWORDS;
if (clearFormData_)
removeMask |= BrowsingDataRemover::REMOVE_PASSWORDS;
// BrowsingDataRemover deletes itself when done.
remover_ = new BrowsingDataRemover(profile_,
static_cast<BrowsingDataRemover::TimePeriod>(timePeriod_),
base::Time());
remover_->AddObserver(observer_.get());
remover_->Remove(removeMask);
}
// Called when the user clicks the cancel button. All we need to do is stop
// the modal session.
- (IBAction)cancel:(id)sender {
[[NSApplication sharedApplication] stopModal];
[[self window] orderOut:self];
}
// Initialize the bools from prefs using the setters to be KVO-compliant.
- (void)initFromPrefs {
PrefService* prefs = profile_->GetPrefs();
[self setClearBrowsingHistory:
prefs->GetBoolean(prefs::kDeleteBrowsingHistory)];
[self setClearDownloadHistory:
prefs->GetBoolean(prefs::kDeleteDownloadHistory)];
[self setEmptyCache:prefs->GetBoolean(prefs::kDeleteCache)];
[self setDeleteCookies:prefs->GetBoolean(prefs::kDeleteCookies)];
[self setClearSavedPasswords:prefs->GetBoolean(prefs::kDeletePasswords)];
[self setClearFormData:prefs->GetBoolean(prefs::kDeleteFormData)];
[self setTimePeriod:prefs->GetInteger(prefs::kDeleteTimePeriod)];
}
// Save the checkbox values to the preferences.
- (void)persistToPrefs {
PrefService* prefs = profile_->GetPrefs();
prefs->SetBoolean(prefs::kDeleteBrowsingHistory,
[self clearBrowsingHistory]);
prefs->SetBoolean(prefs::kDeleteDownloadHistory,
[self clearDownloadHistory]);
prefs->SetBoolean(prefs::kDeleteCache, [self emptyCache]);
prefs->SetBoolean(prefs::kDeleteCookies, [self deleteCookies]);
prefs->SetBoolean(prefs::kDeletePasswords, [self clearSavedPasswords]);
prefs->SetBoolean(prefs::kDeleteFormData, [self clearFormData]);
prefs->SetInteger(prefs::kDeleteTimePeriod, [self timePeriod]);
}
// Called when the data remover object is done with its work. Close the window.
// The remover will delete itself. End the modal session at this point.
- (void)dataRemoverDidFinish {
[[NSApplication sharedApplication] stopModal];
[[self window] orderOut:self];
[self setIsClearing:NO];
remover_ = NULL;
}
@end
......@@ -32,6 +32,10 @@
// the width. Takes ownership of |image|.
- (id)initWithFrame:(NSRect)frame image:(NSImage*)image;
// Allows changing the image once the view has been created, such as when the
// view is loaded from a nib. The same restrictions as above apply.
- (void)setImage:(NSImage*)image;
@end
#endif // CHROME_BROWSER_COCOA_THROBBER_VIEW_H_
......@@ -39,48 +39,7 @@ const float kAnimationIntervalSeconds = 0.03; // 30ms, same as windows
- (id)initWithFrame:(NSRect)frame image:(NSImage*)image {
if ((self = [super initWithFrame:frame])) {
// Ensure that the height divides evenly into the width. Cache the
// number of frames in the animation for later.
NSSize imageSize = [image size];
DCHECK(imageSize.height && imageSize.width);
if (!imageSize.height)
return nil;
DCHECK((int)imageSize.width % (int)imageSize.height == 0);
numFrames_ = (int)imageSize.width / (int)imageSize.height;
DCHECK(numFrames_);
// First check if we have a bitmap image rep and use it, otherwise fall
// back to creating one.
NSBitmapImageRep* rep = [[image representations] objectAtIndex:0];
if (![rep isKindOfClass:[NSBitmapImageRep class]]) {
[image lockFocus];
NSRect imageRect = NSMakeRect(0, 0, imageSize.width, imageSize.height);
rep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect:imageRect]
autorelease];
[image unlockFocus];
}
image_.reset([[CIImage alloc] initWithBitmapImageRep:rep]);
#if 0
// TODO(pinkerton): The invalidation of the view to trigger re-draw causes
// the entire title-bar to redraw (you can see it with QuartzDebug). For some
// reason, setting isOpaque on this view, or any of its parent views, doesn't
// help. As a result, enabling this timer causes new tab to take a very long
// time on a loaded machine, crushing our perf bot when it's under load. For
// now, I'm disabling the timer so we draw the first frame of the animation,
// but nothing more. There are a couple of ways we can fix this:
// 1) Try to figure out why the invalidate is invalidating the entire title bar
// 2) Find some way to draw only the pixels we want and nothing else, but I
// don't know how we'd do that.
// Start a timer for the animation frames.
target_.reset([[TimerTarget alloc] initWithThrobber:self]);
timer_ =
[NSTimer scheduledTimerWithTimeInterval:kAnimationIntervalSeconds
target:target_.get()
selector:@selector(animate:)
userInfo:nil
repeats:YES];
#endif
[self setImage:image];
}
return self;
}
......@@ -116,4 +75,60 @@ const float kAnimationIntervalSeconds = 0.03; // 30ms, same as windows
fraction:1.0];
}
// Stores the internal representation of the image from |image|. We use
// CoreImage for speed (though this doesn't seem to help perf issues). We
// validate that the image is of the appropriate ratio. If the image has more
// than one frame, restarts the timer.
- (void)setImage:(NSImage*)image {
// Reset the animation counter so there's no chance we are off the end.
animationFrame_ = 0;
[timer_ invalidate];
timer_ = nil;
// Ensure that the height divides evenly into the width. Cache the
// number of frames in the animation for later.
NSSize imageSize = [image size];
DCHECK(imageSize.height && imageSize.width);
if (!imageSize.height)
return;
DCHECK((int)imageSize.width % (int)imageSize.height == 0);
numFrames_ = (int)imageSize.width / (int)imageSize.height;
DCHECK(numFrames_);
// First check if we have a bitmap image rep and use it, otherwise fall
// back to creating one.
NSBitmapImageRep* rep = [[image representations] objectAtIndex:0];
if (![rep isKindOfClass:[NSBitmapImageRep class]]) {
[image lockFocus];
NSRect imageRect = NSMakeRect(0, 0, imageSize.width, imageSize.height);
rep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect:imageRect]
autorelease];
[image unlockFocus];
}
image_.reset([[CIImage alloc] initWithBitmapImageRep:rep]);
#if 0
// TODO(pinkerton): The invalidation of the view to trigger re-draw causes
// the entire title-bar to redraw (you can see it with QuartzDebug). For some
// reason, setting isOpaque on this view, or any of its parent views, doesn't
// help. As a result, enabling this timer causes new tab to take a very long
// time on a loaded machine, crushing our perf bot when it's under load. For
// now, I'm disabling the timer so we draw the first frame of the animation,
// but nothing more. There are a couple of ways we can fix this:
// 1) Try to figure out why the invalidate is invalidating the entire title bar
// 2) Find some way to draw only the pixels we want and nothing else, but I
// don't know how we'd do that.
if (numFrames_ > 1) {
// Start a timer for the animation frames.
target_.reset([[TimerTarget alloc] initWithThrobber:self]);
timer_ =
[NSTimer scheduledTimerWithTimeInterval:kAnimationIntervalSeconds
target:target_.get()
selector:@selector(animate:)
userInfo:nil
repeats:YES];
}
#endif
}
@end
......@@ -672,6 +672,8 @@
'browser/cocoa/browser_window_cocoa.mm',
'browser/cocoa/browser_window_controller.h',
'browser/cocoa/browser_window_controller.mm',
'browser/cocoa/clear_browsing_data_controller.h',
'browser/cocoa/clear_browsing_data_controller.mm',
'browser/cocoa/cocoa_test_helper.h',
'browser/cocoa/command_observer_bridge.h',
'browser/cocoa/command_observer_bridge.mm',
......@@ -2107,6 +2109,7 @@
# them.
'app/nibs/en.lproj/About.xib',
'app/nibs/en.lproj/BrowserWindow.xib',
'app/nibs/en.lproj/ClearBrowsingData.xib',
'app/nibs/en.lproj/FindBar.xib',
'app/nibs/en.lproj/FirstRunDialog.xib',
'app/nibs/en.lproj/MainMenu.xib',
......@@ -2875,8 +2878,11 @@
'browser/download/save_page_uitest.cc',
'browser/login_prompt_uitest.cc',
'browser/metrics/metrics_service_uitest.cc',
# leaves an extra window on screen after test completes.
'browser/sessions/session_restore_uitest.cc',
# hangs indefinitely but doesn't crash.
'browser/tab_restore_uitest.cc',
# puts up modal dialogs.
'browser/unload_uitest.cc',
'test/reliability/page_load_test.cc',
'test/ui/layout_plugin_uitest.cc',
......
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