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

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

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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) 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
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/app/chrome_command_ids.h" 13 #include "chrome/app/chrome_command_ids.h"
14 #include "chrome/browser/bookmarks/bookmark_model.h" 14 #include "chrome/browser/bookmarks/bookmark_model.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_tabstrip.h"
17 #include "chrome/browser/ui/browser_window.h" 18 #include "chrome/browser/ui/browser_window.h"
18 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h" 19 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h"
19 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
20 #include "content/public/browser/host_zoom_map.h" 21 #include "content/public/browser/host_zoom_map.h"
21 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
23 #include "content/public/browser/notification_source.h" 24 #include "content/public/browser/notification_source.h"
24 #include "content/public/browser/notification_types.h" 25 #include "content/public/browser/notification_types.h"
25 #include "content/public/browser/user_metrics.h" 26 #include "content/public/browser/user_metrics.h"
26 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 const content::NotificationSource& source, 543 const content::NotificationSource& source,
543 const content::NotificationDetails& details) { 544 const content::NotificationDetails& details) {
544 DCHECK_EQ(content::NOTIFICATION_ZOOM_LEVEL_CHANGED, type); 545 DCHECK_EQ(content::NOTIFICATION_ZOOM_LEVEL_CHANGED, type);
545 UpdateZoomControls(); 546 UpdateZoomControls();
546 } 547 }
547 548
548 private: 549 private:
549 void UpdateZoomControls() { 550 void UpdateZoomControls() {
550 bool enable_increment = false; 551 bool enable_increment = false;
551 bool enable_decrement = false; 552 bool enable_decrement = false;
552 WebContents* selected_tab = menu_->browser_->GetActiveWebContents(); 553 WebContents* selected_tab = chrome::GetActiveWebContents(menu_->browser_);
553 int zoom = 100; 554 int zoom = 100;
554 if (selected_tab) 555 if (selected_tab)
555 zoom = selected_tab->GetZoomPercent(&enable_increment, &enable_decrement); 556 zoom = selected_tab->GetZoomPercent(&enable_increment, &enable_decrement);
556 increment_button_->SetEnabled(enable_increment); 557 increment_button_->SetEnabled(enable_increment);
557 decrement_button_->SetEnabled(enable_decrement); 558 decrement_button_->SetEnabled(enable_decrement);
558 zoom_label_->SetText( 559 zoom_label_->SetText(
559 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, zoom)); 560 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, zoom));
560 561
561 zoom_label_width_ = MaxWidthForZoomLabel(); 562 zoom_label_width_ = MaxWidthForZoomLabel();
562 } 563 }
563 564
564 // Calculates the max width the zoom string can be. 565 // Calculates the max width the zoom string can be.
565 int MaxWidthForZoomLabel() { 566 int MaxWidthForZoomLabel() {
566 gfx::Font font = zoom_label_->font(); 567 gfx::Font font = zoom_label_->font();
567 gfx::Insets insets; 568 gfx::Insets insets;
568 if (zoom_label_->border()) 569 if (zoom_label_->border())
569 zoom_label_->border()->GetInsets(&insets); 570 zoom_label_->border()->GetInsets(&insets);
570 571
571 int max_w = 0; 572 int max_w = 0;
572 573
573 WebContents* selected_tab = menu_->browser_->GetActiveWebContents(); 574 WebContents* selected_tab = chrome::GetActiveWebContents(menu_->browser_);
574 if (selected_tab) { 575 if (selected_tab) {
575 int min_percent = selected_tab->GetMinimumZoomPercent(); 576 int min_percent = selected_tab->GetMinimumZoomPercent();
576 int max_percent = selected_tab->GetMaximumZoomPercent(); 577 int max_percent = selected_tab->GetMaximumZoomPercent();
577 578
578 int step = (max_percent - min_percent) / 10; 579 int step = (max_percent - min_percent) / 10;
579 for (int i = min_percent; i <= max_percent; i += step) { 580 for (int i = min_percent; i <= max_percent; i += step) {
580 int w = font.GetStringWidth( 581 int w = font.GetStringWidth(
581 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, i)); 582 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, i));
582 max_w = std::max(w, max_w); 583 max_w = std::max(w, max_w);
583 } 584 }
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 bookmark_menu_delegate_.reset( 961 bookmark_menu_delegate_.reset(
961 new BookmarkMenuDelegate(browser_, 962 new BookmarkMenuDelegate(browser_,
962 NULL, 963 NULL,
963 parent, 964 parent,
964 first_bookmark_command_id_)); 965 first_bookmark_command_id_));
965 bookmark_menu_delegate_->Init( 966 bookmark_menu_delegate_->Init(
966 this, bookmark_menu_, model->bookmark_bar_node(), 0, 967 this, bookmark_menu_, model->bookmark_bar_node(), 0,
967 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 968 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
968 bookmark_utils::LAUNCH_WRENCH_MENU); 969 bookmark_utils::LAUNCH_WRENCH_MENU);
969 } 970 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/web_dialog_view_browsertest.cc ('k') | chrome/browser/ui/webui/bookmarks_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698