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_wrapper.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" |
58 #include "chrome/browser/favicon/favicon_tab_helper.h" | 59 #include "chrome/browser/favicon/favicon_tab_helper.h" |
59 #include "chrome/browser/file_select_helper.h" | 60 #include "chrome/browser/file_select_helper.h" |
60 #include "chrome/browser/first_run/first_run.h" | 61 #include "chrome/browser/first_run/first_run.h" |
61 #include "chrome/browser/google/google_url_tracker.h" | 62 #include "chrome/browser/google/google_url_tracker.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 ProfileMetrics::LogProfileLaunch(profile_path); | 420 ProfileMetrics::LogProfileLaunch(profile_path); |
420 } | 421 } |
421 | 422 |
422 Browser::~Browser() { | 423 Browser::~Browser() { |
423 ProfileSyncService* service = | 424 ProfileSyncService* service = |
424 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); | 425 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); |
425 if (service) | 426 if (service) |
426 service->RemoveObserver(this); | 427 service->RemoveObserver(this); |
427 | 428 |
428 BrowserList::RemoveBrowser(this); | 429 BrowserList::RemoveBrowser(this); |
| 430 if (extension_window_wrapper_.get()) { |
| 431 ExtensionWindowWrapperList::GetInstance()->RemoveExtensionWindow( |
| 432 extension_window_wrapper_.get()); |
| 433 } |
429 | 434 |
430 #if !defined(OS_MACOSX) | 435 #if !defined(OS_MACOSX) |
431 if (!BrowserList::HasBrowserWithProfile(profile_)) { | 436 if (!BrowserList::HasBrowserWithProfile(profile_)) { |
432 // We're the last browser window with this profile. We need to nuke the | 437 // We're the last browser window with this profile. We need to nuke the |
433 // TabRestoreService, which will start the shutdown of the | 438 // TabRestoreService, which will start the shutdown of the |
434 // NavigationControllers and allow for proper shutdown. If we don't do this | 439 // NavigationControllers and allow for proper shutdown. If we don't do this |
435 // chrome won't shutdown cleanly, and may end up crashing when some | 440 // chrome won't shutdown cleanly, and may end up crashing when some |
436 // thread tries to use the IO thread (or another thread) that is no longer | 441 // thread tries to use the IO thread (or another thread) that is no longer |
437 // valid. | 442 // valid. |
438 // This isn't a valid assumption for Mac OS, as it stays running after | 443 // 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... |
560 ShellIntegration::GetAppId(UTF8ToWide(app_name_), profile_->GetPath()) : | 565 ShellIntegration::GetAppId(UTF8ToWide(app_name_), profile_->GetPath()) : |
561 ShellIntegration::GetChromiumAppId(profile_->GetPath()), | 566 ShellIntegration::GetChromiumAppId(profile_->GetPath()), |
562 window()->GetNativeHandle()); | 567 window()->GetNativeHandle()); |
563 | 568 |
564 if (is_type_panel()) { | 569 if (is_type_panel()) { |
565 ui::win::SetAppIconForWindow(ShellIntegration::GetChromiumIconPath(), | 570 ui::win::SetAppIconForWindow(ShellIntegration::GetChromiumIconPath(), |
566 window()->GetNativeHandle()); | 571 window()->GetNativeHandle()); |
567 } | 572 } |
568 #endif | 573 #endif |
569 | 574 |
| 575 // Add the browser to the list of windows available to the extension API. |
| 576 // (Before sending notifications). |
| 577 extension_window_wrapper_.reset(new BrowserExtensionWindowWrapper(this)); |
| 578 ExtensionWindowWrapperList::GetInstance()->AddExtensionWindow( |
| 579 extension_window_wrapper_.get()); |
| 580 |
570 content::NotificationService::current()->Notify( | 581 content::NotificationService::current()->Notify( |
571 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 582 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
572 content::Source<Browser>(this), | 583 content::Source<Browser>(this), |
573 content::NotificationService::NoDetails()); | 584 content::NotificationService::NoDetails()); |
574 | 585 |
575 PrefService* local_state = g_browser_process->local_state(); | 586 PrefService* local_state = g_browser_process->local_state(); |
576 if (local_state && local_state->FindPreference( | 587 if (local_state && local_state->FindPreference( |
577 prefs::kAutofillPersonalDataManagerFirstRun) && | 588 prefs::kAutofillPersonalDataManagerFirstRun) && |
578 local_state->GetBoolean(prefs::kAutofillPersonalDataManagerFirstRun)) { | 589 local_state->GetBoolean(prefs::kAutofillPersonalDataManagerFirstRun)) { |
579 // Notify PDM that this is a first run. | 590 // Notify PDM that this is a first run. |
(...skipping 4975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5555 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; | 5566 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
5556 ShowSingletonTabOverwritingNTP(params); | 5567 ShowSingletonTabOverwritingNTP(params); |
5557 } else { | 5568 } else { |
5558 service->ShowLoginDialog(); | 5569 service->ShowLoginDialog(); |
5559 } | 5570 } |
5560 } | 5571 } |
5561 | 5572 |
5562 void Browser::ToggleSpeechInput() { | 5573 void Browser::ToggleSpeechInput() { |
5563 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); | 5574 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); |
5564 } | 5575 } |
OLD | NEW |