| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/l10n_util_mac.h" | 10 #include "app/l10n_util_mac.h" |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 }; | 385 }; |
| 386 | 386 |
| 387 // Tracks state for a managed prefs banner and triggers UI updates through the | 387 // Tracks state for a managed prefs banner and triggers UI updates through the |
| 388 // PreferencesWindowController as appropriate. | 388 // PreferencesWindowController as appropriate. |
| 389 class ManagedPrefsBannerState : public ManagedPrefsBannerBase { | 389 class ManagedPrefsBannerState : public ManagedPrefsBannerBase { |
| 390 public: | 390 public: |
| 391 virtual ~ManagedPrefsBannerState() { } | 391 virtual ~ManagedPrefsBannerState() { } |
| 392 | 392 |
| 393 explicit ManagedPrefsBannerState(PreferencesWindowController* controller, | 393 explicit ManagedPrefsBannerState(PreferencesWindowController* controller, |
| 394 OptionsPage page, | 394 OptionsPage page, |
| 395 PrefService* local_state, |
| 395 PrefService* prefs) | 396 PrefService* prefs) |
| 396 : ManagedPrefsBannerBase(prefs, page), | 397 : ManagedPrefsBannerBase(local_state, prefs, page), |
| 397 controller_(controller), | 398 controller_(controller), |
| 398 page_(page) { } | 399 page_(page) { } |
| 399 | 400 |
| 400 BOOL IsVisible() { | 401 BOOL IsVisible() { |
| 401 return DetermineVisibility(); | 402 return DetermineVisibility(); |
| 402 } | 403 } |
| 403 | 404 |
| 404 protected: | 405 protected: |
| 405 // Overridden from ManagedPrefsBannerBase. | 406 // Overridden from ManagedPrefsBannerBase. |
| 406 virtual void OnUpdateVisibility() { | 407 virtual void OnUpdateVisibility() { |
| (...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1953 - (void)animationDidEnd:(NSAnimation*)animation { | 1954 - (void)animationDidEnd:(NSAnimation*)animation { |
| 1954 DCHECK_EQ(animation_.get(), animation); | 1955 DCHECK_EQ(animation_.get(), animation); |
| 1955 // Animation finished, reset subviews to current prefs view and the banner. | 1956 // Animation finished, reset subviews to current prefs view and the banner. |
| 1956 [self resetSubViews]; | 1957 [self resetSubViews]; |
| 1957 } | 1958 } |
| 1958 | 1959 |
| 1959 // Reinitializes the banner state tracker object to watch for managed bits of | 1960 // Reinitializes the banner state tracker object to watch for managed bits of |
| 1960 // preferences relevant to the given options |page|. | 1961 // preferences relevant to the given options |page|. |
| 1961 - (void)initBannerStateForPage:(OptionsPage)page { | 1962 - (void)initBannerStateForPage:(OptionsPage)page { |
| 1962 page = [self normalizePage:page]; | 1963 page = [self normalizePage:page]; |
| 1964 |
| 1965 // During unit tests, there is no local state object, so we fall back to |
| 1966 // the prefs object (where we've explicitly registered this pref so we |
| 1967 // know it's there). |
| 1968 PrefService* local = g_browser_process->local_state(); |
| 1969 if (!local) |
| 1970 local = prefs_; |
| 1963 bannerState_.reset( | 1971 bannerState_.reset( |
| 1964 new PreferencesWindowControllerInternal::ManagedPrefsBannerState( | 1972 new PreferencesWindowControllerInternal::ManagedPrefsBannerState( |
| 1965 self, page, prefs_)); | 1973 self, page, local, prefs_)); |
| 1966 } | 1974 } |
| 1967 | 1975 |
| 1968 - (void)switchToPage:(OptionsPage)page animate:(BOOL)animate { | 1976 - (void)switchToPage:(OptionsPage)page animate:(BOOL)animate { |
| 1969 [self displayPreferenceViewForPage:page animate:animate]; | 1977 [self displayPreferenceViewForPage:page animate:animate]; |
| 1970 NSToolbarItem* toolbarItem = [self getToolbarItemForPage:page]; | 1978 NSToolbarItem* toolbarItem = [self getToolbarItemForPage:page]; |
| 1971 [toolbar_ setSelectedItemIdentifier:[toolbarItem itemIdentifier]]; | 1979 [toolbar_ setSelectedItemIdentifier:[toolbarItem itemIdentifier]]; |
| 1972 } | 1980 } |
| 1973 | 1981 |
| 1974 // Called when the window is being closed. Send out a notification that the user | 1982 // Called when the window is being closed. Send out a notification that the user |
| 1975 // is done editing preferences. Make sure there are no pending field editors | 1983 // is done editing preferences. Make sure there are no pending field editors |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2066 case OPTIONS_PAGE_ADVANCED: | 2074 case OPTIONS_PAGE_ADVANCED: |
| 2067 return underTheHoodView_; | 2075 return underTheHoodView_; |
| 2068 case OPTIONS_PAGE_DEFAULT: | 2076 case OPTIONS_PAGE_DEFAULT: |
| 2069 case OPTIONS_PAGE_COUNT: | 2077 case OPTIONS_PAGE_COUNT: |
| 2070 LOG(DFATAL) << "Invalid page value " << page; | 2078 LOG(DFATAL) << "Invalid page value " << page; |
| 2071 } | 2079 } |
| 2072 return basicsView_; | 2080 return basicsView_; |
| 2073 } | 2081 } |
| 2074 | 2082 |
| 2075 @end | 2083 @end |
| OLD | NEW |