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

Unified Diff: chrome/browser/ui/toolbar/wrench_menu_model.cc

Issue 7857014: patch for global error bubbles (view/gtk) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/global_error_bubble.cc ('k') | chrome/browser/ui/views/global_error_bubble_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/toolbar/wrench_menu_model.cc
diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc
index 7b26e51f45efe21aada9c7fc4bac26e458e26cbe..74295168a87a9b349398d076d82aab46a0306116 100644
--- a/chrome/browser/ui/toolbar/wrench_menu_model.cc
+++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc
@@ -23,6 +23,9 @@
#include "chrome/browser/task_manager/task_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/global_error_delegate.h"
+#include "chrome/browser/ui/global_error_service.h"
+#include "chrome/browser/ui/global_error_service_factory.h"
#include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
#include "chrome/browser/upgrade_detector.h"
#include "chrome/common/chrome_paths.h"
@@ -39,6 +42,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/button_menu_item_model.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/image/image.h"
#if defined(TOOLKIT_USES_GTK)
#include <gtk/gtk.h>
@@ -315,10 +319,23 @@ bool WrenchMenuModel::GetIconForCommandId(int command_id,
default:
break;
}
+
return false;
}
void WrenchMenuModel::ExecuteCommand(int command_id) {
+ const std::vector<GlobalErrorDelegate*>& errors =
+ GlobalErrorServiceFactory::GetForProfile(
+ browser_->profile())->GetErrorDelegates();
+ for (std::vector<GlobalErrorDelegate*>::const_iterator
+ it = errors.begin(); it != errors.end(); ++it) {
+ GlobalErrorDelegate* error = *it;
+ if (error->HasMenuItem() && command_id == error->MenuItemCommandID()) {
+ error->ExecuteMenuItem(browser_);
+ return;
+ }
+ }
+
browser_->ExecuteCommand(command_id);
}
@@ -333,6 +350,16 @@ bool WrenchMenuModel::IsCommandIdChecked(int command_id) const {
}
bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const {
+ const std::vector<GlobalErrorDelegate*>& errors =
+ GlobalErrorServiceFactory::GetForProfile(
+ browser_->profile())->GetErrorDelegates();
+ for (std::vector<GlobalErrorDelegate*>::const_iterator
+ it = errors.begin(); it != errors.end(); ++it) {
+ GlobalErrorDelegate* error = *it;
+ if (error->HasMenuItem() && command_id == error->MenuItemCommandID())
+ return true;
+ }
+
return browser_->command_updater()->IsCommandEnabled(command_id);
}
@@ -408,6 +435,8 @@ WrenchMenuModel::WrenchMenuModel()
#if !defined(OS_CHROMEOS)
void WrenchMenuModel::Build() {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+
AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB);
AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW);
AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW);
@@ -498,13 +527,29 @@ void WrenchMenuModel::Build() {
IDS_VIEW_INCOMPATIBILITIES));
#if defined(OS_WIN)
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES),
*rb.GetBitmapNamed(IDR_CONFLICT_MENU));
#endif
AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE);
+ const std::vector<GlobalErrorDelegate*>& errors =
+ GlobalErrorServiceFactory::GetForProfile(
+ browser_->profile())->GetErrorDelegates();
+ for (std::vector<GlobalErrorDelegate*>::const_iterator
+ it = errors.begin(); it != errors.end(); ++it) {
+ GlobalErrorDelegate* error = *it;
+ if (error->HasMenuItem()) {
+ AddItem(error->MenuItemCommandID(), error->MenuItemLabel());
+ int icon_id = error->MenuItemIconResourceID();
+ if (icon_id) {
+ gfx::Image& image = rb.GetImageNamed(icon_id);
+ SetIcon(GetIndexOfCommandId(error->MenuItemCommandID()),
+ *image.ToSkBitmap());
+ }
+ }
+ }
+
if (browser_defaults::kShowExitMenuItem) {
AddSeparator();
AddItemWithStringId(IDC_EXIT, IDS_EXIT);
« no previous file with comments | « chrome/browser/ui/gtk/global_error_bubble.cc ('k') | chrome/browser/ui/views/global_error_bubble_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698