| OLD | NEW |
| 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/preferences_window_controller.h" | 5 #import "chrome/browser/cocoa/preferences_window_controller.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/mac_util.h" | 8 #include "base/mac_util.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 ShellIntegration::SetAsDefaultBrowser(); | 547 ShellIntegration::SetAsDefaultBrowser(); |
| 548 [self recordUserAction:L"Options_SetAsDefaultBrowser"]; | 548 [self recordUserAction:L"Options_SetAsDefaultBrowser"]; |
| 549 // If the user made Chrome the default browser, then he/she arguably wants | 549 // If the user made Chrome the default browser, then he/she arguably wants |
| 550 // to be notified when that changes. | 550 // to be notified when that changes. |
| 551 prefs_->SetBoolean(prefs::kCheckDefaultBrowser, true); | 551 prefs_->SetBoolean(prefs::kCheckDefaultBrowser, true); |
| 552 | 552 |
| 553 // Tickle KVO so that the UI updates. | 553 // Tickle KVO so that the UI updates. |
| 554 [self didChangeValueForKey:@"defaultBrowser"]; | 554 [self didChangeValueForKey:@"defaultBrowser"]; |
| 555 } | 555 } |
| 556 | 556 |
| 557 // Returns if Chromium is the default browser. | 557 // Returns the Chromium default browser state. |
| 558 - (BOOL)isDefaultBrowser { | 558 - (ShellIntegration::DefaultBrowserState)isDefaultBrowser { |
| 559 return ShellIntegration::IsDefaultBrowser() ? YES : NO; | 559 return ShellIntegration::IsDefaultBrowser(); |
| 560 } | 560 } |
| 561 | 561 |
| 562 // Returns the text color of the "chromium is your default browser" text (green | 562 // Returns the text color of the "chromium is your default browser" text (green |
| 563 // for yes, red for no). | 563 // for yes, red for no). |
| 564 - (NSColor*)defaultBrowserTextColor { | 564 - (NSColor*)defaultBrowserTextColor { |
| 565 return [self isDefaultBrowser] ? | 565 ShellIntegration::DefaultBrowserState state = [self isDefaultBrowser]; |
| 566 return (state == ShellIntegration::IS_DEFAULT_BROWSER) ? |
| 566 [NSColor colorWithCalibratedRed:0.0 green:135.0/255.0 blue:0 alpha:1.0] : | 567 [NSColor colorWithCalibratedRed:0.0 green:135.0/255.0 blue:0 alpha:1.0] : |
| 567 [NSColor colorWithCalibratedRed:135.0/255.0 green:0 blue:0 alpha:1.0]; | 568 [NSColor colorWithCalibratedRed:135.0/255.0 green:0 blue:0 alpha:1.0]; |
| 568 } | 569 } |
| 569 | 570 |
| 570 // Returns the text for the "chromium is your default browser" string dependent | 571 // Returns the text for the "chromium is your default browser" string dependent |
| 571 // on if Chromium actually is or not. | 572 // on if Chromium actually is or not. |
| 572 - (NSString*)defaultBrowserText { | 573 - (NSString*)defaultBrowserText { |
| 573 BOOL isDefault = [self isDefaultBrowser]; | 574 ShellIntegration::DefaultBrowserState state = [self isDefaultBrowser]; |
| 574 int stringId = isDefault ? IDS_OPTIONS_DEFAULTBROWSER_DEFAULT : | 575 int stringId; |
| 575 IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT; | 576 if (state == ShellIntegration::IS_DEFAULT_BROWSER) |
| 577 stringId = IDS_OPTIONS_DEFAULTBROWSER_DEFAULT; |
| 578 else if (state == ShellIntegration::NOT_DEFAULT_BROWSER) |
| 579 stringId = IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT; |
| 580 else |
| 581 stringId = IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN; |
| 576 std::wstring text = | 582 std::wstring text = |
| 577 l10n_util::GetStringF(stringId, l10n_util::GetString(IDS_PRODUCT_NAME)); | 583 l10n_util::GetStringF(stringId, l10n_util::GetString(IDS_PRODUCT_NAME)); |
| 578 return base::SysWideToNSString(text); | 584 return base::SysWideToNSString(text); |
| 579 } | 585 } |
| 580 | 586 |
| 581 //------------------------------------------------------------------------- | 587 //------------------------------------------------------------------------- |
| 582 // User Data panel | 588 // User Data panel |
| 583 | 589 |
| 584 // Since passwords and forms are radio groups, 'enabled' is index 0 and | 590 // Since passwords and forms are radio groups, 'enabled' is index 0 and |
| 585 // 'disabled' is index 1. Yay. | 591 // 'disabled' is index 1. Yay. |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 [[NSNotificationCenter defaultCenter] | 942 [[NSNotificationCenter defaultCenter] |
| 937 postNotificationName:kUserDoneEditingPrefsNotification | 943 postNotificationName:kUserDoneEditingPrefsNotification |
| 938 object:self]; | 944 object:self]; |
| 939 } | 945 } |
| 940 | 946 |
| 941 - (void)controlTextDidEndEditing:(NSNotification*)notification { | 947 - (void)controlTextDidEndEditing:(NSNotification*)notification { |
| 942 [customPagesSource_ validateURLs]; | 948 [customPagesSource_ validateURLs]; |
| 943 } | 949 } |
| 944 | 950 |
| 945 @end | 951 @end |
| OLD | NEW |