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

Side by Side Diff: chrome/browser/ui/toolbar/wrench_menu_model.cc

Issue 301733006: Zoom Extension API (chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix javascript test function signature. Created 6 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/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 15 matching lines...) Expand all
26 #include "chrome/browser/ui/browser_commands.h" 26 #include "chrome/browser/ui/browser_commands.h"
27 #include "chrome/browser/ui/browser_finder.h" 27 #include "chrome/browser/ui/browser_finder.h"
28 #include "chrome/browser/ui/browser_window.h" 28 #include "chrome/browser/ui/browser_window.h"
29 #include "chrome/browser/ui/global_error/global_error.h" 29 #include "chrome/browser/ui/global_error/global_error.h"
30 #include "chrome/browser/ui/global_error/global_error_service.h" 30 #include "chrome/browser/ui/global_error/global_error_service.h"
31 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 31 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
32 #include "chrome/browser/ui/tabs/tab_strip_model.h" 32 #include "chrome/browser/ui/tabs/tab_strip_model.h"
33 #include "chrome/browser/ui/toolbar/bookmark_sub_menu_model.h" 33 #include "chrome/browser/ui/toolbar/bookmark_sub_menu_model.h"
34 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" 34 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
35 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h" 35 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h"
36 #include "chrome/browser/ui/zoom/zoom_controller.h"
37 #include "chrome/browser/ui/zoom/zoom_event_manager.h"
36 #include "chrome/browser/upgrade_detector.h" 38 #include "chrome/browser/upgrade_detector.h"
37 #include "chrome/common/chrome_paths.h" 39 #include "chrome/common/chrome_paths.h"
38 #include "chrome/common/chrome_switches.h" 40 #include "chrome/common/chrome_switches.h"
39 #include "chrome/common/pref_names.h" 41 #include "chrome/common/pref_names.h"
40 #include "chrome/common/profiling.h" 42 #include "chrome/common/profiling.h"
41 #include "components/signin/core/browser/signin_manager.h" 43 #include "components/signin/core/browser/signin_manager.h"
42 #include "components/signin/core/common/profile_management_switches.h" 44 #include "components/signin/core/common/profile_management_switches.h"
43 #include "content/public/browser/host_zoom_map.h" 45 #include "content/public/browser/host_zoom_map.h"
44 #include "content/public/browser/navigation_entry.h" 46 #include "content/public/browser/navigation_entry.h"
45 #include "content/public/browser/notification_service.h" 47 #include "content/public/browser/notification_service.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 WrenchMenuModel::WrenchMenuModel(ui::AcceleratorProvider* provider, 278 WrenchMenuModel::WrenchMenuModel(ui::AcceleratorProvider* provider,
277 Browser* browser, 279 Browser* browser,
278 bool is_new_menu) 280 bool is_new_menu)
279 : ui::SimpleMenuModel(this), 281 : ui::SimpleMenuModel(this),
280 provider_(provider), 282 provider_(provider),
281 browser_(browser), 283 browser_(browser),
282 tab_strip_model_(browser_->tab_strip_model()) { 284 tab_strip_model_(browser_->tab_strip_model()) {
283 Build(is_new_menu); 285 Build(is_new_menu);
284 UpdateZoomControls(); 286 UpdateZoomControls();
285 287
286 zoom_subscription_ = HostZoomMap::GetForBrowserContext( 288 content_zoom_subscription_ = content::HostZoomMap::GetForBrowserContext(
287 browser->profile())->AddZoomLevelChangedCallback( 289 browser->profile())->AddZoomLevelChangedCallback(
288 base::Bind(&WrenchMenuModel::OnZoomLevelChanged, 290 base::Bind(&WrenchMenuModel::OnZoomLevelChanged,
289 base::Unretained(this))); 291 base::Unretained(this)));
292
293 browser_zoom_subscription_ = ZoomEventManager::GetForBrowserContext(
294 browser->profile())->AddZoomLevelChangedCallback(
295 base::Bind(&WrenchMenuModel::OnZoomLevelChanged,
296 base::Unretained(this)));
290 297
291 tab_strip_model_->AddObserver(this); 298 tab_strip_model_->AddObserver(this);
292 299
293 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 300 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
294 content::NotificationService::AllSources()); 301 content::NotificationService::AllSources());
295 } 302 }
296 303
297 WrenchMenuModel::~WrenchMenuModel() { 304 WrenchMenuModel::~WrenchMenuModel() {
298 if (tab_strip_model_) 305 if (tab_strip_model_)
299 tab_strip_model_->RemoveObserver(this); 306 tab_strip_model_->RemoveObserver(this);
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 // you change the order you'll need to update wrench_menu as well. 795 // you change the order you'll need to update wrench_menu as well.
789 AddItemWithStringId(IDC_ZOOM_MINUS, IDS_ZOOM_MINUS); 796 AddItemWithStringId(IDC_ZOOM_MINUS, IDS_ZOOM_MINUS);
790 AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS); 797 AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS);
791 AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); 798 AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN);
792 #endif 799 #endif
793 800
794 AddSeparator(new_menu ? ui::UPPER_SEPARATOR : ui::NORMAL_SEPARATOR); 801 AddSeparator(new_menu ? ui::UPPER_SEPARATOR : ui::NORMAL_SEPARATOR);
795 } 802 }
796 803
797 void WrenchMenuModel::UpdateZoomControls() { 804 void WrenchMenuModel::UpdateZoomControls() {
798 bool enable_increment = false;
799 bool enable_decrement = false;
800 int zoom_percent = 100; 805 int zoom_percent = 100;
801 if (browser_->tab_strip_model()->GetActiveWebContents()) { 806 if (browser_->tab_strip_model()->GetActiveWebContents()) {
802 zoom_percent = 807 zoom_percent = ZoomController::FromWebContents(
803 browser_->tab_strip_model()->GetActiveWebContents()->GetZoomPercent( 808 browser_->tab_strip_model()->GetActiveWebContents())
804 &enable_increment, &enable_decrement); 809 ->GetZoomPercent();
805 } 810 }
806 zoom_label_ = l10n_util::GetStringFUTF16( 811 zoom_label_ = l10n_util::GetStringFUTF16(
807 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); 812 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent));
808 } 813 }
809 814
810 void WrenchMenuModel::OnZoomLevelChanged( 815 void WrenchMenuModel::OnZoomLevelChanged(
811 const content::HostZoomMap::ZoomLevelChange& change) { 816 const content::HostZoomMap::ZoomLevelChange& change) {
812 UpdateZoomControls(); 817 UpdateZoomControls();
813 } 818 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698