| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 #include "chrome/browser/browser.h" | 5 #include "chrome/browser/browser.h" |
| 6 | 6 |
| 7 #include "app/animation.h" | 7 #include "app/animation.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/idle_timer.h" | 10 #include "base/idle_timer.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/thread.h" | 13 #include "base/thread.h" |
| 14 #include "chrome/app/chrome_dll_resource.h" | 14 #include "chrome/app/chrome_dll_resource.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model.h" | 15 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 16 #include "chrome/browser/browser_list.h" | 16 #include "chrome/browser/browser_list.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/browser_shutdown.h" | 18 #include "chrome/browser/browser_shutdown.h" |
| 19 #include "chrome/browser/browser_window.h" | 19 #include "chrome/browser/browser_window.h" |
| 20 #include "chrome/browser/character_encoding.h" | 20 #include "chrome/browser/character_encoding.h" |
| 21 #include "chrome/browser/debugger/devtools_manager.h" | 21 #include "chrome/browser/debugger/devtools_manager.h" |
| 22 #include "chrome/browser/download/download_item_model.h" | 22 #include "chrome/browser/download/download_item_model.h" |
| 23 #include "chrome/browser/download/download_manager.h" | 23 #include "chrome/browser/download/download_manager.h" |
| 24 #include "chrome/browser/download/download_shelf.h" | 24 #include "chrome/browser/download/download_shelf.h" |
| 25 #include "chrome/browser/download/download_started_animation.h" | 25 #include "chrome/browser/download/download_started_animation.h" |
| 26 #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h" |
| 26 #include "chrome/browser/find_bar.h" | 27 #include "chrome/browser/find_bar.h" |
| 27 #include "chrome/browser/find_bar_controller.h" | 28 #include "chrome/browser/find_bar_controller.h" |
| 28 #include "chrome/browser/location_bar.h" | 29 #include "chrome/browser/location_bar.h" |
| 29 #include "chrome/browser/metrics/user_metrics.h" | 30 #include "chrome/browser/metrics/user_metrics.h" |
| 30 #include "chrome/browser/net/url_fixer_upper.h" | 31 #include "chrome/browser/net/url_fixer_upper.h" |
| 31 #include "chrome/browser/options_window.h" | 32 #include "chrome/browser/options_window.h" |
| 32 #include "chrome/browser/profile.h" | 33 #include "chrome/browser/profile.h" |
| 33 #include "chrome/browser/renderer_host/site_instance.h" | 34 #include "chrome/browser/renderer_host/site_instance.h" |
| 34 #include "chrome/browser/sessions/session_service.h" | 35 #include "chrome/browser/sessions/session_service.h" |
| 35 #include "chrome/browser/sessions/session_types.h" | 36 #include "chrome/browser/sessions/session_types.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 chrome_updater_factory_(this), | 182 chrome_updater_factory_(this), |
| 182 is_attempting_to_close_browser_(false), | 183 is_attempting_to_close_browser_(false), |
| 183 cancel_download_confirmation_state_(NOT_PROMPTED), | 184 cancel_download_confirmation_state_(NOT_PROMPTED), |
| 184 maximized_state_(MAXIMIZED_STATE_DEFAULT), | 185 maximized_state_(MAXIMIZED_STATE_DEFAULT), |
| 185 method_factory_(this), | 186 method_factory_(this), |
| 186 idle_task_(new BrowserIdleTimer) { | 187 idle_task_(new BrowserIdleTimer) { |
| 187 tabstrip_model_.AddObserver(this); | 188 tabstrip_model_.AddObserver(this); |
| 188 | 189 |
| 189 registrar_.Add(this, NotificationType::SSL_VISIBLE_STATE_CHANGED, | 190 registrar_.Add(this, NotificationType::SSL_VISIBLE_STATE_CHANGED, |
| 190 NotificationService::AllSources()); | 191 NotificationService::AllSources()); |
| 192 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, |
| 193 NotificationService::AllSources()); |
| 191 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, | 194 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, |
| 192 NotificationService::AllSources()); | 195 NotificationService::AllSources()); |
| 193 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 196 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, |
| 194 NotificationService::AllSources()); | 197 NotificationService::AllSources()); |
| 195 | 198 |
| 196 InitCommandState(); | 199 InitCommandState(); |
| 197 BrowserList::AddBrowser(this); | 200 BrowserList::AddBrowser(this); |
| 198 | 201 |
| 199 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, | 202 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, |
| 200 profile_->GetPrefs(), NULL); | 203 profile_->GetPrefs(), NULL); |
| (...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 // tab contents to be NULL. This is because we listen for all sources | 2075 // tab contents to be NULL. This is because we listen for all sources |
| 2073 // (NavigationControllers) for convenience, so the notification could | 2076 // (NavigationControllers) for convenience, so the notification could |
| 2074 // actually be for a different window while we're doing asynchronous | 2077 // actually be for a different window while we're doing asynchronous |
| 2075 // closing of this one. | 2078 // closing of this one. |
| 2076 if (GetSelectedTabContents() && | 2079 if (GetSelectedTabContents() && |
| 2077 &GetSelectedTabContents()->controller() == | 2080 &GetSelectedTabContents()->controller() == |
| 2078 Source<NavigationController>(source).ptr()) | 2081 Source<NavigationController>(source).ptr()) |
| 2079 UpdateToolbar(false); | 2082 UpdateToolbar(false); |
| 2080 break; | 2083 break; |
| 2081 | 2084 |
| 2085 case NotificationType::EXTENSION_UPDATE_DISABLED: { |
| 2086 // Show the UI. |
| 2087 ExtensionsService* service = Source<ExtensionsService>(source).ptr(); |
| 2088 Extension* extension = Details<Extension>(details).ptr(); |
| 2089 ShowExtensionDisabledUI(service, profile_, extension); |
| 2090 break; |
| 2091 } |
| 2092 |
| 2082 case NotificationType::EXTENSION_UNLOADED: { | 2093 case NotificationType::EXTENSION_UNLOADED: { |
| 2083 // Close any tabs from the unloaded extension. | 2094 // Close any tabs from the unloaded extension. |
| 2084 Extension* extension = Details<Extension>(details).ptr(); | 2095 Extension* extension = Details<Extension>(details).ptr(); |
| 2085 for (int i = 0; i < tabstrip_model_.count(); i++) { | 2096 for (int i = 0; i < tabstrip_model_.count(); i++) { |
| 2086 TabContents* tc = tabstrip_model_.GetTabContentsAt(i); | 2097 TabContents* tc = tabstrip_model_.GetTabContentsAt(i); |
| 2087 if (tc->GetURL().SchemeIs(chrome::kExtensionScheme) && | 2098 if (tc->GetURL().SchemeIs(chrome::kExtensionScheme) && |
| 2088 tc->GetURL().host() == extension->id()) { | 2099 tc->GetURL().host() == extension->id()) { |
| 2089 CloseTabContents(tc); | 2100 CloseTabContents(tc); |
| 2090 return; | 2101 return; |
| 2091 } | 2102 } |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2787 /////////////////////////////////////////////////////////////////////////////// | 2798 /////////////////////////////////////////////////////////////////////////////// |
| 2788 // BrowserToolbarModel (private): | 2799 // BrowserToolbarModel (private): |
| 2789 | 2800 |
| 2790 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { | 2801 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { |
| 2791 // This |current_tab| can be NULL during the initialization of the | 2802 // This |current_tab| can be NULL during the initialization of the |
| 2792 // toolbar during window creation (i.e. before any tabs have been added | 2803 // toolbar during window creation (i.e. before any tabs have been added |
| 2793 // to the window). | 2804 // to the window). |
| 2794 TabContents* current_tab = browser_->GetSelectedTabContents(); | 2805 TabContents* current_tab = browser_->GetSelectedTabContents(); |
| 2795 return current_tab ? ¤t_tab->controller() : NULL; | 2806 return current_tab ? ¤t_tab->controller() : NULL; |
| 2796 } | 2807 } |
| OLD | NEW |