OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/wrench_menu_model.h" | 5 #include "chrome/browser/wrench_menu_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
11 #include "app/menus/button_menu_item_model.h" | 11 #include "app/menus/button_menu_item_model.h" |
12 #include "app/resource_bundle.h" | 12 #include "app/resource_bundle.h" |
| 13 #include "base/string_number_conversions.h" |
13 #include "chrome/app/chrome_dll_resource.h" | 14 #include "chrome/app/chrome_dll_resource.h" |
14 #include "chrome/browser/browser.h" | 15 #include "chrome/browser/browser.h" |
15 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/defaults.h" | 17 #include "chrome/browser/defaults.h" |
17 #include "chrome/browser/encoding_menu_controller.h" | 18 #include "chrome/browser/encoding_menu_controller.h" |
18 #include "chrome/browser/host_zoom_map.h" | 19 #include "chrome/browser/host_zoom_map.h" |
19 #include "chrome/browser/profile.h" | 20 #include "chrome/browser/profile.h" |
20 #include "chrome/browser/sync/profile_sync_service.h" | 21 #include "chrome/browser/sync/profile_sync_service.h" |
21 #include "chrome/browser/sync/sync_ui_util.h" | 22 #include "chrome/browser/sync/sync_ui_util.h" |
22 #include "chrome/browser/tab_contents/tab_contents.h" | 23 #include "chrome/browser/tab_contents/tab_contents.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 AddItemWithStringId(IDC_ZOOM_MINUS, IDS_ZOOM_MINUS); | 348 AddItemWithStringId(IDC_ZOOM_MINUS, IDS_ZOOM_MINUS); |
348 AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS); | 349 AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS); |
349 AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); | 350 AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); |
350 } | 351 } |
351 | 352 |
352 void WrenchMenuModel::UpdateZoomControls() { | 353 void WrenchMenuModel::UpdateZoomControls() { |
353 bool enable_increment, enable_decrement; | 354 bool enable_increment, enable_decrement; |
354 int zoom_percent = | 355 int zoom_percent = |
355 static_cast<int>(GetZoom(&enable_increment, &enable_decrement) * 100); | 356 static_cast<int>(GetZoom(&enable_increment, &enable_decrement) * 100); |
356 zoom_label_ = l10n_util::GetStringFUTF16( | 357 zoom_label_ = l10n_util::GetStringFUTF16( |
357 IDS_ZOOM_PERCENT, IntToString16(zoom_percent)); | 358 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
358 } | 359 } |
359 | 360 |
360 double WrenchMenuModel::GetZoom(bool* enable_increment, | 361 double WrenchMenuModel::GetZoom(bool* enable_increment, |
361 bool* enable_decrement) { | 362 bool* enable_decrement) { |
362 TabContents* selected_tab = browser_->GetSelectedTabContents(); | 363 TabContents* selected_tab = browser_->GetSelectedTabContents(); |
363 *enable_decrement = *enable_increment = false; | 364 *enable_decrement = *enable_increment = false; |
364 if (!selected_tab) | 365 if (!selected_tab) |
365 return 1; | 366 return 1; |
366 | 367 |
367 HostZoomMap* zoom_map = selected_tab->profile()->GetHostZoomMap(); | 368 HostZoomMap* zoom_map = selected_tab->profile()->GetHostZoomMap(); |
(...skipping 27 matching lines...) Expand all Loading... |
395 int command_id = GetCommandIdAt(index); | 396 int command_id = GetCommandIdAt(index); |
396 return command_id == IDC_SYNC_BOOKMARKS || | 397 return command_id == IDC_SYNC_BOOKMARKS || |
397 command_id == IDC_ABOUT; | 398 command_id == IDC_ABOUT; |
398 } | 399 } |
399 | 400 |
400 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { | 401 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { |
401 if (delegate_) | 402 if (delegate_) |
402 return delegate_->IsCommandIdEnabled(command_id); | 403 return delegate_->IsCommandIdEnabled(command_id); |
403 return true; | 404 return true; |
404 } | 405 } |
OLD | NEW |