OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_commands.h" | 5 #include "chrome/browser/ui/browser_commands.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "chrome/browser/ui/browser_finder.h" | 41 #include "chrome/browser/ui/browser_finder.h" |
42 #include "chrome/browser/ui/browser_instant_controller.h" | 42 #include "chrome/browser/ui/browser_instant_controller.h" |
43 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" | 43 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" |
44 #include "chrome/browser/ui/browser_tabstrip.h" | 44 #include "chrome/browser/ui/browser_tabstrip.h" |
45 #include "chrome/browser/ui/browser_window.h" | 45 #include "chrome/browser/ui/browser_window.h" |
46 #include "chrome/browser/ui/chrome_pages.h" | 46 #include "chrome/browser/ui/chrome_pages.h" |
47 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 47 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
48 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 48 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
49 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 49 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
50 #include "chrome/browser/ui/omnibox/location_bar.h" | 50 #include "chrome/browser/ui/omnibox/location_bar.h" |
51 #include "chrome/browser/ui/search/search.h" | |
52 #include "chrome/browser/ui/search/search_model.h" | |
53 #include "chrome/browser/ui/status_bubble.h" | 51 #include "chrome/browser/ui/status_bubble.h" |
54 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 52 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
55 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" | 53 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" |
56 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 54 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
57 #include "chrome/browser/web_applications/web_app.h" | 55 #include "chrome/browser/web_applications/web_app.h" |
58 #include "chrome/common/chrome_switches.h" | 56 #include "chrome/common/chrome_switches.h" |
59 #include "chrome/common/pref_names.h" | 57 #include "chrome/common/pref_names.h" |
60 #include "content/public/browser/devtools_agent_host.h" | 58 #include "content/public/browser/devtools_agent_host.h" |
61 #include "content/public/browser/navigation_controller.h" | 59 #include "content/public/browser/navigation_controller.h" |
62 #include "content/public/browser/navigation_entry.h" | 60 #include "content/public/browser/navigation_entry.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 184 } |
187 | 185 |
188 bool PrintPreviewShowing(const Browser* browser) { | 186 bool PrintPreviewShowing(const Browser* browser) { |
189 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); | 187 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); |
190 printing::PrintPreviewDialogController* controller = | 188 printing::PrintPreviewDialogController* controller = |
191 printing::PrintPreviewDialogController::GetInstance(); | 189 printing::PrintPreviewDialogController::GetInstance(); |
192 return controller && (controller->GetPrintPreviewForContents(contents) || | 190 return controller && (controller->GetPrintPreviewForContents(contents) || |
193 controller->is_creating_print_preview_dialog()); | 191 controller->is_creating_print_preview_dialog()); |
194 } | 192 } |
195 | 193 |
196 bool IsNTPModeForInstantExtendedAPI(const Browser* browser) { | |
197 return browser->search_model() && | |
198 search::IsInstantExtendedAPIEnabled(browser->profile()) && | |
199 browser->search_model()->mode().is_ntp(); | |
200 } | |
201 | |
202 } // namespace | 194 } // namespace |
203 | 195 |
204 bool IsCommandEnabled(Browser* browser, int command) { | 196 bool IsCommandEnabled(Browser* browser, int command) { |
205 return browser->command_controller()->command_updater()->IsCommandEnabled( | 197 return browser->command_controller()->command_updater()->IsCommandEnabled( |
206 command); | 198 command); |
207 } | 199 } |
208 | 200 |
209 bool SupportsCommand(Browser* browser, int command) { | 201 bool SupportsCommand(Browser* browser, int command) { |
210 return browser->command_controller()->command_updater()->SupportsCommand( | 202 return browser->command_controller()->command_updater()->SupportsCommand( |
211 command); | 203 command); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 content::RecordAction(UserMetricsAction("Reload")); | 372 content::RecordAction(UserMetricsAction("Reload")); |
381 ReloadInternal(browser, disposition, false); | 373 ReloadInternal(browser, disposition, false); |
382 } | 374 } |
383 | 375 |
384 void ReloadIgnoringCache(Browser* browser, WindowOpenDisposition disposition) { | 376 void ReloadIgnoringCache(Browser* browser, WindowOpenDisposition disposition) { |
385 content::RecordAction(UserMetricsAction("ReloadIgnoringCache")); | 377 content::RecordAction(UserMetricsAction("ReloadIgnoringCache")); |
386 ReloadInternal(browser, disposition, true); | 378 ReloadInternal(browser, disposition, true); |
387 } | 379 } |
388 | 380 |
389 bool CanReload(const Browser* browser) { | 381 bool CanReload(const Browser* browser) { |
390 return !browser->is_devtools() && !IsNTPModeForInstantExtendedAPI(browser); | 382 return !browser->is_devtools(); |
391 } | 383 } |
392 | 384 |
393 void Home(Browser* browser, WindowOpenDisposition disposition) { | 385 void Home(Browser* browser, WindowOpenDisposition disposition) { |
394 content::RecordAction(UserMetricsAction("Home")); | 386 content::RecordAction(UserMetricsAction("Home")); |
395 | 387 |
396 std::string extra_headers; | 388 std::string extra_headers; |
397 #if defined(ENABLE_RLZ) | 389 #if defined(ENABLE_RLZ) |
398 // If the home page is a Google home page, add the RLZ header to the request. | 390 // If the home page is a Google home page, add the RLZ header to the request. |
399 PrefService* pref_service = browser->profile()->GetPrefs(); | 391 PrefService* pref_service = browser->profile()->GetPrefs(); |
400 if (pref_service) { | 392 if (pref_service) { |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 if (browser->profile()->GetPrefs()->GetBoolean( | 720 if (browser->profile()->GetPrefs()->GetBoolean( |
729 prefs::kPrintPreviewDisabled)) | 721 prefs::kPrintPreviewDisabled)) |
730 print_view_manager->PrintNow(); | 722 print_view_manager->PrintNow(); |
731 else | 723 else |
732 print_view_manager->PrintPreviewNow(false); | 724 print_view_manager->PrintPreviewNow(false); |
733 } | 725 } |
734 | 726 |
735 bool CanPrint(const Browser* browser) { | 727 bool CanPrint(const Browser* browser) { |
736 // Do not print when printing is disabled via pref or policy. | 728 // Do not print when printing is disabled via pref or policy. |
737 // Do not print when a constrained window is showing. It's confusing. | 729 // Do not print when a constrained window is showing. It's confusing. |
738 // Do not print if instant extended API is enabled and mode is NTP. | |
739 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && | 730 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
740 !(IsShowingWebContentsModalDialog(browser) || | 731 !(IsShowingWebContentsModalDialog(browser) || |
741 GetContentRestrictions(browser) & content::CONTENT_RESTRICTION_PRINT || | 732 GetContentRestrictions(browser) & content::CONTENT_RESTRICTION_PRINT); |
742 IsNTPModeForInstantExtendedAPI(browser)); | |
743 } | 733 } |
744 | 734 |
745 void AdvancedPrint(Browser* browser) { | 735 void AdvancedPrint(Browser* browser) { |
746 printing::PrintViewManager* print_view_manager = | 736 printing::PrintViewManager* print_view_manager = |
747 printing::PrintViewManager::FromWebContents( | 737 printing::PrintViewManager::FromWebContents( |
748 browser->tab_strip_model()->GetActiveWebContents()); | 738 browser->tab_strip_model()->GetActiveWebContents()); |
749 print_view_manager->AdvancedPrintNow(); | 739 print_view_manager->AdvancedPrintNow(); |
750 } | 740 } |
751 | 741 |
752 bool CanAdvancedPrint(const Browser* browser) { | 742 bool CanAdvancedPrint(const Browser* browser) { |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 Browser::CreateParams::CreateForApp( | 1082 Browser::CreateParams::CreateForApp( |
1093 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile())); | 1083 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile())); |
1094 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1084 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
1095 | 1085 |
1096 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1086 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
1097 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1087 contents->GetRenderViewHost()->SyncRendererPrefs(); |
1098 app_browser->window()->Show(); | 1088 app_browser->window()->Show(); |
1099 } | 1089 } |
1100 | 1090 |
1101 } // namespace chrome | 1091 } // namespace chrome |
OLD | NEW |