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

Side by Side Diff: chrome/browser/ui/toolbar/wrench_menu_model.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 (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/toolbar/wrench_menu_model.h" 5 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/ui/browser_commands.h" 30 #include "chrome/browser/ui/browser_commands.h"
31 #include "chrome/browser/ui/browser_finder.h" 31 #include "chrome/browser/ui/browser_finder.h"
32 #include "chrome/browser/ui/browser_window.h" 32 #include "chrome/browser/ui/browser_window.h"
33 #include "chrome/browser/ui/global_error/global_error.h" 33 #include "chrome/browser/ui/global_error/global_error.h"
34 #include "chrome/browser/ui/global_error/global_error_service.h" 34 #include "chrome/browser/ui/global_error/global_error_service.h"
35 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 35 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
36 #include "chrome/browser/ui/tabs/tab_strip_model.h" 36 #include "chrome/browser/ui/tabs/tab_strip_model.h"
37 #include "chrome/browser/ui/toolbar/bookmark_sub_menu_model.h" 37 #include "chrome/browser/ui/toolbar/bookmark_sub_menu_model.h"
38 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" 38 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
39 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h" 39 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h"
40 #include "chrome/browser/ui/zoom/zoom_controller.h"
41 #include "chrome/browser/ui/zoom/zoom_event_manager.h"
42 #include "chrome/browser/upgrade_detector.h" 40 #include "chrome/browser/upgrade_detector.h"
43 #include "chrome/common/chrome_paths.h" 41 #include "chrome/common/chrome_paths.h"
44 #include "chrome/common/chrome_switches.h" 42 #include "chrome/common/chrome_switches.h"
45 #include "chrome/common/pref_names.h" 43 #include "chrome/common/pref_names.h"
46 #include "chrome/common/profiling.h" 44 #include "chrome/common/profiling.h"
47 #include "chrome/grit/chromium_strings.h" 45 #include "chrome/grit/chromium_strings.h"
48 #include "chrome/grit/generated_resources.h" 46 #include "chrome/grit/generated_resources.h"
49 #include "components/signin/core/browser/signin_manager.h" 47 #include "components/signin/core/browser/signin_manager.h"
50 #include "components/signin/core/common/profile_management_switches.h" 48 #include "components/signin/core/common/profile_management_switches.h"
49 #include "components/ui/zoom/zoom_controller.h"
50 #include "components/ui/zoom/zoom_event_manager.h"
51 #include "content/public/browser/host_zoom_map.h" 51 #include "content/public/browser/host_zoom_map.h"
52 #include "content/public/browser/navigation_entry.h" 52 #include "content/public/browser/navigation_entry.h"
53 #include "content/public/browser/notification_service.h" 53 #include "content/public/browser/notification_service.h"
54 #include "content/public/browser/notification_source.h" 54 #include "content/public/browser/notification_source.h"
55 #include "content/public/browser/notification_types.h" 55 #include "content/public/browser/notification_types.h"
56 #include "content/public/browser/user_metrics.h" 56 #include "content/public/browser/user_metrics.h"
57 #include "content/public/browser/web_contents.h" 57 #include "content/public/browser/web_contents.h"
58 #include "extensions/common/feature_switch.h" 58 #include "extensions/common/feature_switch.h"
59 #include "grit/theme_resources.h" 59 #include "grit/theme_resources.h"
60 #include "ui/base/l10n/l10n_util.h" 60 #include "ui/base/l10n/l10n_util.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 WrenchMenuModel::WrenchMenuModel(ui::AcceleratorProvider* provider, 278 WrenchMenuModel::WrenchMenuModel(ui::AcceleratorProvider* provider,
279 Browser* browser) 279 Browser* browser)
280 : ui::SimpleMenuModel(this), 280 : ui::SimpleMenuModel(this),
281 uma_action_recorded_(false), 281 uma_action_recorded_(false),
282 provider_(provider), 282 provider_(provider),
283 browser_(browser), 283 browser_(browser),
284 tab_strip_model_(browser_->tab_strip_model()) { 284 tab_strip_model_(browser_->tab_strip_model()) {
285 Build(); 285 Build();
286 UpdateZoomControls(); 286 UpdateZoomControls();
287 287
288 browser_zoom_subscription_ = ZoomEventManager::GetForBrowserContext( 288 browser_zoom_subscription_ =
289 browser->profile())->AddZoomLevelChangedCallback( 289 ui_zoom::ZoomEventManager::GetForBrowserContext(browser->profile())
290 base::Bind(&WrenchMenuModel::OnZoomLevelChanged, 290 ->AddZoomLevelChangedCallback(base::Bind(
291 base::Unretained(this))); 291 &WrenchMenuModel::OnZoomLevelChanged, base::Unretained(this)));
292 292
293 tab_strip_model_->AddObserver(this); 293 tab_strip_model_->AddObserver(this);
294 294
295 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 295 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
296 content::NotificationService::AllSources()); 296 content::NotificationService::AllSources());
297 } 297 }
298 298
299 WrenchMenuModel::~WrenchMenuModel() { 299 WrenchMenuModel::~WrenchMenuModel() {
300 if (tab_strip_model_) 300 if (tab_strip_model_)
301 tab_strip_model_->RemoveObserver(this); 301 tab_strip_model_->RemoveObserver(this);
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS); 1061 AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS);
1062 AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); 1062 AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN);
1063 #endif 1063 #endif
1064 1064
1065 AddSeparator(ui::UPPER_SEPARATOR); 1065 AddSeparator(ui::UPPER_SEPARATOR);
1066 } 1066 }
1067 1067
1068 void WrenchMenuModel::UpdateZoomControls() { 1068 void WrenchMenuModel::UpdateZoomControls() {
1069 int zoom_percent = 100; 1069 int zoom_percent = 100;
1070 if (browser_->tab_strip_model()->GetActiveWebContents()) { 1070 if (browser_->tab_strip_model()->GetActiveWebContents()) {
1071 zoom_percent = ZoomController::FromWebContents( 1071 zoom_percent = ui_zoom::ZoomController::FromWebContents(
1072 browser_->tab_strip_model()->GetActiveWebContents()) 1072 browser_->tab_strip_model()->GetActiveWebContents())
1073 ->GetZoomPercent(); 1073 ->GetZoomPercent();
1074 } 1074 }
1075 zoom_label_ = l10n_util::GetStringFUTF16( 1075 zoom_label_ = l10n_util::GetStringFUTF16(
1076 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); 1076 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent));
1077 } 1077 }
1078 1078
1079 void WrenchMenuModel::OnZoomLevelChanged( 1079 void WrenchMenuModel::OnZoomLevelChanged(
1080 const content::HostZoomMap::ZoomLevelChange& change) { 1080 const content::HostZoomMap::ZoomLevelChange& change) {
1081 UpdateZoomControls(); 1081 UpdateZoomControls();
1082 } 1082 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tab_helpers.cc ('k') | chrome/browser/ui/views/apps/chrome_native_app_window_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698