OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "chrome/browser/character_encoding.h" | 41 #include "chrome/browser/character_encoding.h" |
42 #include "chrome/browser/chrome_notification_types.h" | 42 #include "chrome/browser/chrome_notification_types.h" |
43 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 43 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
44 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 44 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
45 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 45 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
46 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" | 46 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" |
47 #include "chrome/browser/custom_handlers/register_protocol_handler_permission_re
quest.h" | 47 #include "chrome/browser/custom_handlers/register_protocol_handler_permission_re
quest.h" |
48 #include "chrome/browser/defaults.h" | 48 #include "chrome/browser/defaults.h" |
49 #include "chrome/browser/devtools/devtools_toggle_action.h" | 49 #include "chrome/browser/devtools/devtools_toggle_action.h" |
50 #include "chrome/browser/devtools/devtools_window.h" | 50 #include "chrome/browser/devtools/devtools_window.h" |
51 #include "chrome/browser/download/download_item_model.h" | |
52 #include "chrome/browser/download/download_service.h" | 51 #include "chrome/browser/download/download_service.h" |
53 #include "chrome/browser/download/download_service_factory.h" | 52 #include "chrome/browser/download/download_service_factory.h" |
54 #include "chrome/browser/download/download_shelf.h" | |
55 #include "chrome/browser/extensions/api/tabs/tabs_event_router.h" | 53 #include "chrome/browser/extensions/api/tabs/tabs_event_router.h" |
56 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" | 54 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" |
57 #include "chrome/browser/extensions/browser_extension_window_controller.h" | 55 #include "chrome/browser/extensions/browser_extension_window_controller.h" |
58 #include "chrome/browser/extensions/extension_service.h" | 56 #include "chrome/browser/extensions/extension_service.h" |
59 #include "chrome/browser/extensions/extension_ui_util.h" | 57 #include "chrome/browser/extensions/extension_ui_util.h" |
60 #include "chrome/browser/extensions/extension_util.h" | 58 #include "chrome/browser/extensions/extension_util.h" |
61 #include "chrome/browser/extensions/tab_helper.h" | 59 #include "chrome/browser/extensions/tab_helper.h" |
62 #include "chrome/browser/file_select_helper.h" | 60 #include "chrome/browser/file_select_helper.h" |
63 #include "chrome/browser/first_run/first_run.h" | 61 #include "chrome/browser/first_run/first_run.h" |
64 #include "chrome/browser/history/top_sites_factory.h" | 62 #include "chrome/browser/history/top_sites_factory.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 #include "components/history/core/browser/top_sites.h" | 160 #include "components/history/core/browser/top_sites.h" |
163 #include "components/infobars/core/simple_alert_infobar_delegate.h" | 161 #include "components/infobars/core/simple_alert_infobar_delegate.h" |
164 #include "components/search/search.h" | 162 #include "components/search/search.h" |
165 #include "components/sessions/session_types.h" | 163 #include "components/sessions/session_types.h" |
166 #include "components/startup_metric_utils/startup_metric_utils.h" | 164 #include "components/startup_metric_utils/startup_metric_utils.h" |
167 #include "components/translate/core/browser/language_state.h" | 165 #include "components/translate/core/browser/language_state.h" |
168 #include "components/ui/zoom/zoom_controller.h" | 166 #include "components/ui/zoom/zoom_controller.h" |
169 #include "components/web_modal/popup_manager.h" | 167 #include "components/web_modal/popup_manager.h" |
170 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 168 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
171 #include "content/public/browser/devtools_agent_host.h" | 169 #include "content/public/browser/devtools_agent_host.h" |
172 #include "content/public/browser/download_item.h" | |
173 #include "content/public/browser/download_manager.h" | |
174 #include "content/public/browser/interstitial_page.h" | 170 #include "content/public/browser/interstitial_page.h" |
175 #include "content/public/browser/invalidate_type.h" | 171 #include "content/public/browser/invalidate_type.h" |
176 #include "content/public/browser/navigation_controller.h" | 172 #include "content/public/browser/navigation_controller.h" |
177 #include "content/public/browser/navigation_entry.h" | 173 #include "content/public/browser/navigation_entry.h" |
178 #include "content/public/browser/notification_details.h" | 174 #include "content/public/browser/notification_details.h" |
179 #include "content/public/browser/notification_service.h" | 175 #include "content/public/browser/notification_service.h" |
180 #include "content/public/browser/plugin_service.h" | 176 #include "content/public/browser/plugin_service.h" |
181 #include "content/public/browser/render_process_host.h" | 177 #include "content/public/browser/render_process_host.h" |
182 #include "content/public/browser/render_view_host.h" | 178 #include "content/public/browser/render_view_host.h" |
183 #include "content/public/browser/render_widget_host_view.h" | 179 #include "content/public/browser/render_widget_host_view.h" |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 GlobalErrorServiceFactory::GetForProfile(profile()); | 1394 GlobalErrorServiceFactory::GetForProfile(profile()); |
1399 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 1395 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
1400 if (error) | 1396 if (error) |
1401 error->ShowBubbleView(this); | 1397 error->ShowBubbleView(this); |
1402 } | 1398 } |
1403 | 1399 |
1404 void Browser::ShowFirstRunBubble() { | 1400 void Browser::ShowFirstRunBubble() { |
1405 window()->GetLocationBar()->ShowFirstRunBubble(); | 1401 window()->GetLocationBar()->ShowFirstRunBubble(); |
1406 } | 1402 } |
1407 | 1403 |
1408 void Browser::ShowDownload(content::DownloadItem* download) { | |
1409 if (!window()) | |
1410 return; | |
1411 | |
1412 // If the download occurs in a new tab, and it's not a save page | |
1413 // download (started before initial navigation completed) close it. | |
1414 // Avoid calling CloseContents if the tab is not in this browser's tab strip | |
1415 // model; this can happen if the download was initiated by something internal | |
1416 // to Chrome, such as by the app list. | |
1417 WebContents* source = download->GetWebContents(); | |
1418 if (source && source->GetController().IsInitialNavigation() && | |
1419 tab_strip_model_->count() > 1 && | |
1420 tab_strip_model_->GetIndexOfWebContents(source) != | |
1421 TabStripModel::kNoTab && | |
1422 !download->IsSavePackageDownload()) { | |
1423 CloseContents(source); | |
1424 } | |
1425 | |
1426 // Some (app downloads) are not supposed to appear on the shelf. | |
1427 if (!DownloadItemModel(download).ShouldShowInShelf()) | |
1428 return; | |
1429 | |
1430 // GetDownloadShelf creates the download shelf if it was not yet created. | |
1431 window()->GetDownloadShelf()->AddDownload(download); | |
1432 } | |
1433 | |
1434 /////////////////////////////////////////////////////////////////////////////// | 1404 /////////////////////////////////////////////////////////////////////////////// |
1435 // Browser, content::WebContentsDelegate implementation: | 1405 // Browser, content::WebContentsDelegate implementation: |
1436 | 1406 |
1437 WebContents* Browser::OpenURLFromTab(WebContents* source, | 1407 WebContents* Browser::OpenURLFromTab(WebContents* source, |
1438 const OpenURLParams& params) { | 1408 const OpenURLParams& params) { |
1439 if (is_devtools()) { | 1409 if (is_devtools()) { |
1440 DevToolsWindow* window = DevToolsWindow::AsDevToolsWindow(source); | 1410 DevToolsWindow* window = DevToolsWindow::AsDevToolsWindow(source); |
1441 DCHECK(window); | 1411 DCHECK(window); |
1442 return window->OpenURLFromTab(source, params); | 1412 return window->OpenURLFromTab(source, params); |
1443 } | 1413 } |
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2680 if (contents && !allow_js_access) { | 2650 if (contents && !allow_js_access) { |
2681 contents->web_contents()->GetController().LoadURL( | 2651 contents->web_contents()->GetController().LoadURL( |
2682 target_url, | 2652 target_url, |
2683 content::Referrer(), | 2653 content::Referrer(), |
2684 ui::PAGE_TRANSITION_LINK, | 2654 ui::PAGE_TRANSITION_LINK, |
2685 std::string()); // No extra headers. | 2655 std::string()); // No extra headers. |
2686 } | 2656 } |
2687 | 2657 |
2688 return contents != NULL; | 2658 return contents != NULL; |
2689 } | 2659 } |
OLD | NEW |