| OLD | NEW |
| 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/views/wrench_menu.h" | 5 #include "chrome/browser/ui/views/wrench_menu.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 const content::NotificationSource& source, | 542 const content::NotificationSource& source, |
| 543 const content::NotificationDetails& details) { | 543 const content::NotificationDetails& details) { |
| 544 DCHECK_EQ(content::NOTIFICATION_ZOOM_LEVEL_CHANGED, type); | 544 DCHECK_EQ(content::NOTIFICATION_ZOOM_LEVEL_CHANGED, type); |
| 545 UpdateZoomControls(); | 545 UpdateZoomControls(); |
| 546 } | 546 } |
| 547 | 547 |
| 548 private: | 548 private: |
| 549 void UpdateZoomControls() { | 549 void UpdateZoomControls() { |
| 550 bool enable_increment = false; | 550 bool enable_increment = false; |
| 551 bool enable_decrement = false; | 551 bool enable_decrement = false; |
| 552 WebContents* selected_tab = menu_->browser_->GetSelectedWebContents(); | 552 WebContents* selected_tab = menu_->browser_->GetActiveWebContents(); |
| 553 int zoom = 100; | 553 int zoom = 100; |
| 554 if (selected_tab) | 554 if (selected_tab) |
| 555 zoom = selected_tab->GetZoomPercent(&enable_increment, &enable_decrement); | 555 zoom = selected_tab->GetZoomPercent(&enable_increment, &enable_decrement); |
| 556 increment_button_->SetEnabled(enable_increment); | 556 increment_button_->SetEnabled(enable_increment); |
| 557 decrement_button_->SetEnabled(enable_decrement); | 557 decrement_button_->SetEnabled(enable_decrement); |
| 558 zoom_label_->SetText( | 558 zoom_label_->SetText( |
| 559 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, zoom)); | 559 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, zoom)); |
| 560 | 560 |
| 561 zoom_label_width_ = MaxWidthForZoomLabel(); | 561 zoom_label_width_ = MaxWidthForZoomLabel(); |
| 562 } | 562 } |
| 563 | 563 |
| 564 // Calculates the max width the zoom string can be. | 564 // Calculates the max width the zoom string can be. |
| 565 int MaxWidthForZoomLabel() { | 565 int MaxWidthForZoomLabel() { |
| 566 gfx::Font font = zoom_label_->font(); | 566 gfx::Font font = zoom_label_->font(); |
| 567 gfx::Insets insets; | 567 gfx::Insets insets; |
| 568 if (zoom_label_->border()) | 568 if (zoom_label_->border()) |
| 569 zoom_label_->border()->GetInsets(&insets); | 569 zoom_label_->border()->GetInsets(&insets); |
| 570 | 570 |
| 571 int max_w = 0; | 571 int max_w = 0; |
| 572 | 572 |
| 573 WebContents* selected_tab = menu_->browser_->GetSelectedWebContents(); | 573 WebContents* selected_tab = menu_->browser_->GetActiveWebContents(); |
| 574 if (selected_tab) { | 574 if (selected_tab) { |
| 575 int min_percent = selected_tab->GetMinimumZoomPercent(); | 575 int min_percent = selected_tab->GetMinimumZoomPercent(); |
| 576 int max_percent = selected_tab->GetMaximumZoomPercent(); | 576 int max_percent = selected_tab->GetMaximumZoomPercent(); |
| 577 | 577 |
| 578 int step = (max_percent - min_percent) / 10; | 578 int step = (max_percent - min_percent) / 10; |
| 579 for (int i = min_percent; i <= max_percent; i += step) { | 579 for (int i = min_percent; i <= max_percent; i += step) { |
| 580 int w = font.GetStringWidth( | 580 int w = font.GetStringWidth( |
| 581 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, i)); | 581 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, i)); |
| 582 max_w = std::max(w, max_w); | 582 max_w = std::max(w, max_w); |
| 583 } | 583 } |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 bookmark_menu_delegate_.reset( | 960 bookmark_menu_delegate_.reset( |
| 961 new BookmarkMenuDelegate(browser_->profile(), | 961 new BookmarkMenuDelegate(browser_->profile(), |
| 962 NULL, | 962 NULL, |
| 963 parent, | 963 parent, |
| 964 first_bookmark_command_id_)); | 964 first_bookmark_command_id_)); |
| 965 bookmark_menu_delegate_->Init( | 965 bookmark_menu_delegate_->Init( |
| 966 this, bookmark_menu_, model->bookmark_bar_node(), 0, | 966 this, bookmark_menu_, model->bookmark_bar_node(), 0, |
| 967 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 967 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
| 968 bookmark_utils::LAUNCH_WRENCH_MENU); | 968 bookmark_utils::LAUNCH_WRENCH_MENU); |
| 969 } | 969 } |
| OLD | NEW |