| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 #include "chrome/browser/infobars/infobar_tab_helper.h" | 54 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 55 #include "chrome/browser/instant/instant_controller.h" | 55 #include "chrome/browser/instant/instant_controller.h" |
| 56 #include "chrome/browser/instant/instant_unload_handler.h" | 56 #include "chrome/browser/instant/instant_unload_handler.h" |
| 57 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" | 57 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" |
| 58 #include "chrome/browser/net/browser_url_util.h" | 58 #include "chrome/browser/net/browser_url_util.h" |
| 59 #include "chrome/browser/net/url_fixer_upper.h" | 59 #include "chrome/browser/net/url_fixer_upper.h" |
| 60 #include "chrome/browser/notifications/notification_ui_manager.h" | 60 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 61 #include "chrome/browser/platform_util.h" | 61 #include "chrome/browser/platform_util.h" |
| 62 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 62 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 63 #include "chrome/browser/prefs/pref_service.h" | 63 #include "chrome/browser/prefs/pref_service.h" |
| 64 #include "chrome/browser/prerender/prerender_tab_helper.h" |
| 64 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 65 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
| 65 #include "chrome/browser/printing/print_preview_tab_controller.h" | 66 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 66 #include "chrome/browser/printing/print_view_manager.h" | 67 #include "chrome/browser/printing/print_view_manager.h" |
| 67 #include "chrome/browser/profiles/profile.h" | 68 #include "chrome/browser/profiles/profile.h" |
| 68 #include "chrome/browser/sessions/restore_tab_helper.h" | 69 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 69 #include "chrome/browser/sessions/session_service.h" | 70 #include "chrome/browser/sessions/session_service.h" |
| 70 #include "chrome/browser/sessions/session_service_factory.h" | 71 #include "chrome/browser/sessions/session_service_factory.h" |
| 71 #include "chrome/browser/sessions/session_types.h" | 72 #include "chrome/browser/sessions/session_types.h" |
| 72 #include "chrome/browser/sessions/tab_restore_service.h" | 73 #include "chrome/browser/sessions/tab_restore_service.h" |
| 73 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 74 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 #include "content/browser/user_metrics.h" | 135 #include "content/browser/user_metrics.h" |
| 135 #include "content/common/content_restriction.h" | 136 #include "content/common/content_restriction.h" |
| 136 #include "content/common/content_switches.h" | 137 #include "content/common/content_switches.h" |
| 137 #include "content/common/notification_service.h" | 138 #include "content/common/notification_service.h" |
| 138 #include "content/common/page_transition_types.h" | 139 #include "content/common/page_transition_types.h" |
| 139 #include "content/common/page_zoom.h" | 140 #include "content/common/page_zoom.h" |
| 140 #include "content/common/view_messages.h" | 141 #include "content/common/view_messages.h" |
| 141 #include "grit/chromium_strings.h" | 142 #include "grit/chromium_strings.h" |
| 142 #include "grit/generated_resources.h" | 143 #include "grit/generated_resources.h" |
| 143 #include "grit/locale_settings.h" | 144 #include "grit/locale_settings.h" |
| 145 #include "grit/theme_resources_standard.h" |
| 144 #include "net/base/cookie_monster.h" | 146 #include "net/base/cookie_monster.h" |
| 145 #include "net/base/net_util.h" | 147 #include "net/base/net_util.h" |
| 146 #include "net/base/registry_controlled_domain.h" | 148 #include "net/base/registry_controlled_domain.h" |
| 147 #include "net/url_request/url_request_context.h" | 149 #include "net/url_request/url_request_context.h" |
| 148 #include "ui/base/animation/animation.h" | 150 #include "ui/base/animation/animation.h" |
| 149 #include "ui/base/l10n/l10n_util.h" | 151 #include "ui/base/l10n/l10n_util.h" |
| 150 #include "ui/gfx/point.h" | 152 #include "ui/gfx/point.h" |
| 151 #include "webkit/glue/webkit_glue.h" | 153 #include "webkit/glue/webkit_glue.h" |
| 152 #include "webkit/glue/window_open_disposition.h" | 154 #include "webkit/glue/window_open_disposition.h" |
| 153 | 155 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 169 #include "chrome/browser/chromeos/boot_times_loader.h" | 171 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 170 #include "chrome/browser/ui/webui/active_downloads_ui.h" | 172 #include "chrome/browser/ui/webui/active_downloads_ui.h" |
| 171 #else | 173 #else |
| 172 #include "chrome/browser/download/download_shelf.h" | 174 #include "chrome/browser/download/download_shelf.h" |
| 173 #endif | 175 #endif |
| 174 | 176 |
| 175 #if defined(FILE_MANAGER_EXTENSION) | 177 #if defined(FILE_MANAGER_EXTENSION) |
| 176 #include "chrome/browser/extensions/file_manager_util.h" | 178 #include "chrome/browser/extensions/file_manager_util.h" |
| 177 #endif | 179 #endif |
| 178 | 180 |
| 181 #include "webkit/plugins/npapi/plugin_list.h" |
| 182 |
| 179 using base::TimeDelta; | 183 using base::TimeDelta; |
| 180 | 184 |
| 181 /////////////////////////////////////////////////////////////////////////////// | 185 /////////////////////////////////////////////////////////////////////////////// |
| 182 | 186 |
| 183 namespace { | 187 namespace { |
| 184 | 188 |
| 185 // The URL to be loaded to display Help. | 189 // The URL to be loaded to display Help. |
| 186 const char kHelpContentUrl[] = | 190 const char kHelpContentUrl[] = |
| 187 #if defined(OS_CHROMEOS) | 191 #if defined(OS_CHROMEOS) |
| 188 #if defined(OFFICIAL_BUILD) | 192 #if defined(OFFICIAL_BUILD) |
| (...skipping 2353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2542 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( | 2546 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( |
| 2543 tab); | 2547 tab); |
| 2544 if (!tcw || !tcw->find_tab_helper()) | 2548 if (!tcw || !tcw->find_tab_helper()) |
| 2545 return; | 2549 return; |
| 2546 | 2550 |
| 2547 tcw->find_tab_helper()->HandleFindReply(request_id, number_of_matches, | 2551 tcw->find_tab_helper()->HandleFindReply(request_id, number_of_matches, |
| 2548 selection_rect, active_match_ordinal, | 2552 selection_rect, active_match_ordinal, |
| 2549 final_update); | 2553 final_update); |
| 2550 } | 2554 } |
| 2551 | 2555 |
| 2556 // static |
| 2557 void Browser::CrashedPluginHelper(TabContents* tab, |
| 2558 const FilePath& plugin_path) { |
| 2559 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( |
| 2560 tab); |
| 2561 if (!tcw) |
| 2562 return; |
| 2563 |
| 2564 DCHECK(!plugin_path.value().empty()); |
| 2565 |
| 2566 string16 plugin_name = plugin_path.LossyDisplayName(); |
| 2567 webkit::WebPluginInfo plugin_info; |
| 2568 if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( |
| 2569 plugin_path, &plugin_info) && |
| 2570 !plugin_info.name.empty()) { |
| 2571 plugin_name = plugin_info.name; |
| 2572 #if defined(OS_MACOSX) |
| 2573 // Many plugins on the Mac have .plugin in the actual name, which looks |
| 2574 // terrible, so look for that and strip it off if present. |
| 2575 const std::string kPluginExtension = ".plugin"; |
| 2576 if (EndsWith(plugin_name, ASCIIToUTF16(kPluginExtension), true)) |
| 2577 plugin_name.erase(plugin_name.length() - kPluginExtension.length()); |
| 2578 #endif // OS_MACOSX |
| 2579 } |
| 2580 gfx::Image* icon = &ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| 2581 IDR_INFOBAR_PLUGIN_CRASHED); |
| 2582 tcw->infobar_tab_helper()->AddInfoBar( |
| 2583 new SimpleAlertInfoBarDelegate( |
| 2584 tab, |
| 2585 icon, |
| 2586 l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, plugin_name), |
| 2587 true)); |
| 2588 } |
| 2589 |
| 2590 // static |
| 2591 void Browser::UpdateTargetURLHelper(TabContents* tab, int32 page_id, |
| 2592 const GURL& url) { |
| 2593 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( |
| 2594 tab); |
| 2595 if (!tcw || !tcw->prerender_tab_helper()) |
| 2596 return; |
| 2597 tcw->prerender_tab_helper()->UpdateTargetURL(page_id, url); |
| 2598 } |
| 2599 |
| 2552 void Browser::ExecuteCommandWithDisposition( | 2600 void Browser::ExecuteCommandWithDisposition( |
| 2553 int id, WindowOpenDisposition disposition) { | 2601 int id, WindowOpenDisposition disposition) { |
| 2554 // No commands are enabled if there is not yet any selected tab. | 2602 // No commands are enabled if there is not yet any selected tab. |
| 2555 // TODO(pkasting): It seems like we should not need this, because either | 2603 // TODO(pkasting): It seems like we should not need this, because either |
| 2556 // most/all commands should not have been enabled yet anyway or the ones that | 2604 // most/all commands should not have been enabled yet anyway or the ones that |
| 2557 // are enabled should be global, or safe themselves against having no selected | 2605 // are enabled should be global, or safe themselves against having no selected |
| 2558 // tab. However, Ben says he tried removing this before and got lots of | 2606 // tab. However, Ben says he tried removing this before and got lots of |
| 2559 // crashes, e.g. from Windows sending WM_COMMANDs at random times during | 2607 // crashes, e.g. from Windows sending WM_COMMANDs at random times during |
| 2560 // window construction. This probably could use closer examination someday. | 2608 // window construction. This probably could use closer examination someday. |
| 2561 if (!GetSelectedTabContentsWrapper()) | 2609 if (!GetSelectedTabContentsWrapper()) |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3476 if (!GetStatusBubble()) | 3524 if (!GetStatusBubble()) |
| 3477 return; | 3525 return; |
| 3478 | 3526 |
| 3479 if (source == GetSelectedTabContents()) { | 3527 if (source == GetSelectedTabContents()) { |
| 3480 GetStatusBubble()->MouseMoved(location, !motion); | 3528 GetStatusBubble()->MouseMoved(location, !motion); |
| 3481 if (!motion) | 3529 if (!motion) |
| 3482 GetStatusBubble()->SetURL(GURL(), std::string()); | 3530 GetStatusBubble()->SetURL(GURL(), std::string()); |
| 3483 } | 3531 } |
| 3484 } | 3532 } |
| 3485 | 3533 |
| 3486 void Browser::UpdateTargetURL(TabContents* source, const GURL& url) { | 3534 void Browser::UpdateTargetURL(TabContents* source, int32 page_id, |
| 3535 const GURL& url) { |
| 3536 Browser::UpdateTargetURLHelper(source, page_id, url); |
| 3537 |
| 3487 if (!GetStatusBubble()) | 3538 if (!GetStatusBubble()) |
| 3488 return; | 3539 return; |
| 3489 | 3540 |
| 3490 if (source == GetSelectedTabContents()) { | 3541 if (source == GetSelectedTabContents()) { |
| 3491 PrefService* prefs = profile_->GetPrefs(); | 3542 PrefService* prefs = profile_->GetPrefs(); |
| 3492 GetStatusBubble()->SetURL(url, prefs->GetString(prefs::kAcceptLanguages)); | 3543 GetStatusBubble()->SetURL(url, prefs->GetString(prefs::kAcceptLanguages)); |
| 3493 } | 3544 } |
| 3494 } | 3545 } |
| 3495 | 3546 |
| 3496 void Browser::UpdateDownloadShelfVisibility(bool visible) { | 3547 void Browser::UpdateDownloadShelfVisibility(bool visible) { |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3807 void Browser::FindReply(TabContents* tab, | 3858 void Browser::FindReply(TabContents* tab, |
| 3808 int request_id, | 3859 int request_id, |
| 3809 int number_of_matches, | 3860 int number_of_matches, |
| 3810 const gfx::Rect& selection_rect, | 3861 const gfx::Rect& selection_rect, |
| 3811 int active_match_ordinal, | 3862 int active_match_ordinal, |
| 3812 bool final_update) { | 3863 bool final_update) { |
| 3813 FindReplyHelper(tab, request_id, number_of_matches, selection_rect, | 3864 FindReplyHelper(tab, request_id, number_of_matches, selection_rect, |
| 3814 active_match_ordinal, final_update); | 3865 active_match_ordinal, final_update); |
| 3815 } | 3866 } |
| 3816 | 3867 |
| 3868 void Browser::CrashedPlugin(TabContents* tab, const FilePath& plugin_path) { |
| 3869 CrashedPluginHelper(tab, plugin_path); |
| 3870 } |
| 3871 |
| 3817 void Browser::ExitTabbedFullscreenModeIfNecessary() { | 3872 void Browser::ExitTabbedFullscreenModeIfNecessary() { |
| 3818 if (tab_caused_fullscreen_) | 3873 if (tab_caused_fullscreen_) |
| 3819 ToggleFullscreenMode(); | 3874 ToggleFullscreenMode(); |
| 3820 else | 3875 else |
| 3821 NotifyTabOfFullscreenExitIfNecessary(); | 3876 NotifyTabOfFullscreenExitIfNecessary(); |
| 3822 } | 3877 } |
| 3823 | 3878 |
| 3824 /////////////////////////////////////////////////////////////////////////////// | 3879 /////////////////////////////////////////////////////////////////////////////// |
| 3825 // Browser, TabContentsWrapperDelegate implementation: | 3880 // Browser, TabContentsWrapperDelegate implementation: |
| 3826 | 3881 |
| (...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5176 } | 5231 } |
| 5177 | 5232 |
| 5178 void Browser::ShowSyncSetup() { | 5233 void Browser::ShowSyncSetup() { |
| 5179 ProfileSyncService* service = | 5234 ProfileSyncService* service = |
| 5180 profile()->GetOriginalProfile()->GetProfileSyncService(); | 5235 profile()->GetOriginalProfile()->GetProfileSyncService(); |
| 5181 if (service->HasSyncSetupCompleted()) | 5236 if (service->HasSyncSetupCompleted()) |
| 5182 ShowOptionsTab(chrome::kSyncSetupSubPage); | 5237 ShowOptionsTab(chrome::kSyncSetupSubPage); |
| 5183 else | 5238 else |
| 5184 service->ShowLoginDialog(); | 5239 service->ShowLoginDialog(); |
| 5185 } | 5240 } |
| OLD | NEW |