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

Side by Side Diff: chrome/browser/ui/views/location_bar/keyword_hint_view.cc

Issue 11360144: Converts some of the omnibox related classes to support multiple (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win_initialized Created 8 years, 1 month 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) 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/views/location_bar/keyword_hint_view.h" 5 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/search_engines/template_url_service.h" 13 #include "chrome/browser/search_engines/template_url_service.h"
14 #include "chrome/browser/search_engines/template_url_service_factory.h" 14 #include "chrome/browser/search_engines/template_url_service_factory.h"
15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
16 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
17 #include "grit/theme_resources.h" 17 #include "grit/theme_resources.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/image/image_skia.h" 21 #include "ui/gfx/image/image_skia.h"
22 #include "ui/views/controls/label.h" 22 #include "ui/views/controls/label.h"
23 23
24 // Amount of space to offset the tab image from the top of the view by. 24 // Amount of space to offset the tab image from the top of the view by.
25 static const int kTabImageYOffset = 1; 25 static const int kTabImageYOffset = 1;
26 26
27 // The tab key image. 27 // The tab key image.
28 static const gfx::ImageSkia* kTabButtonImage = NULL; 28 static const gfx::ImageSkia* kTabButtonImage = NULL;
29 29
30 KeywordHintView::KeywordHintView(Profile* profile) : profile_(profile) { 30 KeywordHintView::KeywordHintView(Profile* profile,
31 leading_label_ = CreateLabel(); 31 const LocationBarView* location_bar_view)
32 trailing_label_ = CreateLabel(); 32 : profile_(profile) {
33 leading_label_ = CreateLabel(location_bar_view);
34 trailing_label_ = CreateLabel(location_bar_view);
33 35
34 if (!kTabButtonImage) { 36 if (!kTabButtonImage) {
35 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 37 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
36 kTabButtonImage = rb.GetImageSkiaNamed(IDR_LOCATION_BAR_KEYWORD_HINT_TAB); 38 kTabButtonImage = rb.GetImageSkiaNamed(IDR_LOCATION_BAR_KEYWORD_HINT_TAB);
37 } 39 }
38 } 40 }
39 41
40 KeywordHintView::~KeywordHintView() { 42 KeywordHintView::~KeywordHintView() {
41 } 43 }
42 44
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 if (show_labels) { 124 if (show_labels) {
123 pref = leading_label_->GetPreferredSize(); 125 pref = leading_label_->GetPreferredSize();
124 leading_label_->SetBounds(x, 0, pref.width(), height()); 126 leading_label_->SetBounds(x, 0, pref.width(), height());
125 127
126 x += pref.width() + kTabButtonImage->width(); 128 x += pref.width() + kTabButtonImage->width();
127 pref = trailing_label_->GetPreferredSize(); 129 pref = trailing_label_->GetPreferredSize();
128 trailing_label_->SetBounds(x, 0, pref.width(), height()); 130 trailing_label_->SetBounds(x, 0, pref.width(), height());
129 } 131 }
130 } 132 }
131 133
132 views::Label* KeywordHintView::CreateLabel() { 134 views::Label* KeywordHintView::CreateLabel(
135 const LocationBarView* location_bar_view) {
133 views::Label* label = new views::Label(); 136 views::Label* label = new views::Label();
134 label->SetBackgroundColor(LocationBarView::GetColor( 137 label->SetBackgroundColor(location_bar_view->GetColor(
135 ToolbarModel::NONE, LocationBarView::BACKGROUND)); 138 ToolbarModel::NONE, LocationBarView::BACKGROUND));
136 label->SetEnabledColor(LocationBarView::GetColor( 139 label->SetEnabledColor(location_bar_view->GetColor(
137 ToolbarModel::NONE, LocationBarView::DEEMPHASIZED_TEXT)); 140 ToolbarModel::NONE, LocationBarView::DEEMPHASIZED_TEXT));
138 AddChildView(label); 141 AddChildView(label);
139 return label; 142 return label;
140 } 143 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/keyword_hint_view.h ('k') | chrome/browser/ui/views/location_bar/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698