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 #include "chrome/browser/browser.h" | 5 #include "chrome/browser/browser.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "app/animation.h" | 10 #include "app/animation.h" |
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1769 session_service->TabRestored(&new_contents->controller(), pinned); | 1769 session_service->TabRestored(&new_contents->controller(), pinned); |
1770 } | 1770 } |
1771 } | 1771 } |
1772 | 1772 |
1773 void Browser::CloseFrameAfterDragSession() { | 1773 void Browser::CloseFrameAfterDragSession() { |
1774 #if defined(OS_WIN) || defined(OS_LINUX) | 1774 #if defined(OS_WIN) || defined(OS_LINUX) |
1775 // This is scheduled to run after we return to the message loop because | 1775 // This is scheduled to run after we return to the message loop because |
1776 // otherwise the frame will think the drag session is still active and ignore | 1776 // otherwise the frame will think the drag session is still active and ignore |
1777 // the request. | 1777 // the request. |
1778 // TODO(port): figure out what is required here in a cross-platform world | 1778 // TODO(port): figure out what is required here in a cross-platform world |
1779 MessageLoop::current()->PostTask(FROM_HERE, | 1779 MessageLoop::current()->PostTask( |
1780 method_factory_.NewRunnableMethod(&Browser::CloseFrame)); | 1780 FROM_HERE, method_factory_.NewRunnableMethod(&Browser::CloseFrame)); |
1781 #endif | 1781 #endif |
1782 } | 1782 } |
1783 | 1783 |
1784 void Browser::CreateHistoricalTab(TabContents* contents) { | 1784 void Browser::CreateHistoricalTab(TabContents* contents) { |
1785 // We don't create historical tabs for incognito windows or windows without | 1785 // We don't create historical tabs for incognito windows or windows without |
1786 // profiles. | 1786 // profiles. |
1787 if (!profile() || profile()->IsOffTheRecord() || | 1787 if (!profile() || profile()->IsOffTheRecord() || |
1788 !profile()->GetTabRestoreService()) { | 1788 !profile()->GetTabRestoreService()) { |
1789 return; | 1789 return; |
1790 } | 1790 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1955 | 1955 |
1956 void Browser::TabStripEmpty() { | 1956 void Browser::TabStripEmpty() { |
1957 // Close the frame after we return to the message loop (not immediately, | 1957 // Close the frame after we return to the message loop (not immediately, |
1958 // otherwise it will destroy this object before the stack has a chance to | 1958 // otherwise it will destroy this object before the stack has a chance to |
1959 // cleanly unwind.) | 1959 // cleanly unwind.) |
1960 // Note: This will be called several times if TabStripEmpty is called several | 1960 // Note: This will be called several times if TabStripEmpty is called several |
1961 // times. This is because it does not close the window if tabs are | 1961 // times. This is because it does not close the window if tabs are |
1962 // still present. | 1962 // still present. |
1963 // NOTE: If you change to be immediate (no invokeLater) then you'll need to | 1963 // NOTE: If you change to be immediate (no invokeLater) then you'll need to |
1964 // update BrowserList::CloseAllBrowsers. | 1964 // update BrowserList::CloseAllBrowsers. |
1965 MessageLoop::current()->PostTask(FROM_HERE, | 1965 MessageLoop::current()->PostTask( |
1966 method_factory_.NewRunnableMethod(&Browser::CloseFrame)); | 1966 FROM_HERE, method_factory_.NewRunnableMethod(&Browser::CloseFrame)); |
1967 } | 1967 } |
1968 | 1968 |
1969 /////////////////////////////////////////////////////////////////////////////// | 1969 /////////////////////////////////////////////////////////////////////////////// |
1970 // Browser, PageNavigator implementation: | 1970 // Browser, PageNavigator implementation: |
1971 void Browser::OpenURL(const GURL& url, const GURL& referrer, | 1971 void Browser::OpenURL(const GURL& url, const GURL& referrer, |
1972 WindowOpenDisposition disposition, | 1972 WindowOpenDisposition disposition, |
1973 PageTransition::Type transition) { | 1973 PageTransition::Type transition) { |
1974 OpenURLFromTab(NULL, url, referrer, disposition, transition); | 1974 OpenURLFromTab(NULL, url, referrer, disposition, transition); |
1975 } | 1975 } |
1976 | 1976 |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2364 // Browser, NotificationObserver implementation: | 2364 // Browser, NotificationObserver implementation: |
2365 | 2365 |
2366 void Browser::Observe(NotificationType type, | 2366 void Browser::Observe(NotificationType type, |
2367 const NotificationSource& source, | 2367 const NotificationSource& source, |
2368 const NotificationDetails& details) { | 2368 const NotificationDetails& details) { |
2369 switch (type.value) { | 2369 switch (type.value) { |
2370 case NotificationType::TAB_CONTENTS_DISCONNECTED: | 2370 case NotificationType::TAB_CONTENTS_DISCONNECTED: |
2371 if (is_attempting_to_close_browser_) { | 2371 if (is_attempting_to_close_browser_) { |
2372 // Need to do this asynchronously as it will close the tab, which is | 2372 // Need to do this asynchronously as it will close the tab, which is |
2373 // currently on the call stack above us. | 2373 // currently on the call stack above us. |
2374 MessageLoop::current()->PostTask(FROM_HERE, | 2374 MessageLoop::current()->PostTask( |
| 2375 FROM_HERE, |
2375 method_factory_.NewRunnableMethod(&Browser::ClearUnloadState, | 2376 method_factory_.NewRunnableMethod(&Browser::ClearUnloadState, |
2376 Source<TabContents>(source).ptr())); | 2377 Source<TabContents>(source).ptr())); |
2377 } | 2378 } |
2378 break; | 2379 break; |
2379 | 2380 |
2380 case NotificationType::SSL_VISIBLE_STATE_CHANGED: | 2381 case NotificationType::SSL_VISIBLE_STATE_CHANGED: |
2381 // When the current tab's SSL state changes, we need to update the URL | 2382 // When the current tab's SSL state changes, we need to update the URL |
2382 // bar to reflect the new state. Note that it's possible for the selected | 2383 // bar to reflect the new state. Note that it's possible for the selected |
2383 // tab contents to be NULL. This is because we listen for all sources | 2384 // tab contents to be NULL. This is because we listen for all sources |
2384 // (NavigationControllers) for convenience, so the notification could | 2385 // (NavigationControllers) for convenience, so the notification could |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2770 | 2771 |
2771 // If the only updates were synchronously handled above, we're done. | 2772 // If the only updates were synchronously handled above, we're done. |
2772 if (changed_flags == 0) | 2773 if (changed_flags == 0) |
2773 return; | 2774 return; |
2774 | 2775 |
2775 // Save the dirty bits. | 2776 // Save the dirty bits. |
2776 scheduled_updates_[source] |= changed_flags; | 2777 scheduled_updates_[source] |= changed_flags; |
2777 | 2778 |
2778 if (chrome_updater_factory_.empty()) { | 2779 if (chrome_updater_factory_.empty()) { |
2779 // No task currently scheduled, start another. | 2780 // No task currently scheduled, start another. |
2780 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 2781 MessageLoop::current()->PostDelayedTask( |
| 2782 FROM_HERE, |
2781 chrome_updater_factory_.NewRunnableMethod( | 2783 chrome_updater_factory_.NewRunnableMethod( |
2782 &Browser::ProcessPendingUIUpdates), | 2784 &Browser::ProcessPendingUIUpdates), |
2783 kUIUpdateCoalescingTimeMS); | 2785 kUIUpdateCoalescingTimeMS); |
2784 } | 2786 } |
2785 } | 2787 } |
2786 | 2788 |
2787 void Browser::ProcessPendingUIUpdates() { | 2789 void Browser::ProcessPendingUIUpdates() { |
2788 #ifndef NDEBUG | 2790 #ifndef NDEBUG |
2789 // Validate that all tabs we have pending updates for exist. This is scary | 2791 // Validate that all tabs we have pending updates for exist. This is scary |
2790 // because the pending list must be kept in sync with any detached or | 2792 // because the pending list must be kept in sync with any detached or |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3273 return; | 3275 return; |
3274 | 3276 |
3275 ExtensionsService* extension_service = profile()->GetExtensionsService(); | 3277 ExtensionsService* extension_service = profile()->GetExtensionsService(); |
3276 if (extension_service && extension_service->is_ready()) { | 3278 if (extension_service && extension_service->is_ready()) { |
3277 Extension* extension = | 3279 Extension* extension = |
3278 extension_service->GetExtensionById(app_extension_id, false); | 3280 extension_service->GetExtensionById(app_extension_id, false); |
3279 if (extension) | 3281 if (extension) |
3280 contents->SetAppExtension(extension); | 3282 contents->SetAppExtension(extension); |
3281 } | 3283 } |
3282 } | 3284 } |
3283 | |
OLD | NEW |