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

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

Issue 769593003: Move ZoomObserver, ZoomController and ZoomEventManager to components/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove obsolete defines in build files. Created 6 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/toolbar/wrench_menu.h" 5 #include "chrome/browser/ui/views/toolbar/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/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
16 #include "chrome/browser/bookmarks/bookmark_stats.h" 16 #include "chrome/browser/bookmarks/bookmark_stats.h"
17 #include "chrome/browser/chrome_notification_types.h" 17 #include "chrome/browser/chrome_notification_types.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/search/search.h" 19 #include "chrome/browser/search/search.h"
20 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" 22 #include "chrome/browser/ui/tabs/tab_strip_model.h"
23 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" 23 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
24 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h" 24 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h"
25 #include "chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h" 25 #include "chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h"
26 #include "chrome/browser/ui/views/toolbar/wrench_menu_observer.h" 26 #include "chrome/browser/ui/views/toolbar/wrench_menu_observer.h"
27 #include "chrome/browser/ui/zoom/zoom_controller.h"
28 #include "chrome/browser/ui/zoom/zoom_event_manager.h"
29 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
30 #include "components/bookmarks/browser/bookmark_model.h" 28 #include "components/bookmarks/browser/bookmark_model.h"
29 #include "components/ui/zoom/zoom_controller.h"
30 #include "components/ui/zoom/zoom_event_manager.h"
31 #include "content/public/browser/host_zoom_map.h" 31 #include "content/public/browser/host_zoom_map.h"
32 #include "content/public/browser/notification_observer.h" 32 #include "content/public/browser/notification_observer.h"
33 #include "content/public/browser/notification_registrar.h" 33 #include "content/public/browser/notification_registrar.h"
34 #include "content/public/browser/notification_source.h" 34 #include "content/public/browser/notification_source.h"
35 #include "content/public/browser/notification_types.h" 35 #include "content/public/browser/notification_types.h"
36 #include "content/public/browser/user_metrics.h" 36 #include "content/public/browser/user_metrics.h"
37 #include "content/public/browser/web_contents.h" 37 #include "content/public/browser/web_contents.h"
38 #include "extensions/common/feature_switch.h" 38 #include "extensions/common/feature_switch.h"
39 #include "grit/theme_resources.h" 39 #include "grit/theme_resources.h"
40 #include "third_party/skia/include/core/SkCanvas.h" 40 #include "third_party/skia/include/core/SkCanvas.h"
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 int decrement_index, 487 int decrement_index,
488 int increment_index, 488 int increment_index,
489 int fullscreen_index) 489 int fullscreen_index)
490 : WrenchMenuView(menu, menu_model), 490 : WrenchMenuView(menu, menu_model),
491 fullscreen_index_(fullscreen_index), 491 fullscreen_index_(fullscreen_index),
492 increment_button_(NULL), 492 increment_button_(NULL),
493 zoom_label_(NULL), 493 zoom_label_(NULL),
494 decrement_button_(NULL), 494 decrement_button_(NULL),
495 fullscreen_button_(NULL), 495 fullscreen_button_(NULL),
496 zoom_label_width_(0) { 496 zoom_label_width_(0) {
497 browser_zoom_subscription_ = ZoomEventManager::GetForBrowserContext( 497 browser_zoom_subscription_ =
498 menu->browser_->profile())->AddZoomLevelChangedCallback( 498 ui_zoom::ZoomEventManager::GetForBrowserContext(
499 base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged, 499 menu->browser_->profile())
500 base::Unretained(this))); 500 ->AddZoomLevelChangedCallback(
501 base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged,
502 base::Unretained(this)));
501 503
502 decrement_button_ = CreateButtonWithAccName( 504 decrement_button_ = CreateButtonWithAccName(
503 IDS_ZOOM_MINUS2, InMenuButtonBackground::LEFT_BUTTON, 505 IDS_ZOOM_MINUS2, InMenuButtonBackground::LEFT_BUTTON,
504 decrement_index, IDS_ACCNAME_ZOOM_MINUS2); 506 decrement_index, IDS_ACCNAME_ZOOM_MINUS2);
505 507
506 zoom_label_ = new Label( 508 zoom_label_ = new Label(
507 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, 100)); 509 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, 100));
508 zoom_label_->SetAutoColorReadabilityEnabled(false); 510 zoom_label_->SetAutoColorReadabilityEnabled(false);
509 zoom_label_->SetHorizontalAlignment(gfx::ALIGN_RIGHT); 511 zoom_label_->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
510 512
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 private: 633 private:
632 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change) { 634 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change) {
633 UpdateZoomControls(); 635 UpdateZoomControls();
634 } 636 }
635 637
636 void UpdateZoomControls() { 638 void UpdateZoomControls() {
637 WebContents* selected_tab = 639 WebContents* selected_tab =
638 menu()->browser_->tab_strip_model()->GetActiveWebContents(); 640 menu()->browser_->tab_strip_model()->GetActiveWebContents();
639 int zoom = 100; 641 int zoom = 100;
640 if (selected_tab) 642 if (selected_tab)
641 zoom = ZoomController::FromWebContents(selected_tab)->GetZoomPercent(); 643 zoom = ui_zoom::ZoomController::FromWebContents(selected_tab)
644 ->GetZoomPercent();
642 increment_button_->SetEnabled(zoom < selected_tab->GetMaximumZoomPercent()); 645 increment_button_->SetEnabled(zoom < selected_tab->GetMaximumZoomPercent());
643 decrement_button_->SetEnabled(zoom > selected_tab->GetMinimumZoomPercent()); 646 decrement_button_->SetEnabled(zoom > selected_tab->GetMinimumZoomPercent());
644 zoom_label_->SetText( 647 zoom_label_->SetText(
645 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, zoom)); 648 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, zoom));
646 649
647 zoom_label_width_ = MaxWidthForZoomLabel(); 650 zoom_label_width_ = MaxWidthForZoomLabel();
648 } 651 }
649 652
650 // Calculates the max width the zoom string can be. 653 // Calculates the max width the zoom string can be.
651 int MaxWidthForZoomLabel() { 654 int MaxWidthForZoomLabel() {
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 0, 1240 0,
1238 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1241 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1239 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); 1242 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU);
1240 } 1243 }
1241 1244
1242 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { 1245 int WrenchMenu::ModelIndexFromCommandId(int command_id) const {
1243 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1246 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1244 DCHECK(ix != command_id_to_entry_.end()); 1247 DCHECK(ix != command_id_to_entry_.end());
1245 return ix->second.second; 1248 return ix->second.second;
1246 } 1249 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/zoom_view.cc ('k') | chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698