| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 116 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 117 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 117 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| 118 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 118 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| 119 #include "chrome/browser/ui/global_error/global_error.h" | 119 #include "chrome/browser/ui/global_error/global_error.h" |
| 120 #include "chrome/browser/ui/global_error/global_error_service.h" | 120 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 121 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 121 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 122 #include "chrome/browser/ui/hung_plugin_tab_helper.h" | 122 #include "chrome/browser/ui/hung_plugin_tab_helper.h" |
| 123 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | 123 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
| 124 #include "chrome/browser/ui/media_stream_infobar_delegate.h" | 124 #include "chrome/browser/ui/media_stream_infobar_delegate.h" |
| 125 #include "chrome/browser/ui/omnibox/location_bar.h" | 125 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 126 #include "chrome/browser/ui/panels/panel.h" | |
| 127 #include "chrome/browser/ui/panels/panel_manager.h" | |
| 128 #include "chrome/browser/ui/search/search.h" | 126 #include "chrome/browser/ui/search/search.h" |
| 129 #include "chrome/browser/ui/search/search_delegate.h" | 127 #include "chrome/browser/ui/search/search_delegate.h" |
| 130 #include "chrome/browser/ui/search/search_model.h" | 128 #include "chrome/browser/ui/search/search_model.h" |
| 131 #include "chrome/browser/ui/singleton_tabs.h" | 129 #include "chrome/browser/ui/singleton_tabs.h" |
| 132 #include "chrome/browser/ui/status_bubble.h" | 130 #include "chrome/browser/ui/status_bubble.h" |
| 133 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h" | 131 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h" |
| 134 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 132 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 135 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 133 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 136 #include "chrome/browser/ui/tabs/dock_info.h" | 134 #include "chrome/browser/ui/tabs/dock_info.h" |
| 137 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 135 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 const char kBrokenPageUrl[] = | 231 const char kBrokenPageUrl[] = |
| 234 "https://www.google.com/support/chrome/bin/request.py?contact_type=" | 232 "https://www.google.com/support/chrome/bin/request.py?contact_type=" |
| 235 "broken_website&format=inproduct&p.page_title=$1&p.page_url=$2"; | 233 "broken_website&format=inproduct&p.page_title=$1&p.page_url=$2"; |
| 236 | 234 |
| 237 // The URL for the privacy dashboard. | 235 // The URL for the privacy dashboard. |
| 238 const char kPrivacyDashboardUrl[] = "https://www.google.com/dashboard"; | 236 const char kPrivacyDashboardUrl[] = "https://www.google.com/dashboard"; |
| 239 | 237 |
| 240 // How long we wait before updating the browser chrome while loading a page. | 238 // How long we wait before updating the browser chrome while loading a page. |
| 241 const int kUIUpdateCoalescingTimeMS = 200; | 239 const int kUIUpdateCoalescingTimeMS = 200; |
| 242 | 240 |
| 243 bool AllowPanels(const std::string& app_name) { | |
| 244 return PanelManager::ShouldUsePanels( | |
| 245 web_app::GetExtensionIdFromApplicationName(app_name)); | |
| 246 } | |
| 247 | |
| 248 BrowserWindow* CreateBrowserWindow(Browser* browser) { | 241 BrowserWindow* CreateBrowserWindow(Browser* browser) { |
| 249 #if !defined(USE_ASH) | |
| 250 if (browser->is_type_panel()) | |
| 251 return PanelManager::GetInstance()->CreatePanel(browser)->browser_window(); | |
| 252 #endif | |
| 253 return BrowserWindow::CreateBrowserWindow(browser); | 242 return BrowserWindow::CreateBrowserWindow(browser); |
| 254 } | 243 } |
| 255 | 244 |
| 256 #if defined(OS_CHROMEOS) | 245 #if defined(OS_CHROMEOS) |
| 257 chrome::HostDesktopType kDefaultHostDesktopType = chrome::HOST_DESKTOP_TYPE_ASH; | 246 chrome::HostDesktopType kDefaultHostDesktopType = chrome::HOST_DESKTOP_TYPE_ASH; |
| 258 #else | 247 #else |
| 259 chrome::HostDesktopType kDefaultHostDesktopType = | 248 chrome::HostDesktopType kDefaultHostDesktopType = |
| 260 chrome::HOST_DESKTOP_TYPE_NATIVE; | 249 chrome::HOST_DESKTOP_TYPE_NATIVE; |
| 261 #endif | 250 #endif |
| 262 | 251 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 299 |
| 311 // static | 300 // static |
| 312 Browser::CreateParams Browser::CreateParams::CreateForApp( | 301 Browser::CreateParams Browser::CreateParams::CreateForApp( |
| 313 Type type, | 302 Type type, |
| 314 const std::string& app_name, | 303 const std::string& app_name, |
| 315 const gfx::Rect& window_bounds, | 304 const gfx::Rect& window_bounds, |
| 316 Profile* profile) { | 305 Profile* profile) { |
| 317 DCHECK(type != TYPE_TABBED); | 306 DCHECK(type != TYPE_TABBED); |
| 318 DCHECK(!app_name.empty()); | 307 DCHECK(!app_name.empty()); |
| 319 | 308 |
| 320 if (type == TYPE_PANEL && !AllowPanels(app_name)) | |
| 321 type = TYPE_POPUP; | |
| 322 | |
| 323 CreateParams params(type, profile); | 309 CreateParams params(type, profile); |
| 324 params.app_name = app_name; | 310 params.app_name = app_name; |
| 325 params.app_type = APP_TYPE_CHILD; | 311 params.app_type = APP_TYPE_CHILD; |
| 326 params.initial_bounds = window_bounds; | 312 params.initial_bounds = window_bounds; |
| 327 | 313 |
| 328 return params; | 314 return params; |
| 329 } | 315 } |
| 330 | 316 |
| 331 // static | 317 // static |
| 332 Browser::CreateParams Browser::CreateParams::CreateForDevTools( | 318 Browser::CreateParams Browser::CreateParams::CreateForDevTools( |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1443 | 1429 |
| 1444 if (!window()) | 1430 if (!window()) |
| 1445 return; | 1431 return; |
| 1446 | 1432 |
| 1447 // GetDownloadShelf creates the download shelf if it was not yet created. | 1433 // GetDownloadShelf creates the download shelf if it was not yet created. |
| 1448 DownloadShelf* shelf = window()->GetDownloadShelf(); | 1434 DownloadShelf* shelf = window()->GetDownloadShelf(); |
| 1449 shelf->AddDownload(new DownloadItemModel(download)); | 1435 shelf->AddDownload(new DownloadItemModel(download)); |
| 1450 // Don't show the animation for "Save file" downloads. | 1436 // Don't show the animation for "Save file" downloads. |
| 1451 // For non-theme extensions, we don't show the download animation. | 1437 // For non-theme extensions, we don't show the download animation. |
| 1452 // Show animation in same window as the download shelf. Download shelf | 1438 // Show animation in same window as the download shelf. Download shelf |
| 1453 // may not be in the same window that initiated the download, e.g. | 1439 // may not be in the same window that initiated the download. |
| 1454 // Panels. | |
| 1455 // Don't show the animation if the selected tab is not visible (i.e. the | 1440 // Don't show the animation if the selected tab is not visible (i.e. the |
| 1456 // window is minimized, we're in a unit test, etc.). | 1441 // window is minimized, we're in a unit test, etc.). |
| 1457 WebContents* shelf_tab = chrome::GetActiveWebContents(shelf->browser()); | 1442 WebContents* shelf_tab = chrome::GetActiveWebContents(shelf->browser()); |
| 1458 if ((download->GetTotalBytes() > 0) && | 1443 if ((download->GetTotalBytes() > 0) && |
| 1459 !download_crx_util::IsExtensionDownload(*download) && | 1444 !download_crx_util::IsExtensionDownload(*download) && |
| 1460 platform_util::IsVisible(shelf_tab->GetNativeView()) && | 1445 platform_util::IsVisible(shelf_tab->GetNativeView()) && |
| 1461 ui::Animation::ShouldRenderRichAnimation()) { | 1446 ui::Animation::ShouldRenderRichAnimation()) { |
| 1462 DownloadStartedAnimation::Show(shelf_tab); | 1447 DownloadStartedAnimation::Show(shelf_tab); |
| 1463 } | 1448 } |
| 1464 | 1449 |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 | 1816 |
| 1832 // Close any tabs from the unloaded extension, unless it's terminated, | 1817 // Close any tabs from the unloaded extension, unless it's terminated, |
| 1833 // in which case let the sad tabs remain. | 1818 // in which case let the sad tabs remain. |
| 1834 if (content::Details<extensions::UnloadedExtensionInfo>( | 1819 if (content::Details<extensions::UnloadedExtensionInfo>( |
| 1835 details)->reason != extension_misc::UNLOAD_REASON_TERMINATE) { | 1820 details)->reason != extension_misc::UNLOAD_REASON_TERMINATE) { |
| 1836 const Extension* extension = | 1821 const Extension* extension = |
| 1837 content::Details<extensions::UnloadedExtensionInfo>( | 1822 content::Details<extensions::UnloadedExtensionInfo>( |
| 1838 details)->extension; | 1823 details)->extension; |
| 1839 for (int i = tab_strip_model_->count() - 1; i >= 0; --i) { | 1824 for (int i = tab_strip_model_->count() - 1; i >= 0; --i) { |
| 1840 WebContents* tc = chrome::GetTabContentsAt(this, i)->web_contents(); | 1825 WebContents* tc = chrome::GetTabContentsAt(this, i)->web_contents(); |
| 1841 bool close_tab_contents = | 1826 if (tc->GetURL().SchemeIs(chrome::kExtensionScheme) && |
| 1842 tc->GetURL().SchemeIs(chrome::kExtensionScheme) && | 1827 tc->GetURL().host() == extension->id()) |
| 1843 tc->GetURL().host() == extension->id(); | |
| 1844 // We want to close all panels originated by the unloaded extension. | |
| 1845 close_tab_contents = close_tab_contents || | |
| 1846 (type_ == TYPE_PANEL && | |
| 1847 (web_app::GetExtensionIdFromApplicationName(app_name_) == | |
| 1848 extension->id())); | |
| 1849 if (close_tab_contents) | |
| 1850 chrome::CloseWebContents(this, tc); | 1828 chrome::CloseWebContents(this, tc); |
| 1851 } | 1829 } |
| 1852 } | 1830 } |
| 1853 break; | 1831 break; |
| 1854 } | 1832 } |
| 1855 | 1833 |
| 1856 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { | 1834 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { |
| 1857 Profile* profile = content::Source<Profile>(source).ptr(); | 1835 Profile* profile = content::Source<Profile>(source).ptr(); |
| 1858 if (profile_->IsSameProfile(profile) && window()->GetLocationBar()) | 1836 if (profile_->IsSameProfile(profile) && window()->GetLocationBar()) |
| 1859 window()->GetLocationBar()->InvalidatePageActions(); | 1837 window()->GetLocationBar()->InvalidatePageActions(); |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2299 if (contents && !allow_js_access) { | 2277 if (contents && !allow_js_access) { |
| 2300 contents->web_contents()->GetController().LoadURL( | 2278 contents->web_contents()->GetController().LoadURL( |
| 2301 target_url, | 2279 target_url, |
| 2302 content::Referrer(), | 2280 content::Referrer(), |
| 2303 content::PAGE_TRANSITION_LINK, | 2281 content::PAGE_TRANSITION_LINK, |
| 2304 std::string()); // No extra headers. | 2282 std::string()); // No extra headers. |
| 2305 } | 2283 } |
| 2306 | 2284 |
| 2307 return contents != NULL; | 2285 return contents != NULL; |
| 2308 } | 2286 } |
| OLD | NEW |