| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 #include "chrome/browser/tab_contents/retargeting_details.h" | 96 #include "chrome/browser/tab_contents/retargeting_details.h" |
| 97 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" | 97 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" |
| 98 #include "chrome/browser/tab_contents/tab_util.h" | 98 #include "chrome/browser/tab_contents/tab_util.h" |
| 99 #include "chrome/browser/tabs/tab_finder.h" | 99 #include "chrome/browser/tabs/tab_finder.h" |
| 100 #include "chrome/browser/tabs/tab_strip_model.h" | 100 #include "chrome/browser/tabs/tab_strip_model.h" |
| 101 #include "chrome/browser/themes/theme_service.h" | 101 #include "chrome/browser/themes/theme_service.h" |
| 102 #include "chrome/browser/themes/theme_service_factory.h" | 102 #include "chrome/browser/themes/theme_service_factory.h" |
| 103 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" | 103 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" |
| 104 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 104 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
| 105 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 105 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 106 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" | |
| 107 #include "chrome/browser/ui/browser_dialogs.h" | 106 #include "chrome/browser/ui/browser_dialogs.h" |
| 108 #include "chrome/browser/ui/browser_list.h" | 107 #include "chrome/browser/ui/browser_list.h" |
| 109 #include "chrome/browser/ui/browser_navigator.h" | 108 #include "chrome/browser/ui/browser_navigator.h" |
| 110 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" | 109 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" |
| 111 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" | |
| 112 #include "chrome/browser/ui/browser_window.h" | 110 #include "chrome/browser/ui/browser_window.h" |
| 113 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 111 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
| 114 #include "chrome/browser/ui/extensions/shell_window.h" | 112 #include "chrome/browser/ui/extensions/shell_window.h" |
| 115 #include "chrome/browser/ui/find_bar/find_bar.h" | 113 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 116 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 114 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 117 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 115 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| 118 #include "chrome/browser/ui/fullscreen_controller.h" | 116 #include "chrome/browser/ui/fullscreen_controller.h" |
| 119 #include "chrome/browser/ui/global_error.h" | 117 #include "chrome/browser/ui/global_error.h" |
| 120 #include "chrome/browser/ui/global_error_service.h" | 118 #include "chrome/browser/ui/global_error_service.h" |
| 121 #include "chrome/browser/ui/global_error_service_factory.h" | 119 #include "chrome/browser/ui/global_error_service_factory.h" |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 /////////////////////////////////////////////////////////////////////////////// | 332 /////////////////////////////////////////////////////////////////////////////// |
| 335 // Browser, Constructors, Creation, Showing: | 333 // Browser, Constructors, Creation, Showing: |
| 336 | 334 |
| 337 Browser::Browser(Type type, Profile* profile) | 335 Browser::Browser(Type type, Profile* profile) |
| 338 : type_(type), | 336 : type_(type), |
| 339 profile_(profile), | 337 profile_(profile), |
| 340 window_(NULL), | 338 window_(NULL), |
| 341 ALLOW_THIS_IN_INITIALIZER_LIST( | 339 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 342 tab_handler_(TabHandler::CreateTabHandler(this))), | 340 tab_handler_(TabHandler::CreateTabHandler(this))), |
| 343 command_updater_(this), | 341 command_updater_(this), |
| 342 toolbar_model_(this), |
| 344 chrome_updater_factory_(this), | 343 chrome_updater_factory_(this), |
| 345 is_attempting_to_close_browser_(false), | 344 is_attempting_to_close_browser_(false), |
| 346 cancel_download_confirmation_state_(NOT_PROMPTED), | 345 cancel_download_confirmation_state_(NOT_PROMPTED), |
| 347 show_state_(ui::SHOW_STATE_DEFAULT), | 346 show_state_(ui::SHOW_STATE_DEFAULT), |
| 348 is_session_restore_(false), | 347 is_session_restore_(false), |
| 349 weak_factory_(this), | 348 weak_factory_(this), |
| 350 block_command_execution_(false), | 349 block_command_execution_(false), |
| 351 last_blocked_command_id_(-1), | 350 last_blocked_command_id_(-1), |
| 352 last_blocked_command_disposition_(CURRENT_TAB), | 351 last_blocked_command_disposition_(CURRENT_TAB), |
| 353 pending_web_app_action_(NONE), | 352 pending_web_app_action_(NONE), |
| 354 ALLOW_THIS_IN_INITIALIZER_LIST( | 353 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 355 content_setting_bubble_model_delegate_( | |
| 356 new BrowserContentSettingBubbleModelDelegate(this))), | |
| 357 ALLOW_THIS_IN_INITIALIZER_LIST( | |
| 358 toolbar_model_delegate_( | |
| 359 new BrowserToolbarModelDelegate(this))), | |
| 360 ALLOW_THIS_IN_INITIALIZER_LIST( | |
| 361 tab_restore_service_delegate_( | 354 tab_restore_service_delegate_( |
| 362 new BrowserTabRestoreServiceDelegate(this))), | 355 new BrowserTabRestoreServiceDelegate(this))), |
| 363 ALLOW_THIS_IN_INITIALIZER_LIST( | 356 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 364 synced_window_delegate_( | 357 synced_window_delegate_( |
| 365 new BrowserSyncedWindowDelegate(this))), | 358 new BrowserSyncedWindowDelegate(this))), |
| 366 bookmark_bar_state_(BookmarkBar::HIDDEN), | 359 bookmark_bar_state_(BookmarkBar::HIDDEN), |
| 367 window_has_shown_(false) { | 360 window_has_shown_(false) { |
| 368 toolbar_model_.reset(new ToolbarModel(toolbar_model_delegate_.get())); | |
| 369 | |
| 370 registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, | 361 registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, |
| 371 content::NotificationService::AllSources()); | 362 content::NotificationService::AllSources()); |
| 372 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 363 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| 373 content::Source<Profile>(profile_->GetOriginalProfile())); | 364 content::Source<Profile>(profile_->GetOriginalProfile())); |
| 374 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 365 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 375 content::Source<Profile>(profile_->GetOriginalProfile())); | 366 content::Source<Profile>(profile_->GetOriginalProfile())); |
| 376 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 367 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 377 content::Source<Profile>(profile_->GetOriginalProfile())); | 368 content::Source<Profile>(profile_->GetOriginalProfile())); |
| 378 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 369 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
| 379 content::Source<Profile>(profile_->GetOriginalProfile())); | 370 content::Source<Profile>(profile_->GetOriginalProfile())); |
| (...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1864 | 1855 |
| 1865 service->RestoreMostRecentEntry(tab_restore_service_delegate()); | 1856 service->RestoreMostRecentEntry(tab_restore_service_delegate()); |
| 1866 } | 1857 } |
| 1867 | 1858 |
| 1868 void Browser::WriteCurrentURLToClipboard() { | 1859 void Browser::WriteCurrentURLToClipboard() { |
| 1869 // TODO(ericu): There isn't currently a metric for this. Should there be? | 1860 // TODO(ericu): There isn't currently a metric for this. Should there be? |
| 1870 // We don't appear to track the action when it comes from the | 1861 // We don't appear to track the action when it comes from the |
| 1871 // RenderContextViewMenu. | 1862 // RenderContextViewMenu. |
| 1872 | 1863 |
| 1873 WebContents* contents = GetSelectedWebContents(); | 1864 WebContents* contents = GetSelectedWebContents(); |
| 1874 if (!toolbar_model_->ShouldDisplayURL()) | 1865 if (!toolbar_model_.ShouldDisplayURL()) |
| 1875 return; | 1866 return; |
| 1876 | 1867 |
| 1877 chrome_browser_net::WriteURLToClipboard( | 1868 chrome_browser_net::WriteURLToClipboard( |
| 1878 contents->GetURL(), | 1869 contents->GetURL(), |
| 1879 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), | 1870 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), |
| 1880 g_browser_process->clipboard()); | 1871 g_browser_process->clipboard()); |
| 1881 } | 1872 } |
| 1882 | 1873 |
| 1883 void Browser::ConvertPopupToTabbedBrowser() { | 1874 void Browser::ConvertPopupToTabbedBrowser() { |
| 1884 content::RecordAction(UserMetricsAction("ShowAsTab")); | 1875 content::RecordAction(UserMetricsAction("ShowAsTab")); |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2918 // static | 2909 // static |
| 2919 void Browser::UpdateTargetURLHelper(WebContents* tab, int32 page_id, | 2910 void Browser::UpdateTargetURLHelper(WebContents* tab, int32 page_id, |
| 2920 const GURL& url) { | 2911 const GURL& url) { |
| 2921 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( | 2912 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( |
| 2922 tab); | 2913 tab); |
| 2923 if (!tcw || !tcw->prerender_tab_helper()) | 2914 if (!tcw || !tcw->prerender_tab_helper()) |
| 2924 return; | 2915 return; |
| 2925 tcw->prerender_tab_helper()->UpdateTargetURL(page_id, url); | 2916 tcw->prerender_tab_helper()->UpdateTargetURL(page_id, url); |
| 2926 } | 2917 } |
| 2927 | 2918 |
| 2928 void Browser::ExecuteCommand(int id) { | |
| 2929 ExecuteCommandWithDisposition(id, CURRENT_TAB); | |
| 2930 } | |
| 2931 | |
| 2932 void Browser::ExecuteCommand(int id, int event_flags) { | |
| 2933 ExecuteCommandWithDisposition( | |
| 2934 id, browser::DispositionFromEventFlags(event_flags)); | |
| 2935 } | |
| 2936 | |
| 2937 bool Browser::ExecuteCommandIfEnabled(int id) { | |
| 2938 if (command_updater_.SupportsCommand(id) && | |
| 2939 command_updater_.IsCommandEnabled(id)) { | |
| 2940 ExecuteCommand(id, CURRENT_TAB); | |
| 2941 return true; | |
| 2942 } | |
| 2943 return false; | |
| 2944 } | |
| 2945 | |
| 2946 bool Browser::IsReservedCommandOrKey(int command_id, | |
| 2947 const NativeWebKeyboardEvent& event) { | |
| 2948 #if defined(OS_CHROMEOS) | |
| 2949 // Chrome OS's top row of keys produces F1-10. Make sure that web pages | |
| 2950 // aren't able to block Chrome from performing the standard actions for F1-F4 | |
| 2951 // (F5-7 are grabbed by other X clients and hence don't need this protection, | |
| 2952 // and F8-10 are handled separately in Chrome via a GDK event filter, but | |
| 2953 // let's future-proof this). | |
| 2954 ui::KeyboardCode key_code = | |
| 2955 static_cast<ui::KeyboardCode>(event.windowsKeyCode); | |
| 2956 if (key_code == ui::VKEY_F1 || | |
| 2957 key_code == ui::VKEY_F2 || | |
| 2958 key_code == ui::VKEY_F3 || | |
| 2959 key_code == ui::VKEY_F4 || | |
| 2960 key_code == ui::VKEY_F5 || | |
| 2961 key_code == ui::VKEY_F6 || | |
| 2962 key_code == ui::VKEY_F7 || | |
| 2963 key_code == ui::VKEY_F8 || | |
| 2964 key_code == ui::VKEY_F9 || | |
| 2965 key_code == ui::VKEY_F10) { | |
| 2966 return true; | |
| 2967 } | |
| 2968 #endif | |
| 2969 | |
| 2970 if (window_->IsFullscreen() && command_id == IDC_FULLSCREEN) | |
| 2971 return true; | |
| 2972 return command_id == IDC_CLOSE_TAB || | |
| 2973 command_id == IDC_CLOSE_WINDOW || | |
| 2974 command_id == IDC_NEW_INCOGNITO_WINDOW || | |
| 2975 command_id == IDC_NEW_TAB || | |
| 2976 command_id == IDC_NEW_WINDOW || | |
| 2977 command_id == IDC_RESTORE_TAB || | |
| 2978 command_id == IDC_SELECT_NEXT_TAB || | |
| 2979 command_id == IDC_SELECT_PREVIOUS_TAB || | |
| 2980 command_id == IDC_TABPOSE || | |
| 2981 command_id == IDC_EXIT || | |
| 2982 command_id == IDC_SEARCH; | |
| 2983 } | |
| 2984 | |
| 2985 void Browser::SetBlockCommandExecution(bool block) { | |
| 2986 block_command_execution_ = block; | |
| 2987 if (block) { | |
| 2988 last_blocked_command_id_ = -1; | |
| 2989 last_blocked_command_disposition_ = CURRENT_TAB; | |
| 2990 } | |
| 2991 } | |
| 2992 | |
| 2993 int Browser::GetLastBlockedCommand(WindowOpenDisposition* disposition) { | |
| 2994 if (disposition) | |
| 2995 *disposition = last_blocked_command_disposition_; | |
| 2996 return last_blocked_command_id_; | |
| 2997 } | |
| 2998 | |
| 2999 void Browser::UpdateUIForNavigationInTab(TabContentsWrapper* contents, | |
| 3000 content::PageTransition transition, | |
| 3001 bool user_initiated) { | |
| 3002 tab_handler_->GetTabStripModel()->TabNavigating(contents, transition); | |
| 3003 | |
| 3004 bool contents_is_selected = contents == GetSelectedTabContentsWrapper(); | |
| 3005 if (user_initiated && contents_is_selected && window()->GetLocationBar()) { | |
| 3006 // Forcibly reset the location bar if the url is going to change in the | |
| 3007 // current tab, since otherwise it won't discard any ongoing user edits, | |
| 3008 // since it doesn't realize this is a user-initiated action. | |
| 3009 window()->GetLocationBar()->Revert(); | |
| 3010 } | |
| 3011 | |
| 3012 if (GetStatusBubble()) | |
| 3013 GetStatusBubble()->Hide(); | |
| 3014 | |
| 3015 // Update the location bar. This is synchronous. We specifically don't | |
| 3016 // update the load state since the load hasn't started yet and updating it | |
| 3017 // will put it out of sync with the actual state like whether we're | |
| 3018 // displaying a favicon, which controls the throbber. If we updated it here, | |
| 3019 // the throbber will show the default favicon for a split second when | |
| 3020 // navigating away from the new tab page. | |
| 3021 ScheduleUIUpdate(contents->web_contents(), content::INVALIDATE_TYPE_URL); | |
| 3022 | |
| 3023 if (contents_is_selected) | |
| 3024 contents->web_contents()->Focus(); | |
| 3025 } | |
| 3026 | |
| 3027 /////////////////////////////////////////////////////////////////////////////// | |
| 3028 // Browser, PageNavigator implementation: | |
| 3029 | |
| 3030 WebContents* Browser::OpenURL(const OpenURLParams& params) { | |
| 3031 return OpenURLFromTab(NULL, params); | |
| 3032 } | |
| 3033 | |
| 3034 /////////////////////////////////////////////////////////////////////////////// | |
| 3035 // Browser, CommandUpdater::CommandUpdaterDelegate implementation: | |
| 3036 | |
| 3037 void Browser::ExecuteCommandWithDisposition( | 2919 void Browser::ExecuteCommandWithDisposition( |
| 3038 int id, WindowOpenDisposition disposition) { | 2920 int id, WindowOpenDisposition disposition) { |
| 3039 // No commands are enabled if there is not yet any selected tab. | 2921 // No commands are enabled if there is not yet any selected tab. |
| 3040 // TODO(pkasting): It seems like we should not need this, because either | 2922 // TODO(pkasting): It seems like we should not need this, because either |
| 3041 // most/all commands should not have been enabled yet anyway or the ones that | 2923 // most/all commands should not have been enabled yet anyway or the ones that |
| 3042 // are enabled should be global, or safe themselves against having no selected | 2924 // are enabled should be global, or safe themselves against having no selected |
| 3043 // tab. However, Ben says he tried removing this before and got lots of | 2925 // tab. However, Ben says he tried removing this before and got lots of |
| 3044 // crashes, e.g. from Windows sending WM_COMMANDs at random times during | 2926 // crashes, e.g. from Windows sending WM_COMMANDs at random times during |
| 3045 // window construction. This probably could use closer examination someday. | 2927 // window construction. This probably could use closer examination someday. |
| 3046 if (!GetSelectedTabContentsWrapper()) | 2928 if (!GetSelectedTabContentsWrapper()) |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3225 #endif | 3107 #endif |
| 3226 case IDC_SHOW_SYNC_SETUP: ShowSyncSetup(); break; | 3108 case IDC_SHOW_SYNC_SETUP: ShowSyncSetup(); break; |
| 3227 case IDC_TOGGLE_SPEECH_INPUT: ToggleSpeechInput(); break; | 3109 case IDC_TOGGLE_SPEECH_INPUT: ToggleSpeechInput(); break; |
| 3228 | 3110 |
| 3229 default: | 3111 default: |
| 3230 LOG(WARNING) << "Received Unimplemented Command: " << id; | 3112 LOG(WARNING) << "Received Unimplemented Command: " << id; |
| 3231 break; | 3113 break; |
| 3232 } | 3114 } |
| 3233 } | 3115 } |
| 3234 | 3116 |
| 3117 void Browser::ExecuteCommand(int id, int event_flags) { |
| 3118 ExecuteCommandWithDisposition( |
| 3119 id, browser::DispositionFromEventFlags(event_flags)); |
| 3120 } |
| 3121 |
| 3122 bool Browser::ExecuteCommandIfEnabled(int id) { |
| 3123 if (command_updater_.SupportsCommand(id) && |
| 3124 command_updater_.IsCommandEnabled(id)) { |
| 3125 ExecuteCommand(id); |
| 3126 return true; |
| 3127 } |
| 3128 return false; |
| 3129 } |
| 3130 |
| 3131 bool Browser::IsReservedCommandOrKey(int command_id, |
| 3132 const NativeWebKeyboardEvent& event) { |
| 3133 #if defined(OS_CHROMEOS) |
| 3134 // Chrome OS's top row of keys produces F1-10. Make sure that web pages |
| 3135 // aren't able to block Chrome from performing the standard actions for F1-F4 |
| 3136 // (F5-7 are grabbed by other X clients and hence don't need this protection, |
| 3137 // and F8-10 are handled separately in Chrome via a GDK event filter, but |
| 3138 // let's future-proof this). |
| 3139 ui::KeyboardCode key_code = |
| 3140 static_cast<ui::KeyboardCode>(event.windowsKeyCode); |
| 3141 if (key_code == ui::VKEY_F1 || |
| 3142 key_code == ui::VKEY_F2 || |
| 3143 key_code == ui::VKEY_F3 || |
| 3144 key_code == ui::VKEY_F4 || |
| 3145 key_code == ui::VKEY_F5 || |
| 3146 key_code == ui::VKEY_F6 || |
| 3147 key_code == ui::VKEY_F7 || |
| 3148 key_code == ui::VKEY_F8 || |
| 3149 key_code == ui::VKEY_F9 || |
| 3150 key_code == ui::VKEY_F10) { |
| 3151 return true; |
| 3152 } |
| 3153 #endif |
| 3154 |
| 3155 if (window_->IsFullscreen() && command_id == IDC_FULLSCREEN) |
| 3156 return true; |
| 3157 return command_id == IDC_CLOSE_TAB || |
| 3158 command_id == IDC_CLOSE_WINDOW || |
| 3159 command_id == IDC_NEW_INCOGNITO_WINDOW || |
| 3160 command_id == IDC_NEW_TAB || |
| 3161 command_id == IDC_NEW_WINDOW || |
| 3162 command_id == IDC_RESTORE_TAB || |
| 3163 command_id == IDC_SELECT_NEXT_TAB || |
| 3164 command_id == IDC_SELECT_PREVIOUS_TAB || |
| 3165 command_id == IDC_TABPOSE || |
| 3166 command_id == IDC_EXIT || |
| 3167 command_id == IDC_SEARCH; |
| 3168 } |
| 3169 |
| 3170 void Browser::SetBlockCommandExecution(bool block) { |
| 3171 block_command_execution_ = block; |
| 3172 if (block) { |
| 3173 last_blocked_command_id_ = -1; |
| 3174 last_blocked_command_disposition_ = CURRENT_TAB; |
| 3175 } |
| 3176 } |
| 3177 |
| 3178 int Browser::GetLastBlockedCommand(WindowOpenDisposition* disposition) { |
| 3179 if (disposition) |
| 3180 *disposition = last_blocked_command_disposition_; |
| 3181 return last_blocked_command_id_; |
| 3182 } |
| 3183 |
| 3184 void Browser::UpdateUIForNavigationInTab(TabContentsWrapper* contents, |
| 3185 content::PageTransition transition, |
| 3186 bool user_initiated) { |
| 3187 tab_handler_->GetTabStripModel()->TabNavigating(contents, transition); |
| 3188 |
| 3189 bool contents_is_selected = contents == GetSelectedTabContentsWrapper(); |
| 3190 if (user_initiated && contents_is_selected && window()->GetLocationBar()) { |
| 3191 // Forcibly reset the location bar if the url is going to change in the |
| 3192 // current tab, since otherwise it won't discard any ongoing user edits, |
| 3193 // since it doesn't realize this is a user-initiated action. |
| 3194 window()->GetLocationBar()->Revert(); |
| 3195 } |
| 3196 |
| 3197 if (GetStatusBubble()) |
| 3198 GetStatusBubble()->Hide(); |
| 3199 |
| 3200 // Update the location bar. This is synchronous. We specifically don't |
| 3201 // update the load state since the load hasn't started yet and updating it |
| 3202 // will put it out of sync with the actual state like whether we're |
| 3203 // displaying a favicon, which controls the throbber. If we updated it here, |
| 3204 // the throbber will show the default favicon for a split second when |
| 3205 // navigating away from the new tab page. |
| 3206 ScheduleUIUpdate(contents->web_contents(), content::INVALIDATE_TYPE_URL); |
| 3207 |
| 3208 if (contents_is_selected) |
| 3209 contents->web_contents()->Focus(); |
| 3210 } |
| 3211 |
| 3212 /////////////////////////////////////////////////////////////////////////////// |
| 3213 // Browser, PageNavigator implementation: |
| 3214 |
| 3215 WebContents* Browser::OpenURL(const OpenURLParams& params) { |
| 3216 return OpenURLFromTab(NULL, params); |
| 3217 } |
| 3218 |
| 3219 /////////////////////////////////////////////////////////////////////////////// |
| 3220 // Browser, CommandUpdater::CommandUpdaterDelegate implementation: |
| 3221 |
| 3222 void Browser::ExecuteCommand(int id) { |
| 3223 ExecuteCommandWithDisposition(id, CURRENT_TAB); |
| 3224 } |
| 3225 |
| 3235 /////////////////////////////////////////////////////////////////////////////// | 3226 /////////////////////////////////////////////////////////////////////////////// |
| 3236 // Browser, TabHandlerDelegate implementation: | 3227 // Browser, TabHandlerDelegate implementation: |
| 3237 | 3228 |
| 3238 Profile* Browser::GetProfile() const { | 3229 Profile* Browser::GetProfile() const { |
| 3239 return profile(); | 3230 return profile(); |
| 3240 } | 3231 } |
| 3241 | 3232 |
| 3242 Browser* Browser::AsBrowser() { | 3233 Browser* Browser::AsBrowser() { |
| 3243 return this; | 3234 return this; |
| 3244 } | 3235 } |
| (...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4884 // Window management commands | 4875 // Window management commands |
| 4885 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, | 4876 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, |
| 4886 !is_app() && CanDuplicateContentsAt(active_index())); | 4877 !is_app() && CanDuplicateContentsAt(active_index())); |
| 4887 | 4878 |
| 4888 // Page-related commands | 4879 // Page-related commands |
| 4889 window_->SetStarredState( | 4880 window_->SetStarredState( |
| 4890 current_tab_wrapper->bookmark_tab_helper()->is_starred()); | 4881 current_tab_wrapper->bookmark_tab_helper()->is_starred()); |
| 4891 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, | 4882 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, |
| 4892 current_tab->GetController().CanViewSource()); | 4883 current_tab->GetController().CanViewSource()); |
| 4893 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, | 4884 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, |
| 4894 toolbar_model_->ShouldDisplayURL() && current_tab->GetURL().is_valid()); | 4885 toolbar_model_.ShouldDisplayURL() && current_tab->GetURL().is_valid()); |
| 4895 if (is_devtools()) | 4886 if (is_devtools()) |
| 4896 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false); | 4887 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false); |
| 4897 | 4888 |
| 4898 // Changing the encoding is not possible on Chrome-internal webpages. | 4889 // Changing the encoding is not possible on Chrome-internal webpages. |
| 4899 bool is_chrome_internal = HasInternalURL(nc.GetActiveEntry()) || | 4890 bool is_chrome_internal = HasInternalURL(nc.GetActiveEntry()) || |
| 4900 current_tab->ShowingInterstitialPage(); | 4891 current_tab->ShowingInterstitialPage(); |
| 4901 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, | 4892 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, |
| 4902 !is_chrome_internal && current_tab->IsSavable()); | 4893 !is_chrome_internal && current_tab->IsSavable()); |
| 4903 | 4894 |
| 4904 // Show various bits of UI | 4895 // Show various bits of UI |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5635 } else { | 5626 } else { |
| 5636 LoginUIServiceFactory::GetForProfile( | 5627 LoginUIServiceFactory::GetForProfile( |
| 5637 profile()->GetOriginalProfile())->ShowLoginUI(); | 5628 profile()->GetOriginalProfile())->ShowLoginUI(); |
| 5638 } | 5629 } |
| 5639 #endif | 5630 #endif |
| 5640 } | 5631 } |
| 5641 | 5632 |
| 5642 void Browser::ToggleSpeechInput() { | 5633 void Browser::ToggleSpeechInput() { |
| 5643 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); | 5634 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); |
| 5644 } | 5635 } |
| OLD | NEW |