| 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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 // See http://crbug.com/6380. | 567 // See http://crbug.com/6380. |
| 568 b->tab_strip_model()->GetActiveWebContents()->RestoreFocus(); | 568 b->tab_strip_model()->GetActiveWebContents()->RestoreFocus(); |
| 569 } | 569 } |
| 570 } | 570 } |
| 571 | 571 |
| 572 void CloseTab(Browser* browser) { | 572 void CloseTab(Browser* browser) { |
| 573 content::RecordAction(UserMetricsAction("CloseTab_Accelerator")); | 573 content::RecordAction(UserMetricsAction("CloseTab_Accelerator")); |
| 574 browser->tab_strip_model()->CloseSelectedTabs(); | 574 browser->tab_strip_model()->CloseSelectedTabs(); |
| 575 } | 575 } |
| 576 | 576 |
| 577 int GetZoomPercent(content::WebContents* contents) { |
| 578 int zoom = 100; |
| 579 if (contents) { |
| 580 auto zoom_controller = |
| 581 ui_zoom::ZoomController::FromWebContents(contents); |
| 582 if (zoom_controller) |
| 583 zoom = zoom_controller->GetZoomPercent(); |
| 584 } |
| 585 return zoom; |
| 586 } |
| 587 |
| 577 bool CanZoomIn(content::WebContents* contents) { | 588 bool CanZoomIn(content::WebContents* contents) { |
| 578 ui_zoom::ZoomController* zoom_controller = | 589 return contents && !contents->IsCrashed() && |
| 579 ui_zoom::ZoomController::FromWebContents(contents); | 590 GetZoomPercent(contents) != contents->GetMaximumZoomPercent(); |
| 580 return zoom_controller->GetZoomPercent() != contents->GetMaximumZoomPercent(); | |
| 581 } | 591 } |
| 582 | 592 |
| 583 bool CanZoomOut(content::WebContents* contents) { | 593 bool CanZoomOut(content::WebContents* contents) { |
| 584 ui_zoom::ZoomController* zoom_controller = | 594 return contents && !contents->IsCrashed() && |
| 585 ui_zoom::ZoomController::FromWebContents(contents); | 595 GetZoomPercent(contents) != contents->GetMinimumZoomPercent(); |
| 586 return zoom_controller->GetZoomPercent() != | |
| 587 contents->GetMinimumZoomPercent(); | |
| 588 } | 596 } |
| 589 | 597 |
| 590 bool CanResetZoom(content::WebContents* contents) { | 598 bool CanResetZoom(content::WebContents* contents) { |
| 591 ui_zoom::ZoomController* zoom_controller = | 599 ui_zoom::ZoomController* zoom_controller = |
| 592 ui_zoom::ZoomController::FromWebContents(contents); | 600 ui_zoom::ZoomController::FromWebContents(contents); |
| 593 return !zoom_controller->IsAtDefaultZoom() || | 601 return !zoom_controller->IsAtDefaultZoom() || |
| 594 !zoom_controller->PageScaleFactorIsOne(); | 602 !zoom_controller->PageScaleFactorIsOne(); |
| 595 } | 603 } |
| 596 | 604 |
| 597 TabStripModelDelegate::RestoreTabType GetRestoreTabType( | 605 TabStripModelDelegate::RestoreTabType GetRestoreTabType( |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); | 1294 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); |
| 1287 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1295 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
| 1288 | 1296 |
| 1289 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1297 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 1290 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1298 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 1291 app_browser->window()->Show(); | 1299 app_browser->window()->Show(); |
| 1292 } | 1300 } |
| 1293 #endif // defined(ENABLE_EXTENSIONS) | 1301 #endif // defined(ENABLE_EXTENSIONS) |
| 1294 | 1302 |
| 1295 } // namespace chrome | 1303 } // namespace chrome |
| OLD | NEW |