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

Side by Side Diff: chrome/browser/ui/views/wrench_menu.cc

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 27 matching lines...) Expand all
38 #include "ui/views/controls/button/text_button.h" 38 #include "ui/views/controls/button/text_button.h"
39 #include "ui/views/controls/label.h" 39 #include "ui/views/controls/label.h"
40 #include "ui/views/controls/menu/menu_config.h" 40 #include "ui/views/controls/menu/menu_config.h"
41 #include "ui/views/controls/menu/menu_item_view.h" 41 #include "ui/views/controls/menu/menu_item_view.h"
42 #include "ui/views/controls/menu/menu_runner.h" 42 #include "ui/views/controls/menu/menu_runner.h"
43 #include "ui/views/controls/menu/menu_scroll_view_container.h" 43 #include "ui/views/controls/menu/menu_scroll_view_container.h"
44 #include "ui/views/controls/menu/submenu_view.h" 44 #include "ui/views/controls/menu/submenu_view.h"
45 #include "ui/views/widget/widget.h" 45 #include "ui/views/widget/widget.h"
46 46
47 using content::UserMetricsAction; 47 using content::UserMetricsAction;
48 using content::WebContents;
48 using ui::MenuModel; 49 using ui::MenuModel;
49 using views::CustomButton; 50 using views::CustomButton;
50 using views::ImageButton; 51 using views::ImageButton;
51 using views::Label; 52 using views::Label;
52 using views::MenuConfig; 53 using views::MenuConfig;
53 using views::MenuItemView; 54 using views::MenuItemView;
54 using views::TextButton; 55 using views::TextButton;
55 using views::View; 56 using views::View;
56 57
57 namespace { 58 namespace {
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 const content::NotificationSource& source, 499 const content::NotificationSource& source,
499 const content::NotificationDetails& details) { 500 const content::NotificationDetails& details) {
500 DCHECK_EQ(content::NOTIFICATION_ZOOM_LEVEL_CHANGED, type); 501 DCHECK_EQ(content::NOTIFICATION_ZOOM_LEVEL_CHANGED, type);
501 UpdateZoomControls(); 502 UpdateZoomControls();
502 } 503 }
503 504
504 private: 505 private:
505 void UpdateZoomControls() { 506 void UpdateZoomControls() {
506 bool enable_increment = false; 507 bool enable_increment = false;
507 bool enable_decrement = false; 508 bool enable_decrement = false;
508 TabContents* selected_tab = menu_->browser_->GetSelectedTabContents(); 509 WebContents* selected_tab = menu_->browser_->GetSelectedWebContents();
509 int zoom = 100; 510 int zoom = 100;
510 if (selected_tab) 511 if (selected_tab)
511 zoom = selected_tab->GetZoomPercent(&enable_increment, &enable_decrement); 512 zoom = selected_tab->GetZoomPercent(&enable_increment, &enable_decrement);
512 increment_button_->SetEnabled(enable_increment); 513 increment_button_->SetEnabled(enable_increment);
513 decrement_button_->SetEnabled(enable_decrement); 514 decrement_button_->SetEnabled(enable_decrement);
514 zoom_label_->SetText( 515 zoom_label_->SetText(
515 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, zoom)); 516 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, zoom));
516 517
517 zoom_label_width_ = MaxWidthForZoomLabel(); 518 zoom_label_width_ = MaxWidthForZoomLabel();
518 } 519 }
519 520
520 // Calculates the max width the zoom string can be. 521 // Calculates the max width the zoom string can be.
521 int MaxWidthForZoomLabel() { 522 int MaxWidthForZoomLabel() {
522 gfx::Font font = zoom_label_->font(); 523 gfx::Font font = zoom_label_->font();
523 gfx::Insets insets; 524 gfx::Insets insets;
524 if (zoom_label_->border()) 525 if (zoom_label_->border())
525 zoom_label_->border()->GetInsets(&insets); 526 zoom_label_->border()->GetInsets(&insets);
526 527
527 int max_w = 0; 528 int max_w = 0;
528 529
529 TabContents* selected_tab = menu_->browser_->GetSelectedTabContents(); 530 WebContents* selected_tab = menu_->browser_->GetSelectedWebContents();
530 if (selected_tab) { 531 if (selected_tab) {
531 int min_percent = selected_tab->GetMinimumZoomPercent(); 532 int min_percent = selected_tab->GetMinimumZoomPercent();
532 int max_percent = selected_tab->GetMaximumZoomPercent(); 533 int max_percent = selected_tab->GetMaximumZoomPercent();
533 534
534 int step = (max_percent - min_percent) / 10; 535 int step = (max_percent - min_percent) / 10;
535 for (int i = min_percent; i <= max_percent; i += step) { 536 for (int i = min_percent; i <= max_percent; i += step) {
536 int w = font.GetStringWidth( 537 int w = font.GetStringWidth(
537 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, i)); 538 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, i));
538 max_w = std::max(w, max_w); 539 max_w = std::max(w, max_w);
539 } 540 }
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 bookmark_menu_delegate_.reset( 893 bookmark_menu_delegate_.reset(
893 new BookmarkMenuDelegate(browser_->profile(), 894 new BookmarkMenuDelegate(browser_->profile(),
894 NULL, 895 NULL,
895 parent, 896 parent,
896 first_bookmark_command_id_)); 897 first_bookmark_command_id_));
897 bookmark_menu_delegate_->Init( 898 bookmark_menu_delegate_->Init(
898 this, bookmark_menu_, model->bookmark_bar_node(), 0, 899 this, bookmark_menu_, model->bookmark_bar_node(), 0,
899 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 900 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
900 bookmark_utils::LAUNCH_WRENCH_MENU); 901 bookmark_utils::LAUNCH_WRENCH_MENU);
901 } 902 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tab_contents/tab_contents_container.cc ('k') | chrome/browser/ui/webui/active_downloads_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698