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

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

Issue 161293002: mac: Allows extensions to hide the bookmark page menu item. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused headers. Created 6 years, 10 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
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"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/app/chrome_command_ids.h" 15 #include "chrome/app/chrome_command_ids.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/defaults.h" 17 #include "chrome/browser/defaults.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/search/search.h" 20 #include "chrome/browser/search/search.h"
21 #include "chrome/browser/signin/signin_manager.h" 21 #include "chrome/browser/signin/signin_manager.h"
22 #include "chrome/browser/signin/signin_manager_factory.h" 22 #include "chrome/browser/signin/signin_manager_factory.h"
23 #include "chrome/browser/signin/signin_ui_util.h" 23 #include "chrome/browser/signin/signin_ui_util.h"
24 #include "chrome/browser/task_manager/task_manager.h" 24 #include "chrome/browser/task_manager/task_manager.h"
25 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
25 #include "chrome/browser/ui/browser.h" 26 #include "chrome/browser/ui/browser.h"
26 #include "chrome/browser/ui/browser_commands.h" 27 #include "chrome/browser/ui/browser_commands.h"
27 #include "chrome/browser/ui/browser_finder.h" 28 #include "chrome/browser/ui/browser_finder.h"
28 #include "chrome/browser/ui/browser_window.h" 29 #include "chrome/browser/ui/browser_window.h"
29 #include "chrome/browser/ui/global_error/global_error.h" 30 #include "chrome/browser/ui/global_error/global_error.h"
30 #include "chrome/browser/ui/global_error/global_error_service.h" 31 #include "chrome/browser/ui/global_error/global_error_service.h"
31 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 32 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
32 #include "chrome/browser/ui/tabs/tab_strip_model.h" 33 #include "chrome/browser/ui/tabs/tab_strip_model.h"
33 #include "chrome/browser/ui/toolbar/bookmark_sub_menu_model.h" 34 #include "chrome/browser/ui/toolbar/bookmark_sub_menu_model.h"
34 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" 35 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( 397 GlobalError* error = GlobalErrorServiceFactory::GetForProfile(
397 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); 398 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id);
398 if (error) 399 if (error)
399 return true; 400 return true;
400 401
401 return chrome::IsCommandEnabled(browser_, command_id); 402 return chrome::IsCommandEnabled(browser_, command_id);
402 } 403 }
403 404
404 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const { 405 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const {
405 #if defined(OS_WIN) 406 #if defined(OS_WIN)
406 if (command_id == IDC_VIEW_INCOMPATIBILITIES) { 407 if (command_id == IDC_VIEW_INCOMPATIBILITIES) {
sky 2014/02/26 21:46:31 I think it's time for a switch statement.
erikchen 2014/02/26 22:31:19 Done.
407 EnumerateModulesModel* loaded_modules = 408 EnumerateModulesModel* loaded_modules =
408 EnumerateModulesModel::GetInstance(); 409 EnumerateModulesModel::GetInstance();
409 if (loaded_modules->confirmed_bad_modules_detected() <= 0) 410 if (loaded_modules->confirmed_bad_modules_detected() <= 0)
410 return false; 411 return false;
411 // We'll leave the wrench adornment on until the user clicks the link. 412 // We'll leave the wrench adornment on until the user clicks the link.
412 if (loaded_modules->modules_to_notify_about() <= 0) 413 if (loaded_modules->modules_to_notify_about() <= 0)
413 loaded_modules->AcknowledgeConflictNotification(); 414 loaded_modules->AcknowledgeConflictNotification();
414 return true; 415 return true;
415 } else if (command_id == IDC_PIN_TO_START_SCREEN) { 416 } else if (command_id == IDC_PIN_TO_START_SCREEN) {
416 return base::win::IsMetroProcess(); 417 return base::win::IsMetroProcess();
417 #else 418 #else
418 if (command_id == IDC_VIEW_INCOMPATIBILITIES || 419 if (command_id == IDC_VIEW_INCOMPATIBILITIES ||
419 command_id == IDC_PIN_TO_START_SCREEN) { 420 command_id == IDC_PIN_TO_START_SCREEN) {
420 return false; 421 return false;
421 #endif 422 #endif
422 } else if (command_id == IDC_UPGRADE_DIALOG) { 423 } else if (command_id == IDC_UPGRADE_DIALOG) {
423 return UpgradeDetector::GetInstance()->notify_upgrade(); 424 return UpgradeDetector::GetInstance()->notify_upgrade();
424 } 425 }
426
427 // Extensions have the ability to hide the bookmark page menu item.
428 if (command_id == IDC_BOOKMARK_PAGE)
429 return chrome::ShouldShowBookmarkPageMenuItem(browser_->profile());
430
425 return true; 431 return true;
426 } 432 }
427 433
428 bool WrenchMenuModel::GetAcceleratorForCommandId( 434 bool WrenchMenuModel::GetAcceleratorForCommandId(
429 int command_id, 435 int command_id,
430 ui::Accelerator* accelerator) { 436 ui::Accelerator* accelerator) {
431 return provider_->GetAcceleratorForCommandId(command_id, accelerator); 437 return provider_->GetAcceleratorForCommandId(command_id, accelerator);
432 } 438 }
433 439
434 void WrenchMenuModel::ActiveTabChanged(WebContents* old_contents, 440 void WrenchMenuModel::ActiveTabChanged(WebContents* old_contents,
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 &enable_increment, &enable_decrement); 782 &enable_increment, &enable_decrement);
777 } 783 }
778 zoom_label_ = l10n_util::GetStringFUTF16( 784 zoom_label_ = l10n_util::GetStringFUTF16(
779 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); 785 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent));
780 } 786 }
781 787
782 void WrenchMenuModel::OnZoomLevelChanged( 788 void WrenchMenuModel::OnZoomLevelChanged(
783 const content::HostZoomMap::ZoomLevelChange& change) { 789 const content::HostZoomMap::ZoomLevelChange& change) {
784 UpdateZoomControls(); 790 UpdateZoomControls();
785 } 791 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698