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 // OS_WIN | 10 #endif // OS_WIN |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "chrome/browser/debugger/devtools_toggle_action.h" | 42 #include "chrome/browser/debugger/devtools_toggle_action.h" |
43 #include "chrome/browser/debugger/devtools_window.h" | 43 #include "chrome/browser/debugger/devtools_window.h" |
44 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 44 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
45 #include "chrome/browser/download/download_item_model.h" | 45 #include "chrome/browser/download/download_item_model.h" |
46 #include "chrome/browser/download/download_service.h" | 46 #include "chrome/browser/download/download_service.h" |
47 #include "chrome/browser/download/download_service_factory.h" | 47 #include "chrome/browser/download/download_service_factory.h" |
48 #include "chrome/browser/download/download_started_animation.h" | 48 #include "chrome/browser/download/download_started_animation.h" |
49 #include "chrome/browser/download/download_util.h" | 49 #include "chrome/browser/download/download_util.h" |
50 #include "chrome/browser/extensions/crx_installer.h" | 50 #include "chrome/browser/extensions/crx_installer.h" |
51 #include "chrome/browser/extensions/default_apps_trial.h" | 51 #include "chrome/browser/extensions/default_apps_trial.h" |
| 52 #include "chrome/browser/extensions/browser_extension_window_controller.h" |
52 #include "chrome/browser/extensions/extension_browser_event_router.h" | 53 #include "chrome/browser/extensions/extension_browser_event_router.h" |
53 #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h" | 54 #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h" |
54 #include "chrome/browser/extensions/extension_prefs.h" | 55 #include "chrome/browser/extensions/extension_prefs.h" |
55 #include "chrome/browser/extensions/extension_service.h" | 56 #include "chrome/browser/extensions/extension_service.h" |
56 #include "chrome/browser/extensions/extension_tab_helper.h" | 57 #include "chrome/browser/extensions/extension_tab_helper.h" |
57 #include "chrome/browser/extensions/extension_tabs_module.h" | 58 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 59 #include "chrome/browser/extensions/extension_window_list.h" |
58 #include "chrome/browser/favicon/favicon_tab_helper.h" | 60 #include "chrome/browser/favicon/favicon_tab_helper.h" |
59 #include "chrome/browser/file_select_helper.h" | 61 #include "chrome/browser/file_select_helper.h" |
60 #include "chrome/browser/first_run/first_run.h" | 62 #include "chrome/browser/first_run/first_run.h" |
61 #include "chrome/browser/google/google_url_tracker.h" | 63 #include "chrome/browser/google/google_url_tracker.h" |
62 #include "chrome/browser/infobars/infobar_tab_helper.h" | 64 #include "chrome/browser/infobars/infobar_tab_helper.h" |
63 #include "chrome/browser/instant/instant_controller.h" | 65 #include "chrome/browser/instant/instant_controller.h" |
64 #include "chrome/browser/instant/instant_unload_handler.h" | 66 #include "chrome/browser/instant/instant_unload_handler.h" |
65 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" | 67 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" |
66 #include "chrome/browser/intents/web_intents_registry_factory.h" | 68 #include "chrome/browser/intents/web_intents_registry_factory.h" |
67 #include "chrome/browser/intents/web_intents_util.h" | 69 #include "chrome/browser/intents/web_intents_util.h" |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 ProfileMetrics::LogProfileLaunch(profile_path); | 422 ProfileMetrics::LogProfileLaunch(profile_path); |
421 } | 423 } |
422 | 424 |
423 Browser::~Browser() { | 425 Browser::~Browser() { |
424 ProfileSyncService* service = | 426 ProfileSyncService* service = |
425 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); | 427 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); |
426 if (service) | 428 if (service) |
427 service->RemoveObserver(this); | 429 service->RemoveObserver(this); |
428 | 430 |
429 BrowserList::RemoveBrowser(this); | 431 BrowserList::RemoveBrowser(this); |
| 432 if (extension_window_controller_.get()) { |
| 433 ExtensionWindowList::GetInstance()->RemoveExtensionWindow( |
| 434 extension_window_controller_.get()); |
| 435 } |
430 | 436 |
431 #if !defined(OS_MACOSX) | 437 #if !defined(OS_MACOSX) |
432 if (!BrowserList::HasBrowserWithProfile(profile_)) { | 438 if (!BrowserList::HasBrowserWithProfile(profile_)) { |
433 // We're the last browser window with this profile. We need to nuke the | 439 // We're the last browser window with this profile. We need to nuke the |
434 // TabRestoreService, which will start the shutdown of the | 440 // TabRestoreService, which will start the shutdown of the |
435 // NavigationControllers and allow for proper shutdown. If we don't do this | 441 // NavigationControllers and allow for proper shutdown. If we don't do this |
436 // chrome won't shutdown cleanly, and may end up crashing when some | 442 // chrome won't shutdown cleanly, and may end up crashing when some |
437 // thread tries to use the IO thread (or another thread) that is no longer | 443 // thread tries to use the IO thread (or another thread) that is no longer |
438 // valid. | 444 // valid. |
439 // This isn't a valid assumption for Mac OS, as it stays running after | 445 // This isn't a valid assumption for Mac OS, as it stays running after |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 ShellIntegration::GetAppId(UTF8ToWide(app_name_), profile_->GetPath()) : | 567 ShellIntegration::GetAppId(UTF8ToWide(app_name_), profile_->GetPath()) : |
562 ShellIntegration::GetChromiumAppId(profile_->GetPath()), | 568 ShellIntegration::GetChromiumAppId(profile_->GetPath()), |
563 window()->GetNativeHandle()); | 569 window()->GetNativeHandle()); |
564 | 570 |
565 if (is_type_panel()) { | 571 if (is_type_panel()) { |
566 ui::win::SetAppIconForWindow(ShellIntegration::GetChromiumIconPath(), | 572 ui::win::SetAppIconForWindow(ShellIntegration::GetChromiumIconPath(), |
567 window()->GetNativeHandle()); | 573 window()->GetNativeHandle()); |
568 } | 574 } |
569 #endif | 575 #endif |
570 | 576 |
| 577 // Add the browser to the list of windows available to the extension API. |
| 578 // (Before sending notifications). |
| 579 extension_window_controller_.reset( |
| 580 new BrowserExtensionWindowController(this)); |
| 581 ExtensionWindowList::GetInstance()->AddExtensionWindow( |
| 582 extension_window_controller_.get()); |
| 583 |
571 content::NotificationService::current()->Notify( | 584 content::NotificationService::current()->Notify( |
572 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 585 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
573 content::Source<Browser>(this), | 586 content::Source<Browser>(this), |
574 content::NotificationService::NoDetails()); | 587 content::NotificationService::NoDetails()); |
575 | 588 |
576 PrefService* local_state = g_browser_process->local_state(); | 589 PrefService* local_state = g_browser_process->local_state(); |
577 if (local_state && local_state->FindPreference( | 590 if (local_state && local_state->FindPreference( |
578 prefs::kAutofillPersonalDataManagerFirstRun) && | 591 prefs::kAutofillPersonalDataManagerFirstRun) && |
579 local_state->GetBoolean(prefs::kAutofillPersonalDataManagerFirstRun)) { | 592 local_state->GetBoolean(prefs::kAutofillPersonalDataManagerFirstRun)) { |
580 // Notify PDM that this is a first run. | 593 // Notify PDM that this is a first run. |
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 tab_handler_->GetTabStripModel()->DetachTabContentsAt(active_index()); | 1848 tab_handler_->GetTabStripModel()->DetachTabContentsAt(active_index()); |
1836 Browser* browser = Browser::Create(profile_); | 1849 Browser* browser = Browser::Create(profile_); |
1837 browser->tabstrip_model()->AppendTabContents(contents, true); | 1850 browser->tabstrip_model()->AppendTabContents(contents, true); |
1838 browser->window()->Show(); | 1851 browser->window()->Show(); |
1839 } | 1852 } |
1840 | 1853 |
1841 void Browser::ToggleFullscreenMode() { | 1854 void Browser::ToggleFullscreenMode() { |
1842 fullscreen_controller_->ToggleFullscreenMode(); | 1855 fullscreen_controller_->ToggleFullscreenMode(); |
1843 } | 1856 } |
1844 | 1857 |
1845 void Browser::ToggleFullscreenModeWithExtension(const Extension& extension) { | 1858 void Browser::ToggleFullscreenModeWithExtension(const GURL& extension_url) { |
1846 fullscreen_controller_->ToggleFullscreenModeWithExtension(extension); | 1859 fullscreen_controller_->ToggleFullscreenModeWithExtension(extension_url); |
1847 } | 1860 } |
1848 | 1861 |
1849 #if defined(OS_MACOSX) | 1862 #if defined(OS_MACOSX) |
1850 void Browser::TogglePresentationMode() { | 1863 void Browser::TogglePresentationMode() { |
1851 fullscreen_controller_->TogglePresentationMode(); | 1864 fullscreen_controller_->TogglePresentationMode(); |
1852 } | 1865 } |
1853 #endif | 1866 #endif |
1854 | 1867 |
1855 #if defined(OS_CHROMEOS) | 1868 #if defined(OS_CHROMEOS) |
1856 void Browser::Search() { | 1869 void Browser::Search() { |
(...skipping 3719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5576 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; | 5589 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
5577 ShowSingletonTabOverwritingNTP(params); | 5590 ShowSingletonTabOverwritingNTP(params); |
5578 } else { | 5591 } else { |
5579 service->ShowLoginDialog(); | 5592 service->ShowLoginDialog(); |
5580 } | 5593 } |
5581 } | 5594 } |
5582 | 5595 |
5583 void Browser::ToggleSpeechInput() { | 5596 void Browser::ToggleSpeechInput() { |
5584 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); | 5597 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); |
5585 } | 5598 } |
OLD | NEW |