| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #include "chrome/browser/google/google_url_tracker.h" | 52 #include "chrome/browser/google/google_url_tracker.h" |
| 53 #include "chrome/browser/google/google_util.h" | 53 #include "chrome/browser/google/google_util.h" |
| 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/plugin_observer.h" |
| 62 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 63 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 63 #include "chrome/browser/prefs/pref_service.h" | 64 #include "chrome/browser/prefs/pref_service.h" |
| 65 #include "chrome/browser/prerender/prerender_tab_helper.h" |
| 64 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 66 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
| 65 #include "chrome/browser/printing/print_preview_tab_controller.h" | 67 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 66 #include "chrome/browser/printing/print_view_manager.h" | 68 #include "chrome/browser/printing/print_view_manager.h" |
| 67 #include "chrome/browser/profiles/profile.h" | 69 #include "chrome/browser/profiles/profile.h" |
| 68 #include "chrome/browser/sessions/restore_tab_helper.h" | 70 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 69 #include "chrome/browser/sessions/session_service.h" | 71 #include "chrome/browser/sessions/session_service.h" |
| 70 #include "chrome/browser/sessions/session_service_factory.h" | 72 #include "chrome/browser/sessions/session_service_factory.h" |
| 71 #include "chrome/browser/sessions/session_types.h" | 73 #include "chrome/browser/sessions/session_types.h" |
| 72 #include "chrome/browser/sessions/tab_restore_service.h" | 74 #include "chrome/browser/sessions/tab_restore_service.h" |
| 73 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 75 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| (...skipping 2468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2542 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( | 2544 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( |
| 2543 tab); | 2545 tab); |
| 2544 if (!tcw || !tcw->find_tab_helper()) | 2546 if (!tcw || !tcw->find_tab_helper()) |
| 2545 return; | 2547 return; |
| 2546 | 2548 |
| 2547 tcw->find_tab_helper()->HandleFindReply(request_id, number_of_matches, | 2549 tcw->find_tab_helper()->HandleFindReply(request_id, number_of_matches, |
| 2548 selection_rect, active_match_ordinal, | 2550 selection_rect, active_match_ordinal, |
| 2549 final_update); | 2551 final_update); |
| 2550 } | 2552 } |
| 2551 | 2553 |
| 2554 // static |
| 2555 void Browser::CrashedPluginHelper(TabContents* tab, |
| 2556 const FilePath& plugin_path) { |
| 2557 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( |
| 2558 tab); |
| 2559 if (!tcw || !tcw->plugin_observer()) |
| 2560 return; |
| 2561 |
| 2562 tcw->plugin_observer()->CrashedPlugin(plugin_path); |
| 2563 } |
| 2564 |
| 2565 // static |
| 2566 void Browser::DidStartProvisionalLoadForFrameHelper(TabContents* tab, |
| 2567 int64 frame_id, |
| 2568 bool is_main_frame, |
| 2569 bool has_opener_set, |
| 2570 const GURL& url) { |
| 2571 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( |
| 2572 tab); |
| 2573 if (!tcw || !tcw->prerender_tab_helper()) |
| 2574 return; |
| 2575 tcw->prerender_tab_helper()->DidStartProvisionalLoadForFrame( |
| 2576 frame_id, is_main_frame, has_opener_set, url); |
| 2577 } |
| 2578 |
| 2579 // static |
| 2580 void Browser::UpdateTargetURLHelper(TabContents* tab, int32 page_id, |
| 2581 const GURL& url) { |
| 2582 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( |
| 2583 tab); |
| 2584 if (!tcw || !tcw->prerender_tab_helper()) |
| 2585 return; |
| 2586 tcw->prerender_tab_helper()->UpdateTargetURL(page_id, url); |
| 2587 } |
| 2588 |
| 2552 void Browser::ExecuteCommandWithDisposition( | 2589 void Browser::ExecuteCommandWithDisposition( |
| 2553 int id, WindowOpenDisposition disposition) { | 2590 int id, WindowOpenDisposition disposition) { |
| 2554 // No commands are enabled if there is not yet any selected tab. | 2591 // 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 | 2592 // 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 | 2593 // 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 | 2594 // 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 | 2595 // 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 | 2596 // crashes, e.g. from Windows sending WM_COMMANDs at random times during |
| 2560 // window construction. This probably could use closer examination someday. | 2597 // window construction. This probably could use closer examination someday. |
| 2561 if (!GetSelectedTabContentsWrapper()) | 2598 if (!GetSelectedTabContentsWrapper()) |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3476 if (!GetStatusBubble()) | 3513 if (!GetStatusBubble()) |
| 3477 return; | 3514 return; |
| 3478 | 3515 |
| 3479 if (source == GetSelectedTabContents()) { | 3516 if (source == GetSelectedTabContents()) { |
| 3480 GetStatusBubble()->MouseMoved(location, !motion); | 3517 GetStatusBubble()->MouseMoved(location, !motion); |
| 3481 if (!motion) | 3518 if (!motion) |
| 3482 GetStatusBubble()->SetURL(GURL(), std::string()); | 3519 GetStatusBubble()->SetURL(GURL(), std::string()); |
| 3483 } | 3520 } |
| 3484 } | 3521 } |
| 3485 | 3522 |
| 3486 void Browser::UpdateTargetURL(TabContents* source, const GURL& url) { | 3523 void Browser::UpdateTargetURL(TabContents* source, int32 page_id, |
| 3524 const GURL& url) { |
| 3525 Browser::UpdateTargetURLHelper(source, page_id, url); |
| 3526 |
| 3487 if (!GetStatusBubble()) | 3527 if (!GetStatusBubble()) |
| 3488 return; | 3528 return; |
| 3489 | 3529 |
| 3490 if (source == GetSelectedTabContents()) { | 3530 if (source == GetSelectedTabContents()) { |
| 3491 PrefService* prefs = profile_->GetPrefs(); | 3531 PrefService* prefs = profile_->GetPrefs(); |
| 3492 GetStatusBubble()->SetURL(url, prefs->GetString(prefs::kAcceptLanguages)); | 3532 GetStatusBubble()->SetURL(url, prefs->GetString(prefs::kAcceptLanguages)); |
| 3493 } | 3533 } |
| 3494 } | 3534 } |
| 3495 | 3535 |
| 3496 void Browser::UpdateDownloadShelfVisibility(bool visible) { | 3536 void Browser::UpdateDownloadShelfVisibility(bool visible) { |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3807 void Browser::FindReply(TabContents* tab, | 3847 void Browser::FindReply(TabContents* tab, |
| 3808 int request_id, | 3848 int request_id, |
| 3809 int number_of_matches, | 3849 int number_of_matches, |
| 3810 const gfx::Rect& selection_rect, | 3850 const gfx::Rect& selection_rect, |
| 3811 int active_match_ordinal, | 3851 int active_match_ordinal, |
| 3812 bool final_update) { | 3852 bool final_update) { |
| 3813 FindReplyHelper(tab, request_id, number_of_matches, selection_rect, | 3853 FindReplyHelper(tab, request_id, number_of_matches, selection_rect, |
| 3814 active_match_ordinal, final_update); | 3854 active_match_ordinal, final_update); |
| 3815 } | 3855 } |
| 3816 | 3856 |
| 3857 void Browser::CrashedPlugin(TabContents* tab, const FilePath& plugin_path) { |
| 3858 CrashedPluginHelper(tab, plugin_path); |
| 3859 } |
| 3860 |
| 3861 void Browser::DidStartProvisionalLoadForFrame(TabContents* tab, |
| 3862 int64 frame_id, |
| 3863 bool is_main_frame, |
| 3864 bool has_opener_set, |
| 3865 const GURL& url) { |
| 3866 DidStartProvisionalLoadForFrameHelper(tab, frame_id, is_main_frame, |
| 3867 has_opener_set, url); |
| 3868 } |
| 3869 |
| 3817 void Browser::ExitTabbedFullscreenModeIfNecessary() { | 3870 void Browser::ExitTabbedFullscreenModeIfNecessary() { |
| 3818 if (tab_caused_fullscreen_) | 3871 if (tab_caused_fullscreen_) |
| 3819 ToggleFullscreenMode(); | 3872 ToggleFullscreenMode(); |
| 3820 else | 3873 else |
| 3821 NotifyTabOfFullscreenExitIfNecessary(); | 3874 NotifyTabOfFullscreenExitIfNecessary(); |
| 3822 } | 3875 } |
| 3823 | 3876 |
| 3824 /////////////////////////////////////////////////////////////////////////////// | 3877 /////////////////////////////////////////////////////////////////////////////// |
| 3825 // Browser, TabContentsWrapperDelegate implementation: | 3878 // Browser, TabContentsWrapperDelegate implementation: |
| 3826 | 3879 |
| (...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5176 } | 5229 } |
| 5177 | 5230 |
| 5178 void Browser::ShowSyncSetup() { | 5231 void Browser::ShowSyncSetup() { |
| 5179 ProfileSyncService* service = | 5232 ProfileSyncService* service = |
| 5180 profile()->GetOriginalProfile()->GetProfileSyncService(); | 5233 profile()->GetOriginalProfile()->GetProfileSyncService(); |
| 5181 if (service->HasSyncSetupCompleted()) | 5234 if (service->HasSyncSetupCompleted()) |
| 5182 ShowOptionsTab(chrome::kSyncSetupSubPage); | 5235 ShowOptionsTab(chrome::kSyncSetupSubPage); |
| 5183 else | 5236 else |
| 5184 service->ShowLoginDialog(); | 5237 service->ShowLoginDialog(); |
| 5185 } | 5238 } |
| OLD | NEW |