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

Side by Side Diff: chrome/browser/chromeos/dom_ui/menu_ui.cc

Issue 6121004: Remove wstring from gfx. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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) 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/chromeos/dom_ui/menu_ui.h" 5 #include "chrome/browser/chromeos/dom_ui/menu_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/menus/menu_model.h" 9 #include "app/menus/menu_model.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 25 matching lines...) Expand all
36 #include "views/controls/menu/menu_config.h" 36 #include "views/controls/menu/menu_config.h"
37 #include "views/controls/menu/radio_button_image_gtk.h" 37 #include "views/controls/menu/radio_button_image_gtk.h"
38 #include "views/widget/widget_gtk.h" 38 #include "views/widget/widget_gtk.h"
39 39
40 namespace { 40 namespace {
41 41
42 // a fake resource id for not loading extra resource. 42 // a fake resource id for not loading extra resource.
43 const int kNoExtraResource = -1; 43 const int kNoExtraResource = -1;
44 44
45 // A utility function that generates css font property from gfx::Font. 45 // A utility function that generates css font property from gfx::Font.
46 std::wstring GetFontShorthand(const gfx::Font* font) { 46 // NOTE: Returns UTF-8.
47 std::wstring out; 47 std::string GetFontShorthand(const gfx::Font* font) {
48 std::string out;
48 if (font == NULL) { 49 if (font == NULL) {
49 font = &(views::MenuConfig::instance().font); 50 font = &(views::MenuConfig::instance().font);
50 } 51 }
51 if (font->GetStyle() & gfx::Font::BOLD) { 52 if (font->GetStyle() & gfx::Font::BOLD) {
52 out.append(L"bold "); 53 out.append("bold ");
53 } 54 }
54 if (font->GetStyle() & gfx::Font::ITALIC) { 55 if (font->GetStyle() & gfx::Font::ITALIC) {
55 out.append(L"italic "); 56 out.append("italic ");
56 } 57 }
57 if (font->GetStyle() & gfx::Font::UNDERLINED) { 58 if (font->GetStyle() & gfx::Font::UNDERLINED) {
58 out.append(L"underline "); 59 out.append("underline ");
59 } 60 }
60 61
61 // TODO(oshima): The font size from gfx::Font is too small when 62 // TODO(oshima): The font size from gfx::Font is too small when
62 // used in webkit. Figure out the reason. 63 // used in webkit. Figure out the reason.
63 out.append(ASCIIToWide(base::IntToString(font->GetFontSize() + 4))); 64 out.append(base::IntToString(font->GetFontSize() + 4));
64 out.append(L"px/"); 65 out.append("px/");
65 out.append(ASCIIToWide(base::IntToString( 66 out.append(base::IntToString(std::max(kFavIconSize, font->GetHeight())));
66 std::max(kFavIconSize, font->GetHeight())))); 67 out.append("px \"");
67 out.append(L"px \""); 68 out.append(UTF16ToUTF8(font->GetFontName()));
68 out.append(font->GetFontName()); 69 out.append("\",sans-serif");
69 out.append(L"\",sans-serif");
70 return out; 70 return out;
71 } 71 }
72 72
73 // Creates scroll button's up image when |up| is true or 73 // Creates scroll button's up image when |up| is true or
74 // down image if |up| is false. 74 // down image if |up| is false.
75 SkBitmap CreateMenuScrollArrowImage(bool up) { 75 SkBitmap CreateMenuScrollArrowImage(bool up) {
76 const views::MenuConfig& config = views::MenuConfig::instance(); 76 const views::MenuConfig& config = views::MenuConfig::instance();
77 77
78 int height = config.scroll_arrow_height; 78 int height = config.scroll_arrow_height;
79 gfx::CanvasSkia canvas(height * 2, height, false); 79 gfx::CanvasSkia canvas(height * 2, height, false);
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 string16 label16 = model->GetLabelAt(index); 612 string16 label16 = model->GetLabelAt(index);
613 DictionaryValue* item = new DictionaryValue(); 613 DictionaryValue* item = new DictionaryValue();
614 614
615 item->SetString("type", type); 615 item->SetString("type", type);
616 item->SetString("label", label16); 616 item->SetString("label", label16);
617 item->SetBoolean("enabled", model->IsEnabledAt(index)); 617 item->SetBoolean("enabled", model->IsEnabledAt(index));
618 item->SetBoolean("visible", model->IsVisibleAt(index)); 618 item->SetBoolean("visible", model->IsVisibleAt(index));
619 item->SetBoolean("checked", model->IsItemCheckedAt(index)); 619 item->SetBoolean("checked", model->IsItemCheckedAt(index));
620 item->SetInteger("command_id", model->GetCommandIdAt(index)); 620 item->SetInteger("command_id", model->GetCommandIdAt(index));
621 item->SetString( 621 item->SetString(
622 "font", WideToUTF16(GetFontShorthand(model->GetLabelFontAt(index)))); 622 "font", GetFontShorthand(model->GetLabelFontAt(index)));
623 SkBitmap icon; 623 SkBitmap icon;
624 if (model->GetIconAt(index, &icon) && !icon.isNull() && !icon.empty()) { 624 if (model->GetIconAt(index, &icon) && !icon.isNull() && !icon.empty()) {
625 item->SetString("icon", dom_ui_util::GetImageDataUrl(icon)); 625 item->SetString("icon", dom_ui_util::GetImageDataUrl(icon));
626 *max_icon_width = std::max(*max_icon_width, icon.width()); 626 *max_icon_width = std::max(*max_icon_width, icon.width());
627 } 627 }
628 views::Accelerator menu_accelerator; 628 views::Accelerator menu_accelerator;
629 if (model->GetAcceleratorAt(index, &menu_accelerator)) { 629 if (model->GetAcceleratorAt(index, &menu_accelerator)) {
630 item->SetString("accel", menu_accelerator.GetShortcutText()); 630 item->SetString("accel", menu_accelerator.GetShortcutText());
631 *has_accel = true; 631 *has_accel = true;
632 } 632 }
(...skipping 22 matching lines...) Expand all
655 655
656 ChromeURLDataManager::DataSource* MenuUI::CreateDataSource() { 656 ChromeURLDataManager::DataSource* MenuUI::CreateDataSource() {
657 return CreateMenuUIHTMLSource(NULL, 657 return CreateMenuUIHTMLSource(NULL,
658 chrome::kChromeUIMenu, 658 chrome::kChromeUIMenu,
659 "Menu" /* class name */, 659 "Menu" /* class name */,
660 kNoExtraResource, 660 kNoExtraResource,
661 kNoExtraResource); 661 kNoExtraResource);
662 } 662 }
663 663
664 } // namespace chromeos 664 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_popup_view_mac_unittest.mm ('k') | chrome/browser/chromeos/drop_shadow_label.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698