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

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: ut fix 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 #include "chrome/browser/tab_contents/retargeting_details.h" 97 #include "chrome/browser/tab_contents/retargeting_details.h"
98 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" 98 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
99 #include "chrome/browser/tab_contents/tab_util.h" 99 #include "chrome/browser/tab_contents/tab_util.h"
100 #include "chrome/browser/tabs/tab_finder.h" 100 #include "chrome/browser/tabs/tab_finder.h"
101 #include "chrome/browser/tabs/tab_strip_model.h" 101 #include "chrome/browser/tabs/tab_strip_model.h"
102 #include "chrome/browser/themes/theme_service.h" 102 #include "chrome/browser/themes/theme_service.h"
103 #include "chrome/browser/themes/theme_service_factory.h" 103 #include "chrome/browser/themes/theme_service_factory.h"
104 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" 104 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h"
105 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" 105 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
106 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" 106 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
107 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h"
107 #include "chrome/browser/ui/browser_dialogs.h" 108 #include "chrome/browser/ui/browser_dialogs.h"
108 #include "chrome/browser/ui/browser_list.h" 109 #include "chrome/browser/ui/browser_list.h"
109 #include "chrome/browser/ui/browser_navigator.h" 110 #include "chrome/browser/ui/browser_navigator.h"
110 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" 111 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h"
112 #include "chrome/browser/ui/browser_toolbar_model_host.h"
111 #include "chrome/browser/ui/browser_window.h" 113 #include "chrome/browser/ui/browser_window.h"
112 #include "chrome/browser/ui/constrained_window_tab_helper.h" 114 #include "chrome/browser/ui/constrained_window_tab_helper.h"
113 #include "chrome/browser/ui/extensions/shell_window.h" 115 #include "chrome/browser/ui/extensions/shell_window.h"
114 #include "chrome/browser/ui/find_bar/find_bar.h" 116 #include "chrome/browser/ui/find_bar/find_bar.h"
115 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 117 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
116 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 118 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
117 #include "chrome/browser/ui/fullscreen_controller.h" 119 #include "chrome/browser/ui/fullscreen_controller.h"
118 #include "chrome/browser/ui/global_error.h" 120 #include "chrome/browser/ui/global_error.h"
119 #include "chrome/browser/ui/global_error_service.h" 121 #include "chrome/browser/ui/global_error_service.h"
120 #include "chrome/browser/ui/global_error_service_factory.h" 122 #include "chrome/browser/ui/global_error_service_factory.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 /////////////////////////////////////////////////////////////////////////////// 335 ///////////////////////////////////////////////////////////////////////////////
334 // Browser, Constructors, Creation, Showing: 336 // Browser, Constructors, Creation, Showing:
335 337
336 Browser::Browser(Type type, Profile* profile) 338 Browser::Browser(Type type, Profile* profile)
337 : type_(type), 339 : type_(type),
338 profile_(profile), 340 profile_(profile),
339 window_(NULL), 341 window_(NULL),
340 ALLOW_THIS_IN_INITIALIZER_LIST( 342 ALLOW_THIS_IN_INITIALIZER_LIST(
341 tab_handler_(TabHandler::CreateTabHandler(this))), 343 tab_handler_(TabHandler::CreateTabHandler(this))),
342 command_updater_(this), 344 command_updater_(this),
343 toolbar_model_(this),
344 chrome_updater_factory_(this), 345 chrome_updater_factory_(this),
345 is_attempting_to_close_browser_(false), 346 is_attempting_to_close_browser_(false),
346 cancel_download_confirmation_state_(NOT_PROMPTED), 347 cancel_download_confirmation_state_(NOT_PROMPTED),
347 show_state_(ui::SHOW_STATE_DEFAULT), 348 show_state_(ui::SHOW_STATE_DEFAULT),
348 is_session_restore_(false), 349 is_session_restore_(false),
349 weak_factory_(this), 350 weak_factory_(this),
350 block_command_execution_(false), 351 block_command_execution_(false),
351 last_blocked_command_id_(-1), 352 last_blocked_command_id_(-1),
352 last_blocked_command_disposition_(CURRENT_TAB), 353 last_blocked_command_disposition_(CURRENT_TAB),
353 pending_web_app_action_(NONE), 354 pending_web_app_action_(NONE),
354 ALLOW_THIS_IN_INITIALIZER_LIST( 355 ALLOW_THIS_IN_INITIALIZER_LIST(
356 content_setting_bubble_model_delegate_(
357 new BrowserContentSettingBubbleModelDelegate(this))),
358 ALLOW_THIS_IN_INITIALIZER_LIST(
359 toolbar_model_host_(
360 new BrowserToolbarModelHost(this))),
361 ALLOW_THIS_IN_INITIALIZER_LIST(
355 tab_restore_service_delegate_( 362 tab_restore_service_delegate_(
356 new BrowserTabRestoreServiceDelegate(this))), 363 new BrowserTabRestoreServiceDelegate(this))),
357 ALLOW_THIS_IN_INITIALIZER_LIST( 364 ALLOW_THIS_IN_INITIALIZER_LIST(
358 synced_window_delegate_( 365 synced_window_delegate_(
359 new BrowserSyncedWindowDelegate(this))), 366 new BrowserSyncedWindowDelegate(this))),
360 bookmark_bar_state_(BookmarkBar::HIDDEN), 367 bookmark_bar_state_(BookmarkBar::HIDDEN),
361 window_has_shown_(false) { 368 window_has_shown_(false) {
369 toolbar_model_.reset(new ToolbarModel(toolbar_model_host_.get()));
370
362 registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, 371 registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED,
363 content::NotificationService::AllSources()); 372 content::NotificationService::AllSources());
364 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, 373 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
365 content::Source<Profile>(profile_->GetOriginalProfile())); 374 content::Source<Profile>(profile_->GetOriginalProfile()));
366 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 375 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
367 content::Source<Profile>(profile_->GetOriginalProfile())); 376 content::Source<Profile>(profile_->GetOriginalProfile()));
368 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 377 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
369 content::Source<Profile>(profile_->GetOriginalProfile())); 378 content::Source<Profile>(profile_->GetOriginalProfile()));
370 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 379 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
371 content::Source<Profile>(profile_->GetOriginalProfile())); 380 content::Source<Profile>(profile_->GetOriginalProfile()));
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 1863
1855 service->RestoreMostRecentEntry(tab_restore_service_delegate()); 1864 service->RestoreMostRecentEntry(tab_restore_service_delegate());
1856 } 1865 }
1857 1866
1858 void Browser::WriteCurrentURLToClipboard() { 1867 void Browser::WriteCurrentURLToClipboard() {
1859 // TODO(ericu): There isn't currently a metric for this. Should there be? 1868 // TODO(ericu): There isn't currently a metric for this. Should there be?
1860 // We don't appear to track the action when it comes from the 1869 // We don't appear to track the action when it comes from the
1861 // RenderContextViewMenu. 1870 // RenderContextViewMenu.
1862 1871
1863 WebContents* contents = GetSelectedWebContents(); 1872 WebContents* contents = GetSelectedWebContents();
1864 if (!toolbar_model_.ShouldDisplayURL()) 1873 if (!toolbar_model_->ShouldDisplayURL())
1865 return; 1874 return;
1866 1875
1867 chrome_browser_net::WriteURLToClipboard( 1876 chrome_browser_net::WriteURLToClipboard(
1868 contents->GetURL(), 1877 contents->GetURL(),
1869 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), 1878 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
1870 g_browser_process->clipboard()); 1879 g_browser_process->clipboard());
1871 } 1880 }
1872 1881
1873 void Browser::ConvertPopupToTabbedBrowser() { 1882 void Browser::ConvertPopupToTabbedBrowser() {
1874 content::RecordAction(UserMetricsAction("ShowAsTab")); 1883 content::RecordAction(UserMetricsAction("ShowAsTab"));
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
2948 // static 2957 // static
2949 void Browser::UpdateTargetURLHelper(WebContents* tab, int32 page_id, 2958 void Browser::UpdateTargetURLHelper(WebContents* tab, int32 page_id,
2950 const GURL& url) { 2959 const GURL& url) {
2951 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( 2960 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents(
2952 tab); 2961 tab);
2953 if (!tcw || !tcw->prerender_tab_helper()) 2962 if (!tcw || !tcw->prerender_tab_helper())
2954 return; 2963 return;
2955 tcw->prerender_tab_helper()->UpdateTargetURL(page_id, url); 2964 tcw->prerender_tab_helper()->UpdateTargetURL(page_id, url);
2956 } 2965 }
2957 2966
2967 void Browser::ExecuteCommand(int id) {
2968 ExecuteCommandWithDisposition(id, CURRENT_TAB);
2969 }
2970
2971 void Browser::ExecuteCommand(int id, int event_flags) {
2972 ExecuteCommandWithDisposition(
2973 id, browser::DispositionFromEventFlags(event_flags));
2974 }
2975
2976 bool Browser::ExecuteCommandIfEnabled(int id) {
2977 if (command_updater_.SupportsCommand(id) &&
2978 command_updater_.IsCommandEnabled(id)) {
2979 ExecuteCommand(id, CURRENT_TAB);
2980 return true;
2981 }
2982 return false;
2983 }
2984
2985 bool Browser::IsReservedCommandOrKey(int command_id,
2986 const NativeWebKeyboardEvent& event) {
2987 #if defined(OS_CHROMEOS)
2988 // Chrome OS's top row of keys produces F1-10. Make sure that web pages
2989 // aren't able to block Chrome from performing the standard actions for F1-F4
2990 // (F5-7 are grabbed by other X clients and hence don't need this protection,
2991 // and F8-10 are handled separately in Chrome via a GDK event filter, but
2992 // let's future-proof this).
2993 ui::KeyboardCode key_code =
2994 static_cast<ui::KeyboardCode>(event.windowsKeyCode);
2995 if (key_code == ui::VKEY_F1 ||
2996 key_code == ui::VKEY_F2 ||
2997 key_code == ui::VKEY_F3 ||
2998 key_code == ui::VKEY_F4 ||
2999 key_code == ui::VKEY_F5 ||
3000 key_code == ui::VKEY_F6 ||
3001 key_code == ui::VKEY_F7 ||
3002 key_code == ui::VKEY_F8 ||
3003 key_code == ui::VKEY_F9 ||
3004 key_code == ui::VKEY_F10) {
3005 return true;
3006 }
3007 #endif
3008
3009 if (window_->IsFullscreen() && command_id == IDC_FULLSCREEN)
3010 return true;
3011 return command_id == IDC_CLOSE_TAB ||
3012 command_id == IDC_CLOSE_WINDOW ||
3013 command_id == IDC_NEW_INCOGNITO_WINDOW ||
3014 command_id == IDC_NEW_TAB ||
3015 command_id == IDC_NEW_WINDOW ||
3016 command_id == IDC_RESTORE_TAB ||
3017 command_id == IDC_SELECT_NEXT_TAB ||
3018 command_id == IDC_SELECT_PREVIOUS_TAB ||
3019 command_id == IDC_TABPOSE ||
3020 command_id == IDC_EXIT ||
3021 command_id == IDC_SEARCH;
3022 }
3023
3024 void Browser::SetBlockCommandExecution(bool block) {
3025 block_command_execution_ = block;
3026 if (block) {
3027 last_blocked_command_id_ = -1;
3028 last_blocked_command_disposition_ = CURRENT_TAB;
3029 }
3030 }
3031
3032 int Browser::GetLastBlockedCommand(WindowOpenDisposition* disposition) {
3033 if (disposition)
3034 *disposition = last_blocked_command_disposition_;
3035 return last_blocked_command_id_;
3036 }
3037
3038 void Browser::UpdateUIForNavigationInTab(TabContentsWrapper* contents,
3039 content::PageTransition transition,
3040 bool user_initiated) {
3041 tab_handler_->GetTabStripModel()->TabNavigating(contents, transition);
3042
3043 bool contents_is_selected = contents == GetSelectedTabContentsWrapper();
3044 if (user_initiated && contents_is_selected && window()->GetLocationBar()) {
3045 // Forcibly reset the location bar if the url is going to change in the
3046 // current tab, since otherwise it won't discard any ongoing user edits,
3047 // since it doesn't realize this is a user-initiated action.
3048 window()->GetLocationBar()->Revert();
3049 }
3050
3051 if (GetStatusBubble())
3052 GetStatusBubble()->Hide();
3053
3054 // Update the location bar. This is synchronous. We specifically don't
3055 // update the load state since the load hasn't started yet and updating it
3056 // will put it out of sync with the actual state like whether we're
3057 // displaying a favicon, which controls the throbber. If we updated it here,
3058 // the throbber will show the default favicon for a split second when
3059 // navigating away from the new tab page.
3060 ScheduleUIUpdate(contents->web_contents(), content::INVALIDATE_TYPE_URL);
3061
3062 if (contents_is_selected)
3063 contents->web_contents()->Focus();
3064 }
3065
3066 ///////////////////////////////////////////////////////////////////////////////
3067 // Browser, PageNavigator implementation:
3068
3069 WebContents* Browser::OpenURL(const OpenURLParams& params) {
3070 return OpenURLFromTab(NULL, params);
3071 }
3072
3073 ///////////////////////////////////////////////////////////////////////////////
3074 // Browser, CommandUpdater::CommandUpdaterDelegate implementation:
3075
2958 void Browser::ExecuteCommandWithDisposition( 3076 void Browser::ExecuteCommandWithDisposition(
2959 int id, WindowOpenDisposition disposition) { 3077 int id, WindowOpenDisposition disposition) {
2960 // No commands are enabled if there is not yet any selected tab. 3078 // No commands are enabled if there is not yet any selected tab.
2961 // TODO(pkasting): It seems like we should not need this, because either 3079 // TODO(pkasting): It seems like we should not need this, because either
2962 // most/all commands should not have been enabled yet anyway or the ones that 3080 // most/all commands should not have been enabled yet anyway or the ones that
2963 // are enabled should be global, or safe themselves against having no selected 3081 // are enabled should be global, or safe themselves against having no selected
2964 // tab. However, Ben says he tried removing this before and got lots of 3082 // tab. However, Ben says he tried removing this before and got lots of
2965 // crashes, e.g. from Windows sending WM_COMMANDs at random times during 3083 // crashes, e.g. from Windows sending WM_COMMANDs at random times during
2966 // window construction. This probably could use closer examination someday. 3084 // window construction. This probably could use closer examination someday.
2967 if (!GetSelectedTabContentsWrapper()) 3085 if (!GetSelectedTabContentsWrapper())
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
3145 #endif 3263 #endif
3146 case IDC_SHOW_SYNC_SETUP: ShowSyncSetup(); break; 3264 case IDC_SHOW_SYNC_SETUP: ShowSyncSetup(); break;
3147 case IDC_TOGGLE_SPEECH_INPUT: ToggleSpeechInput(); break; 3265 case IDC_TOGGLE_SPEECH_INPUT: ToggleSpeechInput(); break;
3148 3266
3149 default: 3267 default:
3150 LOG(WARNING) << "Received Unimplemented Command: " << id; 3268 LOG(WARNING) << "Received Unimplemented Command: " << id;
3151 break; 3269 break;
3152 } 3270 }
3153 } 3271 }
3154 3272
3155 void Browser::ExecuteCommand(int id, int event_flags) {
3156 ExecuteCommandWithDisposition(
3157 id, browser::DispositionFromEventFlags(event_flags));
3158 }
3159
3160 bool Browser::ExecuteCommandIfEnabled(int id) {
3161 if (command_updater_.SupportsCommand(id) &&
3162 command_updater_.IsCommandEnabled(id)) {
3163 ExecuteCommand(id);
3164 return true;
3165 }
3166 return false;
3167 }
3168
3169 bool Browser::IsReservedCommandOrKey(int command_id,
3170 const NativeWebKeyboardEvent& event) {
3171 #if defined(OS_CHROMEOS)
3172 // Chrome OS's top row of keys produces F1-10. Make sure that web pages
3173 // aren't able to block Chrome from performing the standard actions for F1-F4
3174 // (F5-7 are grabbed by other X clients and hence don't need this protection,
3175 // and F8-10 are handled separately in Chrome via a GDK event filter, but
3176 // let's future-proof this).
3177 ui::KeyboardCode key_code =
3178 static_cast<ui::KeyboardCode>(event.windowsKeyCode);
3179 if (key_code == ui::VKEY_F1 ||
3180 key_code == ui::VKEY_F2 ||
3181 key_code == ui::VKEY_F3 ||
3182 key_code == ui::VKEY_F4 ||
3183 key_code == ui::VKEY_F5 ||
3184 key_code == ui::VKEY_F6 ||
3185 key_code == ui::VKEY_F7 ||
3186 key_code == ui::VKEY_F8 ||
3187 key_code == ui::VKEY_F9 ||
3188 key_code == ui::VKEY_F10) {
3189 return true;
3190 }
3191 #endif
3192
3193 if (window_->IsFullscreen() && command_id == IDC_FULLSCREEN)
3194 return true;
3195 return command_id == IDC_CLOSE_TAB ||
3196 command_id == IDC_CLOSE_WINDOW ||
3197 command_id == IDC_NEW_INCOGNITO_WINDOW ||
3198 command_id == IDC_NEW_TAB ||
3199 command_id == IDC_NEW_WINDOW ||
3200 command_id == IDC_RESTORE_TAB ||
3201 command_id == IDC_SELECT_NEXT_TAB ||
3202 command_id == IDC_SELECT_PREVIOUS_TAB ||
3203 command_id == IDC_TABPOSE ||
3204 command_id == IDC_EXIT ||
3205 command_id == IDC_SEARCH;
3206 }
3207
3208 void Browser::SetBlockCommandExecution(bool block) {
3209 block_command_execution_ = block;
3210 if (block) {
3211 last_blocked_command_id_ = -1;
3212 last_blocked_command_disposition_ = CURRENT_TAB;
3213 }
3214 }
3215
3216 int Browser::GetLastBlockedCommand(WindowOpenDisposition* disposition) {
3217 if (disposition)
3218 *disposition = last_blocked_command_disposition_;
3219 return last_blocked_command_id_;
3220 }
3221
3222 void Browser::UpdateUIForNavigationInTab(TabContentsWrapper* contents,
3223 content::PageTransition transition,
3224 bool user_initiated) {
3225 tab_handler_->GetTabStripModel()->TabNavigating(contents, transition);
3226
3227 bool contents_is_selected = contents == GetSelectedTabContentsWrapper();
3228 if (user_initiated && contents_is_selected && window()->GetLocationBar()) {
3229 // Forcibly reset the location bar if the url is going to change in the
3230 // current tab, since otherwise it won't discard any ongoing user edits,
3231 // since it doesn't realize this is a user-initiated action.
3232 window()->GetLocationBar()->Revert();
3233 }
3234
3235 if (GetStatusBubble())
3236 GetStatusBubble()->Hide();
3237
3238 // Update the location bar. This is synchronous. We specifically don't
3239 // update the load state since the load hasn't started yet and updating it
3240 // will put it out of sync with the actual state like whether we're
3241 // displaying a favicon, which controls the throbber. If we updated it here,
3242 // the throbber will show the default favicon for a split second when
3243 // navigating away from the new tab page.
3244 ScheduleUIUpdate(contents->web_contents(), content::INVALIDATE_TYPE_URL);
3245
3246 if (contents_is_selected)
3247 contents->web_contents()->Focus();
3248 }
3249
3250 ///////////////////////////////////////////////////////////////////////////////
3251 // Browser, PageNavigator implementation:
3252
3253 WebContents* Browser::OpenURL(const OpenURLParams& params) {
3254 return OpenURLFromTab(NULL, params);
3255 }
3256
3257 ///////////////////////////////////////////////////////////////////////////////
3258 // Browser, CommandUpdater::CommandUpdaterDelegate implementation:
3259
3260 void Browser::ExecuteCommand(int id) {
3261 ExecuteCommandWithDisposition(id, CURRENT_TAB);
3262 }
3263
3264 /////////////////////////////////////////////////////////////////////////////// 3273 ///////////////////////////////////////////////////////////////////////////////
3265 // Browser, TabHandlerDelegate implementation: 3274 // Browser, TabHandlerDelegate implementation:
3266 3275
3267 Profile* Browser::GetProfile() const { 3276 Profile* Browser::GetProfile() const {
3268 return profile(); 3277 return profile();
3269 } 3278 }
3270 3279
3271 Browser* Browser::AsBrowser() { 3280 Browser* Browser::AsBrowser() {
3272 return this; 3281 return this;
3273 } 3282 }
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after
4901 // Window management commands 4910 // Window management commands
4902 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, 4911 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB,
4903 !is_app() && CanDuplicateContentsAt(active_index())); 4912 !is_app() && CanDuplicateContentsAt(active_index()));
4904 4913
4905 // Page-related commands 4914 // Page-related commands
4906 window_->SetStarredState( 4915 window_->SetStarredState(
4907 current_tab_wrapper->bookmark_tab_helper()->is_starred()); 4916 current_tab_wrapper->bookmark_tab_helper()->is_starred());
4908 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, 4917 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE,
4909 current_tab->GetController().CanViewSource()); 4918 current_tab->GetController().CanViewSource());
4910 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, 4919 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION,
4911 toolbar_model_.ShouldDisplayURL() && current_tab->GetURL().is_valid()); 4920 toolbar_model_->ShouldDisplayURL() && current_tab->GetURL().is_valid());
4912 if (is_devtools()) 4921 if (is_devtools())
4913 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false); 4922 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false);
4914 4923
4915 // Changing the encoding is not possible on Chrome-internal webpages. 4924 // Changing the encoding is not possible on Chrome-internal webpages.
4916 bool is_chrome_internal = HasInternalURL(nc.GetActiveEntry()) || 4925 bool is_chrome_internal = HasInternalURL(nc.GetActiveEntry()) ||
4917 current_tab->ShowingInterstitialPage(); 4926 current_tab->ShowingInterstitialPage();
4918 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, 4927 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU,
4919 !is_chrome_internal && current_tab->IsSavable()); 4928 !is_chrome_internal && current_tab->IsSavable());
4920 4929
4921 // Show various bits of UI 4930 // Show various bits of UI
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
5648 ShowSingletonTabOverwritingNTP(params); 5657 ShowSingletonTabOverwritingNTP(params);
5649 } else { 5658 } else {
5650 LoginUIServiceFactory::GetForProfile( 5659 LoginUIServiceFactory::GetForProfile(
5651 profile()->GetOriginalProfile())->ShowLoginUI(); 5660 profile()->GetOriginalProfile())->ShowLoginUI();
5652 } 5661 }
5653 } 5662 }
5654 5663
5655 void Browser::ToggleSpeechInput() { 5664 void Browser::ToggleSpeechInput() {
5656 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); 5665 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput();
5657 } 5666 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698