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

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

Issue 393133002: Migrate HostZoomMap to live in StoragePartition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 6 years, 4 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 #include "chrome/browser/enumerate_modules_model_win.h" 71 #include "chrome/browser/enumerate_modules_model_win.h"
72 #include "chrome/browser/ui/metro_pin_tab_helper_win.h" 72 #include "chrome/browser/ui/metro_pin_tab_helper_win.h"
73 #include "content/public/browser/gpu_data_manager.h" 73 #include "content/public/browser/gpu_data_manager.h"
74 #endif 74 #endif
75 75
76 #if defined(USE_ASH) 76 #if defined(USE_ASH)
77 #include "ash/shell.h" 77 #include "ash/shell.h"
78 #endif 78 #endif
79 79
80 using base::UserMetricsAction; 80 using base::UserMetricsAction;
81 using content::HostZoomMap;
82 using content::WebContents; 81 using content::WebContents;
83 82
84 namespace { 83 namespace {
85 // Conditionally return the update app menu item title based on upgrade detector 84 // Conditionally return the update app menu item title based on upgrade detector
86 // state. 85 // state.
87 base::string16 GetUpgradeDialogMenuItemName() { 86 base::string16 GetUpgradeDialogMenuItemName() {
88 if (UpgradeDetector::GetInstance()->is_outdated_install() || 87 if (UpgradeDetector::GetInstance()->is_outdated_install() ||
89 UpgradeDetector::GetInstance()->is_outdated_install_no_au()) { 88 UpgradeDetector::GetInstance()->is_outdated_install_no_au()) {
90 return l10n_util::GetStringUTF16(IDS_UPGRADE_BUBBLE_MENU_ITEM); 89 return l10n_util::GetStringUTF16(IDS_UPGRADE_BUBBLE_MENU_ITEM);
91 } else { 90 } else {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 277
279 WrenchMenuModel::WrenchMenuModel(ui::AcceleratorProvider* provider, 278 WrenchMenuModel::WrenchMenuModel(ui::AcceleratorProvider* provider,
280 Browser* browser) 279 Browser* browser)
281 : ui::SimpleMenuModel(this), 280 : ui::SimpleMenuModel(this),
282 provider_(provider), 281 provider_(provider),
283 browser_(browser), 282 browser_(browser),
284 tab_strip_model_(browser_->tab_strip_model()) { 283 tab_strip_model_(browser_->tab_strip_model()) {
285 Build(); 284 Build();
286 UpdateZoomControls(); 285 UpdateZoomControls();
287 286
288 content_zoom_subscription_ = content::HostZoomMap::GetForBrowserContext( 287 // By asking for the HostZoomMap via the BrowserContext, we get the map
289 browser->profile())->AddZoomLevelChangedCallback( 288 // associated with the default storage partition, and not the one related
290 base::Bind(&WrenchMenuModel::OnZoomLevelChanged, 289 // to any specialized storage partitions, e.g. those used by WebViewGuests.
291 base::Unretained(this))); 290 content_zoom_subscription_ =
291 content::HostZoomMap::GetDefaultForBrowserContext(browser->profile())
292 ->AddZoomLevelChangedCallback(base::Bind(
293 &WrenchMenuModel::OnZoomLevelChanged, base::Unretained(this)));
292 294
293 browser_zoom_subscription_ = ZoomEventManager::GetForBrowserContext( 295 browser_zoom_subscription_ = ZoomEventManager::GetForBrowserContext(
294 browser->profile())->AddZoomLevelChangedCallback( 296 browser->profile())->AddZoomLevelChangedCallback(
295 base::Bind(&WrenchMenuModel::OnZoomLevelChanged, 297 base::Bind(&WrenchMenuModel::OnZoomLevelChanged,
296 base::Unretained(this))); 298 base::Unretained(this)));
297 299
298 tab_strip_model_->AddObserver(this); 300 tab_strip_model_->AddObserver(this);
299 301
300 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 302 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
301 content::NotificationService::AllSources()); 303 content::NotificationService::AllSources());
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 ->GetZoomPercent(); 799 ->GetZoomPercent();
798 } 800 }
799 zoom_label_ = l10n_util::GetStringFUTF16( 801 zoom_label_ = l10n_util::GetStringFUTF16(
800 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); 802 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent));
801 } 803 }
802 804
803 void WrenchMenuModel::OnZoomLevelChanged( 805 void WrenchMenuModel::OnZoomLevelChanged(
804 const content::HostZoomMap::ZoomLevelChange& change) { 806 const content::HostZoomMap::ZoomLevelChange& change) {
805 UpdateZoomControls(); 807 UpdateZoomControls();
806 } 808 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698