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

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

Issue 310913002: Issue 32919: Update the Zoom NSMenuItems (Zoom-In/Zoom-out/Actual-Size) when the zoom state changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved the unit tests to browser_commands_unittest since its independent of ZoomController Created 6 years, 4 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
OLDNEW
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/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 46 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
47 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 47 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
48 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 48 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
49 #include "chrome/browser/ui/location_bar/location_bar.h" 49 #include "chrome/browser/ui/location_bar/location_bar.h"
50 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 50 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
51 #include "chrome/browser/ui/search/search_tab_helper.h" 51 #include "chrome/browser/ui/search/search_tab_helper.h"
52 #include "chrome/browser/ui/status_bubble.h" 52 #include "chrome/browser/ui/status_bubble.h"
53 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 53 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
54 #include "chrome/browser/ui/tabs/tab_strip_model.h" 54 #include "chrome/browser/ui/tabs/tab_strip_model.h"
55 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" 55 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h"
56 #include "chrome/browser/ui/zoom/zoom_controller.h"
56 #include "chrome/browser/upgrade_detector.h" 57 #include "chrome/browser/upgrade_detector.h"
57 #include "chrome/browser/web_applications/web_app.h" 58 #include "chrome/browser/web_applications/web_app.h"
58 #include "chrome/common/chrome_switches.h" 59 #include "chrome/common/chrome_switches.h"
59 #include "chrome/common/chrome_version_info.h" 60 #include "chrome/common/chrome_version_info.h"
60 #include "chrome/common/content_restriction.h" 61 #include "chrome/common/content_restriction.h"
61 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 62 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
62 #include "chrome/common/pref_names.h" 63 #include "chrome/common/pref_names.h"
63 #include "components/bookmarks/browser/bookmark_model.h" 64 #include "components/bookmarks/browser/bookmark_model.h"
64 #include "components/bookmarks/browser/bookmark_utils.h" 65 #include "components/bookmarks/browser/bookmark_utils.h"
65 #include "components/google/core/browser/google_util.h" 66 #include "components/google/core/browser/google_util.h"
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 // See http://crbug.com/6380. 579 // See http://crbug.com/6380.
579 b->tab_strip_model()->GetActiveWebContents()->RestoreFocus(); 580 b->tab_strip_model()->GetActiveWebContents()->RestoreFocus();
580 } 581 }
581 } 582 }
582 583
583 void CloseTab(Browser* browser) { 584 void CloseTab(Browser* browser) {
584 content::RecordAction(UserMetricsAction("CloseTab_Accelerator")); 585 content::RecordAction(UserMetricsAction("CloseTab_Accelerator"));
585 browser->tab_strip_model()->CloseSelectedTabs(); 586 browser->tab_strip_model()->CloseSelectedTabs();
586 } 587 }
587 588
589 bool CanZoomIn(content::WebContents* contents) {
590 ZoomController* zoom_controller = ZoomController::FromWebContents(contents);
591 return zoom_controller->GetZoomPercent() !=
592 contents->GetMaximumZoomPercent() + 1;
593 }
594
595 bool CanZoomOut(content::WebContents* contents) {
596 ZoomController* zoom_controller = ZoomController::FromWebContents(contents);
597 return zoom_controller->GetZoomPercent() !=
598 contents->GetMinimumZoomPercent();
599 }
600
601 bool ActualSize(content::WebContents* contents) {
602 ZoomController* zoom_controller = ZoomController::FromWebContents(contents);
603 return zoom_controller->GetZoomPercent() != 100.0f;
604 }
605
588 void RestoreTab(Browser* browser) { 606 void RestoreTab(Browser* browser) {
589 content::RecordAction(UserMetricsAction("RestoreTab")); 607 content::RecordAction(UserMetricsAction("RestoreTab"));
590 TabRestoreService* service = 608 TabRestoreService* service =
591 TabRestoreServiceFactory::GetForProfile(browser->profile()); 609 TabRestoreServiceFactory::GetForProfile(browser->profile());
592 if (service) 610 if (service)
593 service->RestoreMostRecentEntry(browser->tab_restore_service_delegate(), 611 service->RestoreMostRecentEntry(browser->tab_restore_service_delegate(),
594 browser->host_desktop_type()); 612 browser->host_desktop_type());
595 } 613 }
596 614
597 TabStripModelDelegate::RestoreTabType GetRestoreTabType( 615 TabStripModelDelegate::RestoreTabType GetRestoreTabType(
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 browser->profile(), 1304 browser->profile(),
1287 browser->host_desktop_type())); 1305 browser->host_desktop_type()));
1288 app_browser->tab_strip_model()->AppendWebContents(contents, true); 1306 app_browser->tab_strip_model()->AppendWebContents(contents, true);
1289 1307
1290 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1308 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1291 contents->GetRenderViewHost()->SyncRendererPrefs(); 1309 contents->GetRenderViewHost()->SyncRendererPrefs();
1292 app_browser->window()->Show(); 1310 app_browser->window()->Show();
1293 } 1311 }
1294 1312
1295 } // namespace chrome 1313 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698