| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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  // OS_WIN | 10 #endif  // OS_WIN | 
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 92 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 92 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 
| 93 #include "chrome/browser/ui/tabs/dock_info.h" | 93 #include "chrome/browser/ui/tabs/dock_info.h" | 
| 94 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 94 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 
| 95 #include "chrome/browser/ui/web_applications/web_app_ui.h" | 95 #include "chrome/browser/ui/web_applications/web_app_ui.h" | 
| 96 #include "chrome/browser/ui/webui/bug_report_ui.h" | 96 #include "chrome/browser/ui/webui/bug_report_ui.h" | 
| 97 #include "chrome/browser/ui/webui/options/content_settings_handler.h" | 97 #include "chrome/browser/ui/webui/options/content_settings_handler.h" | 
| 98 #include "chrome/browser/ui/window_sizer.h" | 98 #include "chrome/browser/ui/window_sizer.h" | 
| 99 #include "chrome/browser/upgrade_detector.h" | 99 #include "chrome/browser/upgrade_detector.h" | 
| 100 #include "chrome/browser/web_applications/web_app.h" | 100 #include "chrome/browser/web_applications/web_app.h" | 
| 101 #include "chrome/common/chrome_constants.h" | 101 #include "chrome/common/chrome_constants.h" | 
|  | 102 #include "chrome/common/chrome_notification_types.h" | 
| 102 #include "chrome/common/chrome_switches.h" | 103 #include "chrome/common/chrome_switches.h" | 
| 103 #include "chrome/common/extensions/extension.h" | 104 #include "chrome/common/extensions/extension.h" | 
| 104 #include "chrome/common/extensions/extension_constants.h" | 105 #include "chrome/common/extensions/extension_constants.h" | 
| 105 #include "chrome/common/pref_names.h" | 106 #include "chrome/common/pref_names.h" | 
| 106 #include "chrome/common/profiling.h" | 107 #include "chrome/common/profiling.h" | 
| 107 #include "chrome/common/url_constants.h" | 108 #include "chrome/common/url_constants.h" | 
| 108 #include "chrome/common/web_apps.h" | 109 #include "chrome/common/web_apps.h" | 
| 109 #include "content/browser/debugger/devtools_manager.h" | 110 #include "content/browser/debugger/devtools_manager.h" | 
| 110 #include "content/browser/debugger/devtools_toggle_action.h" | 111 #include "content/browser/debugger/devtools_toggle_action.h" | 
| 111 #include "content/browser/debugger/devtools_window.h" | 112 #include "content/browser/debugger/devtools_window.h" | 
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 243       maximized_state_(MAXIMIZED_STATE_DEFAULT), | 244       maximized_state_(MAXIMIZED_STATE_DEFAULT), | 
| 244       method_factory_(this), | 245       method_factory_(this), | 
| 245       block_command_execution_(false), | 246       block_command_execution_(false), | 
| 246       last_blocked_command_id_(-1), | 247       last_blocked_command_id_(-1), | 
| 247       last_blocked_command_disposition_(CURRENT_TAB), | 248       last_blocked_command_disposition_(CURRENT_TAB), | 
| 248       pending_web_app_action_(NONE), | 249       pending_web_app_action_(NONE), | 
| 249       ALLOW_THIS_IN_INITIALIZER_LIST( | 250       ALLOW_THIS_IN_INITIALIZER_LIST( | 
| 250           tab_restore_service_delegate_( | 251           tab_restore_service_delegate_( | 
| 251               new BrowserTabRestoreServiceDelegate(this))), | 252               new BrowserTabRestoreServiceDelegate(this))), | 
| 252       bookmark_bar_state_(BookmarkBar::HIDDEN) { | 253       bookmark_bar_state_(BookmarkBar::HIDDEN) { | 
| 253   registrar_.Add(this, NotificationType::SSL_VISIBLE_STATE_CHANGED, | 254   registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, | 
| 254                  NotificationService::AllSources()); | 255                  NotificationService::AllSources()); | 
| 255   registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, | 256   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 
| 256                  NotificationService::AllSources()); | 257                  NotificationService::AllSources()); | 
| 257   registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 258   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 
| 258                  NotificationService::AllSources()); | 259                  NotificationService::AllSources()); | 
| 259   registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, | 260   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 
| 260                  NotificationService::AllSources()); | 261                  NotificationService::AllSources()); | 
| 261   registrar_.Add(this, NotificationType::EXTENSION_UNINSTALLED, | 262   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 
| 262                  NotificationService::AllSources()); | 263                  NotificationService::AllSources()); | 
| 263   registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED, | 264   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 
| 264                  NotificationService::AllSources()); | 265                  NotificationService::AllSources()); | 
| 265   registrar_.Add( | 266   registrar_.Add( | 
| 266       this, NotificationType::BROWSER_THEME_CHANGED, | 267       this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 
| 267       Source<ThemeService>(ThemeServiceFactory::GetForProfile(profile_))); | 268       Source<ThemeService>(ThemeServiceFactory::GetForProfile(profile_))); | 
| 268   registrar_.Add(this, NotificationType::TAB_CONTENT_SETTINGS_CHANGED, | 269   registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED, | 
| 269                  NotificationService::AllSources()); | 270                  NotificationService::AllSources()); | 
| 270   registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, | 271   registrar_.Add(this, | 
|  | 272                  chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, | 
| 271                  NotificationService::AllSources()); | 273                  NotificationService::AllSources()); | 
| 272 | 274 | 
| 273   // Need to know when to alert the user of theme install delay. | 275   // Need to know when to alert the user of theme install delay. | 
| 274   registrar_.Add(this, NotificationType::EXTENSION_READY_FOR_INSTALL, | 276   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_READY_FOR_INSTALL, | 
| 275                  NotificationService::AllSources()); | 277                  NotificationService::AllSources()); | 
| 276 | 278 | 
| 277   PrefService* local_state = g_browser_process->local_state(); | 279   PrefService* local_state = g_browser_process->local_state(); | 
| 278   if (local_state) { | 280   if (local_state) { | 
| 279     local_pref_registrar_.Init(local_state); | 281     local_pref_registrar_.Init(local_state); | 
| 280     local_pref_registrar_.Add(prefs::kPrintingEnabled, this); | 282     local_pref_registrar_.Add(prefs::kPrintingEnabled, this); | 
| 281     local_pref_registrar_.Add(prefs::kAllowFileSelectionDialogs, this); | 283     local_pref_registrar_.Add(prefs::kAllowFileSelectionDialogs, this); | 
| 282   } | 284   } | 
| 283 | 285 | 
| 284   profile_pref_registrar_.Init(profile_->GetPrefs()); | 286   profile_pref_registrar_.Init(profile_->GetPrefs()); | 
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 460     // name.  See http://crbug.com/7028. | 462     // name.  See http://crbug.com/7028. | 
| 461     ui::win::SetAppIdForWindow( | 463     ui::win::SetAppIdForWindow( | 
| 462         is_app() ? | 464         is_app() ? | 
| 463         ShellIntegration::GetAppId(UTF8ToWide(app_name_), profile_->GetPath()) : | 465         ShellIntegration::GetAppId(UTF8ToWide(app_name_), profile_->GetPath()) : | 
| 464         ShellIntegration::GetChromiumAppId(profile_->GetPath()), | 466         ShellIntegration::GetChromiumAppId(profile_->GetPath()), | 
| 465         window()->GetNativeHandle()); | 467         window()->GetNativeHandle()); | 
| 466   } | 468   } | 
| 467 #endif | 469 #endif | 
| 468 | 470 | 
| 469   NotificationService::current()->Notify( | 471   NotificationService::current()->Notify( | 
| 470       NotificationType::BROWSER_WINDOW_READY, | 472       chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 
| 471       Source<Browser>(this), | 473       Source<Browser>(this), | 
| 472       NotificationService::NoDetails()); | 474       NotificationService::NoDetails()); | 
| 473 | 475 | 
| 474   if (use_compact_navigation_bar_.GetValue()) { | 476   if (use_compact_navigation_bar_.GetValue()) { | 
| 475     // This enables the compact navigation bar host. | 477     // This enables the compact navigation bar host. | 
| 476     UseCompactNavigationBarChanged(); | 478     UseCompactNavigationBarChanged(); | 
| 477   } | 479   } | 
| 478 | 480 | 
| 479   // Show the First Run information bubble if we've been told to. | 481   // Show the First Run information bubble if we've been told to. | 
| 480   PrefService* local_state = g_browser_process->local_state(); | 482   PrefService* local_state = g_browser_process->local_state(); | 
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 994   if (session_service) | 996   if (session_service) | 
| 995     session_service->WindowClosing(session_id()); | 997     session_service->WindowClosing(session_id()); | 
| 996 | 998 | 
| 997   TabRestoreService* tab_restore_service = | 999   TabRestoreService* tab_restore_service = | 
| 998       TabRestoreServiceFactory::GetForProfile(profile()); | 1000       TabRestoreServiceFactory::GetForProfile(profile()); | 
| 999   if (tab_restore_service && is_type_tabbed() && tab_count()) | 1001   if (tab_restore_service && is_type_tabbed() && tab_count()) | 
| 1000     tab_restore_service->BrowserClosing(tab_restore_service_delegate()); | 1002     tab_restore_service->BrowserClosing(tab_restore_service_delegate()); | 
| 1001 | 1003 | 
| 1002   // TODO(sky): convert session/tab restore to use notification. | 1004   // TODO(sky): convert session/tab restore to use notification. | 
| 1003   NotificationService::current()->Notify( | 1005   NotificationService::current()->Notify( | 
| 1004       NotificationType::BROWSER_CLOSING, | 1006       chrome::NOTIFICATION_BROWSER_CLOSING, | 
| 1005       Source<Browser>(this), | 1007       Source<Browser>(this), | 
| 1006       Details<bool>(&exiting)); | 1008       Details<bool>(&exiting)); | 
| 1007 | 1009 | 
| 1008   CloseAllTabs(); | 1010   CloseAllTabs(); | 
| 1009 } | 1011 } | 
| 1010 | 1012 | 
| 1011 void Browser::OnWindowActivated() { | 1013 void Browser::OnWindowActivated() { | 
| 1012   // On some platforms we want to automatically reload tabs that are | 1014   // On some platforms we want to automatically reload tabs that are | 
| 1013   // killed when the user selects them. | 1015   // killed when the user selects them. | 
| 1014   TabContents* contents = GetSelectedTabContents(); | 1016   TabContents* contents = GetSelectedTabContents(); | 
| (...skipping 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2845   contents->restore_tab_helper()->SetWindowID(session_id()); | 2847   contents->restore_tab_helper()->SetWindowID(session_id()); | 
| 2846 | 2848 | 
| 2847   SyncHistoryWithTabs(index); | 2849   SyncHistoryWithTabs(index); | 
| 2848 | 2850 | 
| 2849   // Make sure the loading state is updated correctly, otherwise the throbber | 2851   // Make sure the loading state is updated correctly, otherwise the throbber | 
| 2850   // won't start if the page is loading. | 2852   // won't start if the page is loading. | 
| 2851   LoadingStateChanged(contents->tab_contents()); | 2853   LoadingStateChanged(contents->tab_contents()); | 
| 2852 | 2854 | 
| 2853   // If the tab crashes in the beforeunload or unload handler, it won't be | 2855   // If the tab crashes in the beforeunload or unload handler, it won't be | 
| 2854   // able to ack. But we know we can close it. | 2856   // able to ack. But we know we can close it. | 
| 2855   registrar_.Add(this, NotificationType::TAB_CONTENTS_DISCONNECTED, | 2857   registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED, | 
| 2856                  Source<TabContents>(contents->tab_contents())); | 2858                  Source<TabContents>(contents->tab_contents())); | 
| 2857 | 2859 | 
| 2858   registrar_.Add(this, NotificationType::INTERSTITIAL_ATTACHED, | 2860   registrar_.Add(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED, | 
| 2859                  Source<TabContents>(contents->tab_contents())); | 2861                  Source<TabContents>(contents->tab_contents())); | 
| 2860 } | 2862 } | 
| 2861 | 2863 | 
| 2862 void Browser::TabClosingAt(TabStripModel* tab_strip_model, | 2864 void Browser::TabClosingAt(TabStripModel* tab_strip_model, | 
| 2863                            TabContentsWrapper* contents, | 2865                            TabContentsWrapper* contents, | 
| 2864                            int index) { | 2866                            int index) { | 
| 2865   NotificationService::current()->Notify( | 2867   NotificationService::current()->Notify( | 
| 2866       NotificationType::TAB_CLOSING, | 2868       content::NOTIFICATION_TAB_CLOSING, | 
| 2867       Source<NavigationController>(&contents->controller()), | 2869       Source<NavigationController>(&contents->controller()), | 
| 2868       NotificationService::NoDetails()); | 2870       NotificationService::NoDetails()); | 
| 2869 | 2871 | 
| 2870   // Sever the TabContents' connection back to us. | 2872   // Sever the TabContents' connection back to us. | 
| 2871   SetAsDelegate(contents, NULL); | 2873   SetAsDelegate(contents, NULL); | 
| 2872 } | 2874 } | 
| 2873 | 2875 | 
| 2874 void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) { | 2876 void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) { | 
| 2875   TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); | 2877   TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); | 
| 2876 } | 2878 } | 
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3085                    tabstrip_model()->GetWrapperIndex(source)) | 3087                    tabstrip_model()->GetWrapperIndex(source)) | 
| 3086              : NULL; | 3088              : NULL; | 
| 3087   params.disposition = disposition; | 3089   params.disposition = disposition; | 
| 3088   params.window_bounds = initial_pos; | 3090   params.window_bounds = initial_pos; | 
| 3089   params.window_action = browser::NavigateParams::SHOW_WINDOW; | 3091   params.window_action = browser::NavigateParams::SHOW_WINDOW; | 
| 3090   params.user_gesture = user_gesture; | 3092   params.user_gesture = user_gesture; | 
| 3091   browser::Navigate(¶ms); | 3093   browser::Navigate(¶ms); | 
| 3092 | 3094 | 
| 3093   if (source) { | 3095   if (source) { | 
| 3094     NotificationService::current()->Notify( | 3096     NotificationService::current()->Notify( | 
| 3095       NotificationType::TAB_ADDED, | 3097       content::NOTIFICATION_TAB_ADDED, | 
| 3096       Source<TabContentsDelegate>(source->delegate()), | 3098       Source<TabContentsDelegate>(source->delegate()), | 
| 3097       Details<TabContents>(source)); | 3099       Details<TabContents>(source)); | 
| 3098   } | 3100   } | 
| 3099 } | 3101 } | 
| 3100 | 3102 | 
| 3101 void Browser::ActivateContents(TabContents* contents) { | 3103 void Browser::ActivateContents(TabContents* contents) { | 
| 3102   tab_handler_->GetTabStripModel()->ActivateTabAt( | 3104   tab_handler_->GetTabStripModel()->ActivateTabAt( | 
| 3103       tab_handler_->GetTabStripModel()->GetWrapperIndex(contents), false); | 3105       tab_handler_->GetTabStripModel()->GetWrapperIndex(contents), false); | 
| 3104   window_->Activate(); | 3106   window_->Activate(); | 
| 3105 } | 3107 } | 
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3225   } | 3227   } | 
| 3226   tabstrip_model()->SetTabBlocked(index, blocked); | 3228   tabstrip_model()->SetTabBlocked(index, blocked); | 
| 3227 } | 3229 } | 
| 3228 | 3230 | 
| 3229 void Browser::TabContentsFocused(TabContents* tab_content) { | 3231 void Browser::TabContentsFocused(TabContents* tab_content) { | 
| 3230   window_->TabContentsFocused(tab_content); | 3232   window_->TabContentsFocused(tab_content); | 
| 3231 } | 3233 } | 
| 3232 | 3234 | 
| 3233 bool Browser::TakeFocus(bool reverse) { | 3235 bool Browser::TakeFocus(bool reverse) { | 
| 3234   NotificationService::current()->Notify( | 3236   NotificationService::current()->Notify( | 
| 3235       NotificationType::FOCUS_RETURNED_TO_BROWSER, | 3237       chrome::NOTIFICATION_FOCUS_RETURNED_TO_BROWSER, | 
| 3236       Source<Browser>(this), | 3238       Source<Browser>(this), | 
| 3237       NotificationService::NoDetails()); | 3239       NotificationService::NoDetails()); | 
| 3238   return false; | 3240   return false; | 
| 3239 } | 3241 } | 
| 3240 | 3242 | 
| 3241 bool Browser::IsApplication() const { | 3243 bool Browser::IsApplication() const { | 
| 3242   return is_app(); | 3244   return is_app(); | 
| 3243 } | 3245 } | 
| 3244 | 3246 | 
| 3245 void Browser::ConvertContentsToApplication(TabContents* contents) { | 3247 void Browser::ConvertContentsToApplication(TabContents* contents) { | 
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3527 void Browser::FileSelected(const FilePath& path, int index, void* params) { | 3529 void Browser::FileSelected(const FilePath& path, int index, void* params) { | 
| 3528   profile_->set_last_selected_directory(path.DirName()); | 3530   profile_->set_last_selected_directory(path.DirName()); | 
| 3529   GURL file_url = net::FilePathToFileURL(path); | 3531   GURL file_url = net::FilePathToFileURL(path); | 
| 3530   if (!file_url.is_empty()) | 3532   if (!file_url.is_empty()) | 
| 3531     OpenURL(file_url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 3533     OpenURL(file_url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 
| 3532 } | 3534 } | 
| 3533 | 3535 | 
| 3534 /////////////////////////////////////////////////////////////////////////////// | 3536 /////////////////////////////////////////////////////////////////////////////// | 
| 3535 // Browser, NotificationObserver implementation: | 3537 // Browser, NotificationObserver implementation: | 
| 3536 | 3538 | 
| 3537 void Browser::Observe(NotificationType type, | 3539 void Browser::Observe(int type, | 
| 3538                       const NotificationSource& source, | 3540                       const NotificationSource& source, | 
| 3539                       const NotificationDetails& details) { | 3541                       const NotificationDetails& details) { | 
| 3540   switch (type.value) { | 3542   switch (type) { | 
| 3541     case NotificationType::TAB_CONTENTS_DISCONNECTED: | 3543     case content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED: | 
| 3542       if (is_attempting_to_close_browser_) { | 3544       if (is_attempting_to_close_browser_) { | 
| 3543         // Pass in false so that we delay processing. We need to delay the | 3545         // Pass in false so that we delay processing. We need to delay the | 
| 3544         // processing as it may close the tab, which is currently on the call | 3546         // processing as it may close the tab, which is currently on the call | 
| 3545         // stack above us. | 3547         // stack above us. | 
| 3546         ClearUnloadState(Source<TabContents>(source).ptr(), false); | 3548         ClearUnloadState(Source<TabContents>(source).ptr(), false); | 
| 3547       } | 3549       } | 
| 3548       break; | 3550       break; | 
| 3549 | 3551 | 
| 3550     case NotificationType::SSL_VISIBLE_STATE_CHANGED: | 3552     case content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED: | 
| 3551       // When the current tab's SSL state changes, we need to update the URL | 3553       // When the current tab's SSL state changes, we need to update the URL | 
| 3552       // bar to reflect the new state. Note that it's possible for the selected | 3554       // bar to reflect the new state. Note that it's possible for the selected | 
| 3553       // tab contents to be NULL. This is because we listen for all sources | 3555       // tab contents to be NULL. This is because we listen for all sources | 
| 3554       // (NavigationControllers) for convenience, so the notification could | 3556       // (NavigationControllers) for convenience, so the notification could | 
| 3555       // actually be for a different window while we're doing asynchronous | 3557       // actually be for a different window while we're doing asynchronous | 
| 3556       // closing of this one. | 3558       // closing of this one. | 
| 3557       if (GetSelectedTabContents() && | 3559       if (GetSelectedTabContents() && | 
| 3558           &GetSelectedTabContents()->controller() == | 3560           &GetSelectedTabContents()->controller() == | 
| 3559           Source<NavigationController>(source).ptr()) | 3561           Source<NavigationController>(source).ptr()) | 
| 3560         UpdateToolbar(false); | 3562         UpdateToolbar(false); | 
| 3561       break; | 3563       break; | 
| 3562 | 3564 | 
| 3563     case NotificationType::EXTENSION_UPDATE_DISABLED: { | 3565     case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: { | 
| 3564       // Show the UI if the extension was disabled for escalated permissions. | 3566       // Show the UI if the extension was disabled for escalated permissions. | 
| 3565       Profile* profile = Source<Profile>(source).ptr(); | 3567       Profile* profile = Source<Profile>(source).ptr(); | 
| 3566       if (profile_->IsSameProfile(profile)) { | 3568       if (profile_->IsSameProfile(profile)) { | 
| 3567         ExtensionService* service = profile->GetExtensionService(); | 3569         ExtensionService* service = profile->GetExtensionService(); | 
| 3568         DCHECK(service); | 3570         DCHECK(service); | 
| 3569         const Extension* extension = Details<const Extension>(details).ptr(); | 3571         const Extension* extension = Details<const Extension>(details).ptr(); | 
| 3570         if (service->extension_prefs()->DidExtensionEscalatePermissions( | 3572         if (service->extension_prefs()->DidExtensionEscalatePermissions( | 
| 3571                 extension->id())) | 3573                 extension->id())) | 
| 3572           ShowExtensionDisabledUI(service, profile_, extension); | 3574           ShowExtensionDisabledUI(service, profile_, extension); | 
| 3573       } | 3575       } | 
| 3574       break; | 3576       break; | 
| 3575     } | 3577     } | 
| 3576 | 3578 | 
| 3577     case NotificationType::EXTENSION_UNLOADED: { | 3579     case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 
| 3578       if (window()->GetLocationBar()) | 3580       if (window()->GetLocationBar()) | 
| 3579         window()->GetLocationBar()->UpdatePageActions(); | 3581         window()->GetLocationBar()->UpdatePageActions(); | 
| 3580 | 3582 | 
| 3581       // Close any tabs from the unloaded extension. | 3583       // Close any tabs from the unloaded extension. | 
| 3582       const Extension* extension = | 3584       const Extension* extension = | 
| 3583           Details<UnloadedExtensionInfo>(details)->extension; | 3585           Details<UnloadedExtensionInfo>(details)->extension; | 
| 3584       TabStripModel* model = tab_handler_->GetTabStripModel(); | 3586       TabStripModel* model = tab_handler_->GetTabStripModel(); | 
| 3585       for (int i = model->count() - 1; i >= 0; --i) { | 3587       for (int i = model->count() - 1; i >= 0; --i) { | 
| 3586         TabContents* tc = model->GetTabContentsAt(i)->tab_contents(); | 3588         TabContents* tc = model->GetTabContentsAt(i)->tab_contents(); | 
| 3587         if (tc->GetURL().SchemeIs(chrome::kExtensionScheme) && | 3589         if (tc->GetURL().SchemeIs(chrome::kExtensionScheme) && | 
| 3588             tc->GetURL().host() == extension->id()) { | 3590             tc->GetURL().host() == extension->id()) { | 
| 3589           CloseTabContents(tc); | 3591           CloseTabContents(tc); | 
| 3590         } | 3592         } | 
| 3591       } | 3593       } | 
| 3592 | 3594 | 
| 3593       break; | 3595       break; | 
| 3594     } | 3596     } | 
| 3595 | 3597 | 
| 3596     case NotificationType::EXTENSION_PROCESS_TERMINATED: { | 3598     case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { | 
| 3597       if (window()->GetLocationBar()) | 3599       if (window()->GetLocationBar()) | 
| 3598         window()->GetLocationBar()->InvalidatePageActions(); | 3600         window()->GetLocationBar()->InvalidatePageActions(); | 
| 3599       break; | 3601       break; | 
| 3600     } | 3602     } | 
| 3601 | 3603 | 
| 3602     case NotificationType::EXTENSION_UNINSTALLED: | 3604     case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: | 
| 3603     case NotificationType::EXTENSION_LOADED: | 3605     case chrome::NOTIFICATION_EXTENSION_LOADED: | 
| 3604       if (window()->GetLocationBar()) | 3606       if (window()->GetLocationBar()) | 
| 3605         window()->GetLocationBar()->UpdatePageActions(); | 3607         window()->GetLocationBar()->UpdatePageActions(); | 
| 3606       break; | 3608       break; | 
| 3607 | 3609 | 
| 3608     case NotificationType::BROWSER_THEME_CHANGED: | 3610     case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: | 
| 3609       window()->UserChangedTheme(); | 3611       window()->UserChangedTheme(); | 
| 3610       break; | 3612       break; | 
| 3611 | 3613 | 
| 3612     case NotificationType::EXTENSION_READY_FOR_INSTALL: { | 3614     case chrome::NOTIFICATION_EXTENSION_READY_FOR_INSTALL: { | 
| 3613       // Handle EXTENSION_READY_FOR_INSTALL for last active tabbed browser. | 3615       // Handle EXTENSION_READY_FOR_INSTALL for last active tabbed browser. | 
| 3614       if (BrowserList::FindTabbedBrowser(profile(), true) != this) | 3616       if (BrowserList::FindTabbedBrowser(profile(), true) != this) | 
| 3615         break; | 3617         break; | 
| 3616 | 3618 | 
| 3617       // We only want to show the loading dialog for themes, but we don't want | 3619       // We only want to show the loading dialog for themes, but we don't want | 
| 3618       // to wait until unpack to find out an extension is a theme, so we test | 3620       // to wait until unpack to find out an extension is a theme, so we test | 
| 3619       // the download_url GURL instead. This means that themes in the extensions | 3621       // the download_url GURL instead. This means that themes in the extensions | 
| 3620       // gallery won't get the loading dialog. | 3622       // gallery won't get the loading dialog. | 
| 3621       GURL download_url = *(Details<GURL>(details).ptr()); | 3623       GURL download_url = *(Details<GURL>(details).ptr()); | 
| 3622       if (ExtensionService::IsDownloadFromMiniGallery(download_url)) | 3624       if (ExtensionService::IsDownloadFromMiniGallery(download_url)) | 
| 3623         window()->ShowThemeInstallBubble(); | 3625         window()->ShowThemeInstallBubble(); | 
| 3624       break; | 3626       break; | 
| 3625     } | 3627     } | 
| 3626 | 3628 | 
| 3627     case NotificationType::PREF_CHANGED: { | 3629     case chrome::NOTIFICATION_PREF_CHANGED: { | 
| 3628       const std::string& pref_name = *Details<std::string>(details).ptr(); | 3630       const std::string& pref_name = *Details<std::string>(details).ptr(); | 
| 3629       if (pref_name == prefs::kUseVerticalTabs) { | 3631       if (pref_name == prefs::kUseVerticalTabs) { | 
| 3630         UseVerticalTabsChanged(); | 3632         UseVerticalTabsChanged(); | 
| 3631       } else if (pref_name == prefs::kUseCompactNavigationBar) { | 3633       } else if (pref_name == prefs::kUseCompactNavigationBar) { | 
| 3632         UseCompactNavigationBarChanged(); | 3634         UseCompactNavigationBarChanged(); | 
| 3633       } else if (pref_name == prefs::kPrintingEnabled) { | 3635       } else if (pref_name == prefs::kPrintingEnabled) { | 
| 3634         UpdatePrintingState(GetContentRestrictionsForSelectedTab()); | 3636         UpdatePrintingState(GetContentRestrictionsForSelectedTab()); | 
| 3635       } else if (pref_name == prefs::kInstantEnabled) { | 3637       } else if (pref_name == prefs::kInstantEnabled) { | 
| 3636         if (!InstantController::IsEnabled(profile())) { | 3638         if (!InstantController::IsEnabled(profile())) { | 
| 3637           if (instant()) { | 3639           if (instant()) { | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 3654         UpdateCommandsForBookmarkEditing(); | 3656         UpdateCommandsForBookmarkEditing(); | 
| 3655       } else if (pref_name == prefs::kAllowFileSelectionDialogs) { | 3657       } else if (pref_name == prefs::kAllowFileSelectionDialogs) { | 
| 3656         UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); | 3658         UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); | 
| 3657         UpdateOpenFileState(); | 3659         UpdateOpenFileState(); | 
| 3658       } else { | 3660       } else { | 
| 3659         NOTREACHED(); | 3661         NOTREACHED(); | 
| 3660       } | 3662       } | 
| 3661       break; | 3663       break; | 
| 3662     } | 3664     } | 
| 3663 | 3665 | 
| 3664     case NotificationType::TAB_CONTENT_SETTINGS_CHANGED: { | 3666     case chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED: { | 
| 3665       TabContents* tab_contents = Source<TabContents>(source).ptr(); | 3667       TabContents* tab_contents = Source<TabContents>(source).ptr(); | 
| 3666       if (tab_contents == GetSelectedTabContents()) { | 3668       if (tab_contents == GetSelectedTabContents()) { | 
| 3667         LocationBar* location_bar = window()->GetLocationBar(); | 3669         LocationBar* location_bar = window()->GetLocationBar(); | 
| 3668         if (location_bar) | 3670         if (location_bar) | 
| 3669           location_bar->UpdateContentSettingsIcons(); | 3671           location_bar->UpdateContentSettingsIcons(); | 
| 3670       } | 3672       } | 
| 3671       break; | 3673       break; | 
| 3672     } | 3674     } | 
| 3673 | 3675 | 
| 3674     case NotificationType::INTERSTITIAL_ATTACHED: | 3676     case content::NOTIFICATION_INTERSTITIAL_ATTACHED: | 
| 3675       UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 3677       UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 
| 3676       break; | 3678       break; | 
| 3677 | 3679 | 
| 3678     case NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: | 3680     case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: | 
| 3679       UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); | 3681       UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); | 
| 3680       break; | 3682       break; | 
| 3681 | 3683 | 
| 3682     default: | 3684     default: | 
| 3683       NOTREACHED() << "Got a notification we didn't register for."; | 3685       NOTREACHED() << "Got a notification we didn't register for."; | 
| 3684   } | 3686   } | 
| 3685 } | 3687 } | 
| 3686 | 3688 | 
| 3687 /////////////////////////////////////////////////////////////////////////////// | 3689 /////////////////////////////////////////////////////////////////////////////// | 
| 3688 // Browser, ProfileSyncServiceObserver implementation: | 3690 // Browser, ProfileSyncServiceObserver implementation: | 
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4539   } | 4541   } | 
| 4540 | 4542 | 
| 4541   if (is_attempting_to_close_browser_) { | 4543   if (is_attempting_to_close_browser_) { | 
| 4542     // If this is the last tab with unload handlers, then ProcessPendingTabs | 4544     // If this is the last tab with unload handlers, then ProcessPendingTabs | 
| 4543     // would call back into the TabStripModel (which is invoking this method on | 4545     // would call back into the TabStripModel (which is invoking this method on | 
| 4544     // us). Avoid that by passing in false so that the call to | 4546     // us). Avoid that by passing in false so that the call to | 
| 4545     // ProcessPendingTabs is delayed. | 4547     // ProcessPendingTabs is delayed. | 
| 4546     ClearUnloadState(contents->tab_contents(), false); | 4548     ClearUnloadState(contents->tab_contents(), false); | 
| 4547   } | 4549   } | 
| 4548 | 4550 | 
| 4549   registrar_.Remove(this, NotificationType::INTERSTITIAL_ATTACHED, | 4551   registrar_.Remove(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED, | 
| 4550                     Source<TabContents>(contents->tab_contents())); | 4552                     Source<TabContents>(contents->tab_contents())); | 
| 4551   registrar_.Remove(this, NotificationType::TAB_CONTENTS_DISCONNECTED, | 4553   registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED, | 
| 4552                     Source<TabContents>(contents->tab_contents())); | 4554                     Source<TabContents>(contents->tab_contents())); | 
| 4553 } | 4555 } | 
| 4554 | 4556 | 
| 4555 // static | 4557 // static | 
| 4556 void Browser::RegisterAppPrefs(const std::string& app_name, Profile* profile) { | 4558 void Browser::RegisterAppPrefs(const std::string& app_name, Profile* profile) { | 
| 4557   // We need to register the window position pref. | 4559   // We need to register the window position pref. | 
| 4558   std::string window_pref(prefs::kBrowserWindowPlacement); | 4560   std::string window_pref(prefs::kBrowserWindowPlacement); | 
| 4559   window_pref.append("_"); | 4561   window_pref.append("_"); | 
| 4560   window_pref.append(app_name); | 4562   window_pref.append(app_name); | 
| 4561   PrefService* prefs = profile->GetPrefs(); | 4563   PrefService* prefs = profile->GetPrefs(); | 
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4745     // end up querying state once they process the tab switch. | 4747     // end up querying state once they process the tab switch. | 
| 4746     return; | 4748     return; | 
| 4747   } | 4749   } | 
| 4748 | 4750 | 
| 4749   BookmarkBar::AnimateChangeType animate_type = | 4751   BookmarkBar::AnimateChangeType animate_type = | 
| 4750       (reason == BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE) ? | 4752       (reason == BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE) ? | 
| 4751       BookmarkBar::ANIMATE_STATE_CHANGE : | 4753       BookmarkBar::ANIMATE_STATE_CHANGE : | 
| 4752       BookmarkBar::DONT_ANIMATE_STATE_CHANGE; | 4754       BookmarkBar::DONT_ANIMATE_STATE_CHANGE; | 
| 4753   window_->BookmarkBarStateChanged(animate_type); | 4755   window_->BookmarkBarStateChanged(animate_type); | 
| 4754 } | 4756 } | 
| OLD | NEW | 
|---|