| OLD | NEW | 
|     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  Loading... | 
|   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 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1935  |  1942  | 
|  1936     case content::NOTIFICATION_INTERSTITIAL_DETACHED: |  1943     case content::NOTIFICATION_INTERSTITIAL_DETACHED: | 
|  1937       UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |  1944       UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 
|  1938       break; |  1945       break; | 
|  1939  |  1946  | 
|  1940     default: |  1947     default: | 
|  1941       NOTREACHED() << "Got a notification we didn't register for."; |  1948       NOTREACHED() << "Got a notification we didn't register for."; | 
|  1942   } |  1949   } | 
|  1943 } |  1950 } | 
|  1944  |  1951  | 
|  1945 void Browser::OnPreferenceChanged(PrefServiceBase* service, |  | 
|  1946                                   const std::string& pref_name) { |  | 
|  1947   if (pref_name == prefs::kDevToolsDisabled) { |  | 
|  1948     if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) |  | 
|  1949       content::DevToolsManager::GetInstance()->CloseAllClientHosts(); |  | 
|  1950   } else if (pref_name == prefs::kShowBookmarkBar) { |  | 
|  1951     UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); |  | 
|  1952   } else if (pref_name == prefs::kHomePage) { |  | 
|  1953     MarkHomePageAsChanged(static_cast<PrefService*>(service)); |  | 
|  1954   } else { |  | 
|  1955     NOTREACHED(); |  | 
|  1956   } |  | 
|  1957 } |  | 
|  1958  |  | 
|  1959 void Browser::ModeChanged(const chrome::search::Mode& old_mode, |  1952 void Browser::ModeChanged(const chrome::search::Mode& old_mode, | 
|  1960                           const chrome::search::Mode& new_mode) { |  1953                           const chrome::search::Mode& new_mode) { | 
|  1961   UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |  1954   UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 
|  1962 } |  1955 } | 
|  1963  |  1956  | 
|  1964 /////////////////////////////////////////////////////////////////////////////// |  1957 /////////////////////////////////////////////////////////////////////////////// | 
|  1965 // Browser, Command and state updating (private): |  1958 // Browser, Command and state updating (private): | 
|  1966  |  1959  | 
|  1967 void Browser::MarkHomePageAsChanged(PrefService* pref_service) { |  1960 void Browser::OnDevToolsDisabledChanged() { | 
|  1968   pref_service->SetBoolean(prefs::kHomePageChanged, true); |  1961   if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) | 
 |  1962     content::DevToolsManager::GetInstance()->CloseAllClientHosts(); | 
 |  1963 } | 
 |  1964  | 
 |  1965 void Browser::MarkHomePageAsChanged() { | 
 |  1966   profile_->GetPrefs()->SetBoolean(prefs::kHomePageChanged, true); | 
|  1969 } |  1967 } | 
|  1970  |  1968  | 
|  1971 /////////////////////////////////////////////////////////////////////////////// |  1969 /////////////////////////////////////////////////////////////////////////////// | 
|  1972 // Browser, UI update coalescing and handling (private): |  1970 // Browser, UI update coalescing and handling (private): | 
|  1973  |  1971  | 
|  1974 void Browser::UpdateToolbar(bool should_restore_state) { |  1972 void Browser::UpdateToolbar(bool should_restore_state) { | 
|  1975   window_->UpdateToolbar(chrome::GetActiveTabContents(this), |  1973   window_->UpdateToolbar(chrome::GetActiveTabContents(this), | 
|  1976                          should_restore_state); |  1974                          should_restore_state); | 
|  1977 } |  1975 } | 
|  1978  |  1976  | 
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2352   if (contents && !allow_js_access) { |  2350   if (contents && !allow_js_access) { | 
|  2353     contents->web_contents()->GetController().LoadURL( |  2351     contents->web_contents()->GetController().LoadURL( | 
|  2354         target_url, |  2352         target_url, | 
|  2355         content::Referrer(), |  2353         content::Referrer(), | 
|  2356         content::PAGE_TRANSITION_LINK, |  2354         content::PAGE_TRANSITION_LINK, | 
|  2357         std::string());  // No extra headers. |  2355         std::string());  // No extra headers. | 
|  2358   } |  2356   } | 
|  2359  |  2357  | 
|  2360   return contents != NULL; |  2358   return contents != NULL; | 
|  2361 } |  2359 } | 
| OLD | NEW |