Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(537)

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 9479008: Re-factor location bar/toolbar code to get rid of the browser dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: call right overloaded method Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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"
106 #include "chrome/browser/ui/browser_dialogs.h" 107 #include "chrome/browser/ui/browser_dialogs.h"
107 #include "chrome/browser/ui/browser_list.h" 108 #include "chrome/browser/ui/browser_list.h"
108 #include "chrome/browser/ui/browser_navigator.h" 109 #include "chrome/browser/ui/browser_navigator.h"
109 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" 110 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h"
111 #include "chrome/browser/ui/browser_toolbar_model_delegate.h"
110 #include "chrome/browser/ui/browser_window.h" 112 #include "chrome/browser/ui/browser_window.h"
111 #include "chrome/browser/ui/constrained_window_tab_helper.h" 113 #include "chrome/browser/ui/constrained_window_tab_helper.h"
112 #include "chrome/browser/ui/extensions/shell_window.h" 114 #include "chrome/browser/ui/extensions/shell_window.h"
113 #include "chrome/browser/ui/find_bar/find_bar.h" 115 #include "chrome/browser/ui/find_bar/find_bar.h"
114 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 116 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
115 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 117 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
116 #include "chrome/browser/ui/fullscreen_controller.h" 118 #include "chrome/browser/ui/fullscreen_controller.h"
117 #include "chrome/browser/ui/global_error.h" 119 #include "chrome/browser/ui/global_error.h"
118 #include "chrome/browser/ui/global_error_service.h" 120 #include "chrome/browser/ui/global_error_service.h"
119 #include "chrome/browser/ui/global_error_service_factory.h" 121 #include "chrome/browser/ui/global_error_service_factory.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 /////////////////////////////////////////////////////////////////////////////// 334 ///////////////////////////////////////////////////////////////////////////////
333 // Browser, Constructors, Creation, Showing: 335 // Browser, Constructors, Creation, Showing:
334 336
335 Browser::Browser(Type type, Profile* profile) 337 Browser::Browser(Type type, Profile* profile)
336 : type_(type), 338 : type_(type),
337 profile_(profile), 339 profile_(profile),
338 window_(NULL), 340 window_(NULL),
339 ALLOW_THIS_IN_INITIALIZER_LIST( 341 ALLOW_THIS_IN_INITIALIZER_LIST(
340 tab_handler_(TabHandler::CreateTabHandler(this))), 342 tab_handler_(TabHandler::CreateTabHandler(this))),
341 command_updater_(this), 343 command_updater_(this),
342 toolbar_model_(this),
343 chrome_updater_factory_(this), 344 chrome_updater_factory_(this),
344 is_attempting_to_close_browser_(false), 345 is_attempting_to_close_browser_(false),
345 cancel_download_confirmation_state_(NOT_PROMPTED), 346 cancel_download_confirmation_state_(NOT_PROMPTED),
346 show_state_(ui::SHOW_STATE_DEFAULT), 347 show_state_(ui::SHOW_STATE_DEFAULT),
347 is_session_restore_(false), 348 is_session_restore_(false),
348 weak_factory_(this), 349 weak_factory_(this),
349 block_command_execution_(false), 350 block_command_execution_(false),
350 last_blocked_command_id_(-1), 351 last_blocked_command_id_(-1),
351 last_blocked_command_disposition_(CURRENT_TAB), 352 last_blocked_command_disposition_(CURRENT_TAB),
352 pending_web_app_action_(NONE), 353 pending_web_app_action_(NONE),
353 ALLOW_THIS_IN_INITIALIZER_LIST( 354 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(
354 tab_restore_service_delegate_( 361 tab_restore_service_delegate_(
355 new BrowserTabRestoreServiceDelegate(this))), 362 new BrowserTabRestoreServiceDelegate(this))),
356 ALLOW_THIS_IN_INITIALIZER_LIST( 363 ALLOW_THIS_IN_INITIALIZER_LIST(
357 synced_window_delegate_( 364 synced_window_delegate_(
358 new BrowserSyncedWindowDelegate(this))), 365 new BrowserSyncedWindowDelegate(this))),
359 bookmark_bar_state_(BookmarkBar::HIDDEN), 366 bookmark_bar_state_(BookmarkBar::HIDDEN),
360 window_has_shown_(false) { 367 window_has_shown_(false) {
368 toolbar_model_.reset(new ToolbarModel(toolbar_model_delegate_.get()));
369
361 registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, 370 registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED,
362 content::NotificationService::AllSources()); 371 content::NotificationService::AllSources());
363 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, 372 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
364 content::Source<Profile>(profile_->GetOriginalProfile())); 373 content::Source<Profile>(profile_->GetOriginalProfile()));
365 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 374 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
366 content::Source<Profile>(profile_->GetOriginalProfile())); 375 content::Source<Profile>(profile_->GetOriginalProfile()));
367 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 376 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
368 content::Source<Profile>(profile_->GetOriginalProfile())); 377 content::Source<Profile>(profile_->GetOriginalProfile()));
369 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 378 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
370 content::Source<Profile>(profile_->GetOriginalProfile())); 379 content::Source<Profile>(profile_->GetOriginalProfile()));
(...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 1864
1856 service->RestoreMostRecentEntry(tab_restore_service_delegate()); 1865 service->RestoreMostRecentEntry(tab_restore_service_delegate());
1857 } 1866 }
1858 1867
1859 void Browser::WriteCurrentURLToClipboard() { 1868 void Browser::WriteCurrentURLToClipboard() {
1860 // TODO(ericu): There isn't currently a metric for this. Should there be? 1869 // TODO(ericu): There isn't currently a metric for this. Should there be?
1861 // We don't appear to track the action when it comes from the 1870 // We don't appear to track the action when it comes from the
1862 // RenderContextViewMenu. 1871 // RenderContextViewMenu.
1863 1872
1864 WebContents* contents = GetSelectedWebContents(); 1873 WebContents* contents = GetSelectedWebContents();
1865 if (!toolbar_model_.ShouldDisplayURL()) 1874 if (!toolbar_model_->ShouldDisplayURL())
1866 return; 1875 return;
1867 1876
1868 chrome_browser_net::WriteURLToClipboard( 1877 chrome_browser_net::WriteURLToClipboard(
1869 contents->GetURL(), 1878 contents->GetURL(),
1870 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), 1879 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
1871 g_browser_process->clipboard()); 1880 g_browser_process->clipboard());
1872 } 1881 }
1873 1882
1874 void Browser::ConvertPopupToTabbedBrowser() { 1883 void Browser::ConvertPopupToTabbedBrowser() {
1875 content::RecordAction(UserMetricsAction("ShowAsTab")); 1884 content::RecordAction(UserMetricsAction("ShowAsTab"));
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
2909 // static 2918 // static
2910 void Browser::UpdateTargetURLHelper(WebContents* tab, int32 page_id, 2919 void Browser::UpdateTargetURLHelper(WebContents* tab, int32 page_id,
2911 const GURL& url) { 2920 const GURL& url) {
2912 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( 2921 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents(
2913 tab); 2922 tab);
2914 if (!tcw || !tcw->prerender_tab_helper()) 2923 if (!tcw || !tcw->prerender_tab_helper())
2915 return; 2924 return;
2916 tcw->prerender_tab_helper()->UpdateTargetURL(page_id, url); 2925 tcw->prerender_tab_helper()->UpdateTargetURL(page_id, url);
2917 } 2926 }
2918 2927
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);
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
2919 void Browser::ExecuteCommandWithDisposition( 3037 void Browser::ExecuteCommandWithDisposition(
2920 int id, WindowOpenDisposition disposition) { 3038 int id, WindowOpenDisposition disposition) {
2921 // No commands are enabled if there is not yet any selected tab. 3039 // No commands are enabled if there is not yet any selected tab.
2922 // TODO(pkasting): It seems like we should not need this, because either 3040 // TODO(pkasting): It seems like we should not need this, because either
2923 // most/all commands should not have been enabled yet anyway or the ones that 3041 // most/all commands should not have been enabled yet anyway or the ones that
2924 // are enabled should be global, or safe themselves against having no selected 3042 // are enabled should be global, or safe themselves against having no selected
2925 // tab. However, Ben says he tried removing this before and got lots of 3043 // tab. However, Ben says he tried removing this before and got lots of
2926 // crashes, e.g. from Windows sending WM_COMMANDs at random times during 3044 // crashes, e.g. from Windows sending WM_COMMANDs at random times during
2927 // window construction. This probably could use closer examination someday. 3045 // window construction. This probably could use closer examination someday.
2928 if (!GetSelectedTabContentsWrapper()) 3046 if (!GetSelectedTabContentsWrapper())
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
3107 #endif 3225 #endif
3108 case IDC_SHOW_SYNC_SETUP: ShowSyncSetup(); break; 3226 case IDC_SHOW_SYNC_SETUP: ShowSyncSetup(); break;
3109 case IDC_TOGGLE_SPEECH_INPUT: ToggleSpeechInput(); break; 3227 case IDC_TOGGLE_SPEECH_INPUT: ToggleSpeechInput(); break;
3110 3228
3111 default: 3229 default:
3112 LOG(WARNING) << "Received Unimplemented Command: " << id; 3230 LOG(WARNING) << "Received Unimplemented Command: " << id;
3113 break; 3231 break;
3114 } 3232 }
3115 } 3233 }
3116 3234
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
3226 /////////////////////////////////////////////////////////////////////////////// 3235 ///////////////////////////////////////////////////////////////////////////////
3227 // Browser, TabHandlerDelegate implementation: 3236 // Browser, TabHandlerDelegate implementation:
3228 3237
3229 Profile* Browser::GetProfile() const { 3238 Profile* Browser::GetProfile() const {
3230 return profile(); 3239 return profile();
3231 } 3240 }
3232 3241
3233 Browser* Browser::AsBrowser() { 3242 Browser* Browser::AsBrowser() {
3234 return this; 3243 return this;
3235 } 3244 }
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after
4875 // Window management commands 4884 // Window management commands
4876 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, 4885 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB,
4877 !is_app() && CanDuplicateContentsAt(active_index())); 4886 !is_app() && CanDuplicateContentsAt(active_index()));
4878 4887
4879 // Page-related commands 4888 // Page-related commands
4880 window_->SetStarredState( 4889 window_->SetStarredState(
4881 current_tab_wrapper->bookmark_tab_helper()->is_starred()); 4890 current_tab_wrapper->bookmark_tab_helper()->is_starred());
4882 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, 4891 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE,
4883 current_tab->GetController().CanViewSource()); 4892 current_tab->GetController().CanViewSource());
4884 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, 4893 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION,
4885 toolbar_model_.ShouldDisplayURL() && current_tab->GetURL().is_valid()); 4894 toolbar_model_->ShouldDisplayURL() && current_tab->GetURL().is_valid());
4886 if (is_devtools()) 4895 if (is_devtools())
4887 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false); 4896 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false);
4888 4897
4889 // Changing the encoding is not possible on Chrome-internal webpages. 4898 // Changing the encoding is not possible on Chrome-internal webpages.
4890 bool is_chrome_internal = HasInternalURL(nc.GetActiveEntry()) || 4899 bool is_chrome_internal = HasInternalURL(nc.GetActiveEntry()) ||
4891 current_tab->ShowingInterstitialPage(); 4900 current_tab->ShowingInterstitialPage();
4892 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, 4901 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU,
4893 !is_chrome_internal && current_tab->IsSavable()); 4902 !is_chrome_internal && current_tab->IsSavable());
4894 4903
4895 // Show various bits of UI 4904 // Show various bits of UI
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
5626 } else { 5635 } else {
5627 LoginUIServiceFactory::GetForProfile( 5636 LoginUIServiceFactory::GetForProfile(
5628 profile()->GetOriginalProfile())->ShowLoginUI(); 5637 profile()->GetOriginalProfile())->ShowLoginUI();
5629 } 5638 }
5630 #endif 5639 #endif
5631 } 5640 }
5632 5641
5633 void Browser::ToggleSpeechInput() { 5642 void Browser::ToggleSpeechInput() {
5634 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); 5643 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput();
5635 } 5644 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_content_setting_bubble_model_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698