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

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 11362250: Remove PrefObserver usages, batch 6. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // defined(OS_WIN) 10 #endif // defined(OS_WIN)
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 #if defined(ENABLE_THEMES) 389 #if defined(ENABLE_THEMES)
390 registrar_.Add( 390 registrar_.Add(
391 this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 391 this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
392 content::Source<ThemeService>( 392 content::Source<ThemeService>(
393 ThemeServiceFactory::GetForProfile(profile_))); 393 ThemeServiceFactory::GetForProfile(profile_)));
394 #endif 394 #endif
395 registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, 395 registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED,
396 content::NotificationService::AllSources()); 396 content::NotificationService::AllSources());
397 397
398 profile_pref_registrar_.Init(profile_->GetPrefs()); 398 profile_pref_registrar_.Init(profile_->GetPrefs());
399 profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); 399 profile_pref_registrar_.Add(
400 profile_pref_registrar_.Add(prefs::kShowBookmarkBar, this); 400 prefs::kDevToolsDisabled,
401 profile_pref_registrar_.Add(prefs::kHomePage, this); 401 base::Bind(&Browser::OnDevToolsDisabledChanged, base::Unretained(this)));
402 profile_pref_registrar_.Add(
403 prefs::kShowBookmarkBar,
404 base::Bind(&Browser::UpdateBookmarkBarState, base::Unretained(this),
405 BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE));
406 profile_pref_registrar_.Add(
407 prefs::kHomePage,
408 base::Bind(&Browser::MarkHomePageAsChanged, base::Unretained(this)));
402 409
403 BrowserList::AddBrowser(this); 410 BrowserList::AddBrowser(this);
404 411
405 // NOTE: These prefs all need to be explicitly destroyed in the destructor 412 // NOTE: These prefs all need to be explicitly destroyed in the destructor
406 // or you'll get a nasty surprise when you run the incognito tests. 413 // or you'll get a nasty surprise when you run the incognito tests.
407 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, 414 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector,
408 profile_->GetPrefs(), NULL); 415 profile_->GetPrefs(), NULL);
409 416
410 instant_controller_.reset(new chrome::BrowserInstantController(this)); 417 instant_controller_.reset(new chrome::BrowserInstantController(this));
411 418
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 1937
1931 case content::NOTIFICATION_INTERSTITIAL_DETACHED: 1938 case content::NOTIFICATION_INTERSTITIAL_DETACHED:
1932 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); 1939 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
1933 break; 1940 break;
1934 1941
1935 default: 1942 default:
1936 NOTREACHED() << "Got a notification we didn't register for."; 1943 NOTREACHED() << "Got a notification we didn't register for.";
1937 } 1944 }
1938 } 1945 }
1939 1946
1940 void Browser::OnPreferenceChanged(PrefServiceBase* service,
1941 const std::string& pref_name) {
1942 if (pref_name == prefs::kDevToolsDisabled) {
1943 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled))
1944 content::DevToolsManager::GetInstance()->CloseAllClientHosts();
1945 } else if (pref_name == prefs::kShowBookmarkBar) {
1946 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE);
1947 } else if (pref_name == prefs::kHomePage) {
1948 MarkHomePageAsChanged(static_cast<PrefService*>(service));
1949 } else {
1950 NOTREACHED();
1951 }
1952 }
1953
1954 void Browser::ModeChanged(const chrome::search::Mode& old_mode, 1947 void Browser::ModeChanged(const chrome::search::Mode& old_mode,
1955 const chrome::search::Mode& new_mode) { 1948 const chrome::search::Mode& new_mode) {
1956 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); 1949 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
1957 } 1950 }
1958 1951
1959 /////////////////////////////////////////////////////////////////////////////// 1952 ///////////////////////////////////////////////////////////////////////////////
1960 // Browser, Command and state updating (private): 1953 // Browser, Command and state updating (private):
1961 1954
1962 void Browser::MarkHomePageAsChanged(PrefService* pref_service) { 1955 void Browser::OnDevToolsDisabledChanged() {
1963 pref_service->SetBoolean(prefs::kHomePageChanged, true); 1956 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled))
1957 content::DevToolsManager::GetInstance()->CloseAllClientHosts();
1958 }
1959
1960 void Browser::MarkHomePageAsChanged() {
1961 profile_->GetPrefs()->SetBoolean(prefs::kHomePageChanged, true);
1964 } 1962 }
1965 1963
1966 /////////////////////////////////////////////////////////////////////////////// 1964 ///////////////////////////////////////////////////////////////////////////////
1967 // Browser, UI update coalescing and handling (private): 1965 // Browser, UI update coalescing and handling (private):
1968 1966
1969 void Browser::UpdateToolbar(bool should_restore_state) { 1967 void Browser::UpdateToolbar(bool should_restore_state) {
1970 window_->UpdateToolbar(chrome::GetActiveTabContents(this), 1968 window_->UpdateToolbar(chrome::GetActiveTabContents(this),
1971 should_restore_state); 1969 should_restore_state);
1972 } 1970 }
1973 1971
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 if (contents && !allow_js_access) { 2345 if (contents && !allow_js_access) {
2348 contents->web_contents()->GetController().LoadURL( 2346 contents->web_contents()->GetController().LoadURL(
2349 target_url, 2347 target_url,
2350 content::Referrer(), 2348 content::Referrer(),
2351 content::PAGE_TRANSITION_LINK, 2349 content::PAGE_TRANSITION_LINK,
2352 std::string()); // No extra headers. 2350 std::string()); // No extra headers.
2353 } 2351 }
2354 2352
2355 return contents != NULL; 2353 return contents != NULL;
2356 } 2354 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698