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

Side by Side Diff: chrome/browser/ui/views/toolbar/app_menu.cc

Issue 1545153002: Switch to standard integer types in chrome/browser/ui/views/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views/toolbar/app_menu.h" 5 #include "chrome/browser/ui/views/toolbar/app_menu.h"
6 6
7 #include <stdint.h>
8
7 #include <algorithm> 9 #include <algorithm>
8 #include <cmath> 10 #include <cmath>
9 #include <set> 11 #include <set>
10 12
13 #include "base/macros.h"
11 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
12 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "build/build_config.h"
14 #include "chrome/app/chrome_command_ids.h" 18 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
16 #include "chrome/browser/bookmarks/bookmark_stats.h" 20 #include "chrome/browser/bookmarks/bookmark_stats.h"
17 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
18 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/search/search.h" 23 #include "chrome/browser/search/search.h"
20 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_window.h" 25 #include "chrome/browser/ui/browser_window.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" 26 #include "chrome/browser/ui/tabs/tab_strip_model.h"
23 #include "chrome/browser/ui/toolbar/app_menu_model.h" 27 #include "chrome/browser/ui/toolbar/app_menu_model.h"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 ~HoveredImageSource() override {} 400 ~HoveredImageSource() override {}
397 401
398 gfx::ImageSkiaRep GetImageForScale(float scale) override { 402 gfx::ImageSkiaRep GetImageForScale(float scale) override {
399 const gfx::ImageSkiaRep& rep = image_.GetRepresentation(scale); 403 const gfx::ImageSkiaRep& rep = image_.GetRepresentation(scale);
400 SkBitmap bitmap = rep.sk_bitmap(); 404 SkBitmap bitmap = rep.sk_bitmap();
401 SkBitmap white; 405 SkBitmap white;
402 white.allocN32Pixels(bitmap.width(), bitmap.height()); 406 white.allocN32Pixels(bitmap.width(), bitmap.height());
403 white.eraseARGB(0, 0, 0, 0); 407 white.eraseARGB(0, 0, 0, 0);
404 bitmap.lockPixels(); 408 bitmap.lockPixels();
405 for (int y = 0; y < bitmap.height(); ++y) { 409 for (int y = 0; y < bitmap.height(); ++y) {
406 uint32* image_row = bitmap.getAddr32(0, y); 410 uint32_t* image_row = bitmap.getAddr32(0, y);
407 uint32* dst_row = white.getAddr32(0, y); 411 uint32_t* dst_row = white.getAddr32(0, y);
408 for (int x = 0; x < bitmap.width(); ++x) { 412 for (int x = 0; x < bitmap.width(); ++x) {
409 uint32 image_pixel = image_row[x]; 413 uint32_t image_pixel = image_row[x];
410 // Fill the non transparent pixels with |color_|. 414 // Fill the non transparent pixels with |color_|.
411 dst_row[x] = (image_pixel & 0xFF000000) == 0x0 ? 0x0 : color_; 415 dst_row[x] = (image_pixel & 0xFF000000) == 0x0 ? 0x0 : color_;
412 } 416 }
413 } 417 }
414 bitmap.unlockPixels(); 418 bitmap.unlockPixels();
415 return gfx::ImageSkiaRep(white, scale); 419 return gfx::ImageSkiaRep(white, scale);
416 } 420 }
417 421
418 private: 422 private:
419 const gfx::ImageSkia image_; 423 const gfx::ImageSkia image_;
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 FOR_EACH_OBSERVER(AppMenuObserver, observer_list_, AppMenuDestroyed()); 827 FOR_EACH_OBSERVER(AppMenuObserver, observer_list_, AppMenuDestroyed());
824 } 828 }
825 829
826 void AppMenu::Init(ui::MenuModel* model) { 830 void AppMenu::Init(ui::MenuModel* model) {
827 DCHECK(!root_); 831 DCHECK(!root_);
828 root_ = new MenuItemView(this); 832 root_ = new MenuItemView(this);
829 root_->set_has_icons(true); // We have checks, radios and icons, set this 833 root_->set_has_icons(true); // We have checks, radios and icons, set this
830 // so we get the taller menu style. 834 // so we get the taller menu style.
831 PopulateMenu(root_, model); 835 PopulateMenu(root_, model);
832 836
833 int32 types = views::MenuRunner::HAS_MNEMONICS; 837 int32_t types = views::MenuRunner::HAS_MNEMONICS;
834 if (for_drop()) { 838 if (for_drop()) {
835 // We add NESTED_DRAG since currently the only operation to open the app 839 // We add NESTED_DRAG since currently the only operation to open the app
836 // menu for is an extension action drag, which is controlled by the child 840 // menu for is an extension action drag, which is controlled by the child
837 // BrowserActionsContainer view. 841 // BrowserActionsContainer view.
838 types |= views::MenuRunner::FOR_DROP | views::MenuRunner::NESTED_DRAG; 842 types |= views::MenuRunner::FOR_DROP | views::MenuRunner::NESTED_DRAG;
839 } 843 }
840 menu_runner_.reset(new views::MenuRunner(root_, types)); 844 menu_runner_.reset(new views::MenuRunner(root_, types));
841 } 845 }
842 846
843 void AppMenu::RunMenu(views::MenuButton* host) { 847 void AppMenu::RunMenu(views::MenuButton* host) {
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 0, 1266 0,
1263 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1267 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1264 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); 1268 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU);
1265 } 1269 }
1266 1270
1267 int AppMenu::ModelIndexFromCommandId(int command_id) const { 1271 int AppMenu::ModelIndexFromCommandId(int command_id) const {
1268 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1272 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1269 DCHECK(ix != command_id_to_entry_.end()); 1273 DCHECK(ix != command_id_to_entry_.end());
1270 return ix->second.second; 1274 return ix->second.second;
1271 } 1275 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/theme_image_mapper.cc ('k') | chrome/browser/ui/views/toolbar/back_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698