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

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

Issue 9479008: Re-factor location bar/toolbar code to get rid of the browser dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: call right overloaded method Created 8 years, 9 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) 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/location_bar_view.h" 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
6 6
7 #if defined(TOOLKIT_USES_GTK) 7 #if defined(TOOLKIT_USES_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 }; 132 };
133 133
134 static const int kSelectedKeywordBackgroundImages[] = { 134 static const int kSelectedKeywordBackgroundImages[] = {
135 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L, 135 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L,
136 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C, 136 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C,
137 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R, 137 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R,
138 }; 138 };
139 139
140 // LocationBarView ----------------------------------------------------------- 140 // LocationBarView -----------------------------------------------------------
141 141
142 LocationBarView::LocationBarView(Browser* browser, 142 LocationBarView::LocationBarView(Profile* profile,
143 CommandUpdater* command_updater,
143 ToolbarModel* model, 144 ToolbarModel* model,
144 Delegate* delegate, 145 Delegate* delegate,
145 Mode mode) 146 Mode mode)
146 : browser_(browser), 147 : profile_(profile),
148 command_updater_(command_updater),
147 model_(model), 149 model_(model),
148 delegate_(delegate), 150 delegate_(delegate),
149 disposition_(CURRENT_TAB), 151 disposition_(CURRENT_TAB),
150 transition_(content::PageTransitionFromInt( 152 transition_(content::PageTransitionFromInt(
151 content::PAGE_TRANSITION_TYPED | 153 content::PAGE_TRANSITION_TYPED |
152 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), 154 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)),
153 location_icon_view_(NULL), 155 location_icon_view_(NULL),
154 ev_bubble_view_(NULL), 156 ev_bubble_view_(NULL),
155 location_entry_view_(NULL), 157 location_entry_view_(NULL),
156 selected_keyword_view_(NULL), 158 selected_keyword_view_(NULL),
(...skipping 13 matching lines...) Expand all
170 painter_.reset( 172 painter_.reset(
171 views::Painter::CreateImagePainter( 173 views::Painter::CreateImagePainter(
172 *ResourceBundle::GetSharedInstance().GetImageNamed( 174 *ResourceBundle::GetSharedInstance().GetImageNamed(
173 IDR_LOCATION_BAR_BORDER).ToSkBitmap(), 175 IDR_LOCATION_BAR_BORDER).ToSkBitmap(),
174 gfx::Insets(kBorderRoundCornerHeight, kBorderRoundCornerWidth, 176 gfx::Insets(kBorderRoundCornerHeight, kBorderRoundCornerWidth,
175 kBorderRoundCornerHeight, kBorderRoundCornerWidth), 177 kBorderRoundCornerHeight, kBorderRoundCornerWidth),
176 true)); 178 true));
177 } 179 }
178 180
179 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, 181 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled,
180 browser_->profile()->GetPrefs(), this); 182 profile_->GetPrefs(), this);
181 } 183 }
182 184
183 LocationBarView::~LocationBarView() { 185 LocationBarView::~LocationBarView() {
184 if (template_url_service_) 186 if (template_url_service_)
185 template_url_service_->RemoveObserver(this); 187 template_url_service_->RemoveObserver(this);
186 } 188 }
187 189
188 void LocationBarView::Init() { 190 void LocationBarView::Init() {
189 if (mode_ == POPUP) { 191 if (mode_ == POPUP) {
190 font_ = ResourceBundle::GetSharedInstance().GetFont( 192 font_ = ResourceBundle::GetSharedInstance().GetFont(
(...skipping 17 matching lines...) Expand all
208 210
209 ev_bubble_view_ = 211 ev_bubble_view_ =
210 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, 212 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID,
211 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), this); 213 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), this);
212 AddChildView(ev_bubble_view_); 214 AddChildView(ev_bubble_view_);
213 ev_bubble_view_->SetVisible(false); 215 ev_bubble_view_->SetVisible(false);
214 ev_bubble_view_->set_drag_controller(this); 216 ev_bubble_view_->set_drag_controller(this);
215 217
216 // URL edit field. 218 // URL edit field.
217 // View container for URL edit field. 219 // View container for URL edit field.
218 Profile* profile = browser_->profile();
219 location_entry_.reset(OmniboxView::CreateOmniboxView( 220 location_entry_.reset(OmniboxView::CreateOmniboxView(
220 this, 221 this,
221 model_, 222 model_,
222 profile, 223 profile_,
223 browser_->command_updater(), 224 command_updater_,
224 mode_ == POPUP, 225 mode_ == POPUP,
225 this)); 226 this));
226 SetLocationEntryFocusable(true); 227 SetLocationEntryFocusable(true);
227 228
228 location_entry_view_ = location_entry_->AddToView(this); 229 location_entry_view_ = location_entry_->AddToView(this);
229 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); 230 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE);
230 231
231 selected_keyword_view_ = new SelectedKeywordView( 232 selected_keyword_view_ = new SelectedKeywordView(
232 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, 233 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER,
233 GetColor(ToolbarModel::NONE, TEXT), profile); 234 GetColor(ToolbarModel::NONE, TEXT), profile_);
234 AddChildView(selected_keyword_view_); 235 AddChildView(selected_keyword_view_);
235 selected_keyword_view_->SetFont(font_); 236 selected_keyword_view_->SetFont(font_);
236 selected_keyword_view_->SetVisible(false); 237 selected_keyword_view_->SetVisible(false);
237 238
238 keyword_hint_view_ = new KeywordHintView(profile); 239 keyword_hint_view_ = new KeywordHintView(profile_);
239 AddChildView(keyword_hint_view_); 240 AddChildView(keyword_hint_view_);
240 keyword_hint_view_->SetVisible(false); 241 keyword_hint_view_->SetVisible(false);
241 keyword_hint_view_->SetFont(font_); 242 keyword_hint_view_->SetFont(font_);
242 243
243 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { 244 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
244 ContentSettingImageView* content_blocked_view = 245 ContentSettingImageView* content_blocked_view =
245 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this); 246 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this);
246 content_setting_views_.push_back(content_blocked_view); 247 content_setting_views_.push_back(content_blocked_view);
247 AddChildView(content_blocked_view); 248 AddChildView(content_blocked_view);
248 content_blocked_view->SetVisible(false); 249 content_blocked_view->SetVisible(false);
249 } 250 }
250 251
251 // Hide the star and Chrome To Mobile icons in popups and in the app launcher. 252 // Hide the star and Chrome To Mobile icons in popups and in the app launcher.
252 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { 253 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) {
253 star_view_ = new StarView(browser_->command_updater()); 254 star_view_ = new StarView(command_updater_);
254 AddChildView(star_view_); 255 AddChildView(star_view_);
255 star_view_->SetVisible(true); 256 star_view_->SetVisible(true);
256 257
257 // Also disable Chrome To Mobile for off-the-record and non-synced profiles. 258 // Also disable Chrome To Mobile for off-the-record and non-synced profiles.
258 Profile* profile = browser_->profile(); 259 if (!profile_->IsOffTheRecord() && profile_->IsSyncAccessible()) {
259 if (!profile->IsOffTheRecord() && profile->IsSyncAccessible()) {
260 chrome_to_mobile_view_ = 260 chrome_to_mobile_view_ =
261 new ChromeToMobileView(this, browser_->command_updater()); 261 new ChromeToMobileView(this, command_updater_);
262 AddChildView(chrome_to_mobile_view_); 262 AddChildView(chrome_to_mobile_view_);
263 ChromeToMobileService* service = 263 ChromeToMobileService* service =
264 ChromeToMobileServiceFactory::GetForProfile(browser_->profile()); 264 ChromeToMobileServiceFactory::GetForProfile(profile_);
265 service->RequestMobileListUpdate(); 265 service->RequestMobileListUpdate();
266 chrome_to_mobile_view_->SetVisible(!service->mobiles().empty()); 266 chrome_to_mobile_view_->SetVisible(!service->mobiles().empty());
267 } 267 }
268 } 268 }
269 269
270 // Initialize the location entry. We do this to avoid a black flash which is 270 // Initialize the location entry. We do this to avoid a black flash which is
271 // visible when the location entry has just been initialized. 271 // visible when the location entry has just been initialized.
272 Update(NULL); 272 Update(NULL);
273 273
274 OnChanged(); 274 OnChanged();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 FocusLocation(select_all); 332 FocusLocation(select_all);
333 } 333 }
334 334
335 void LocationBarView::SetAnimationOffset(int offset) { 335 void LocationBarView::SetAnimationOffset(int offset) {
336 animation_offset_ = offset; 336 animation_offset_ = offset;
337 } 337 }
338 338
339 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { 339 void LocationBarView::Update(const WebContents* tab_for_state_restoring) {
340 bool star_enabled = star_view_ && !model_->input_in_progress() && 340 bool star_enabled = star_view_ && !model_->input_in_progress() &&
341 edit_bookmarks_enabled_.GetValue(); 341 edit_bookmarks_enabled_.GetValue();
342 CommandUpdater* command_updater = browser_->command_updater(); 342 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled);
343 command_updater->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled);
344 if (star_view_) 343 if (star_view_)
345 star_view_->SetVisible(star_enabled); 344 star_view_->SetVisible(star_enabled);
346 345
347 Profile* profile = browser_->profile();
348 bool chrome_to_mobile_enabled = chrome_to_mobile_view_ && 346 bool chrome_to_mobile_enabled = chrome_to_mobile_view_ &&
349 !model_->input_in_progress() && profile->IsSyncAccessible() && 347 !model_->input_in_progress() && profile_->IsSyncAccessible() &&
350 !ChromeToMobileServiceFactory::GetForProfile(profile)->mobiles().empty(); 348 !ChromeToMobileServiceFactory::GetForProfile(profile_)->mobiles().empty();
351 command_updater->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, 349 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE,
352 chrome_to_mobile_enabled); 350 chrome_to_mobile_enabled);
353 351
354 RefreshContentSettingViews(); 352 RefreshContentSettingViews();
355 RefreshPageActionViews(); 353 RefreshPageActionViews();
356 // Don't Update in app launcher mode so that the location entry does not show 354 // Don't Update in app launcher mode so that the location entry does not show
357 // a URL or security background. 355 // a URL or security background.
358 if (mode_ != APP_LAUNCHER) 356 if (mode_ != APP_LAUNCHER)
359 location_entry_->Update(tab_for_state_restoring); 357 location_entry_->Update(tab_for_state_restoring);
360 OnChanged(); 358 OnChanged();
361 } 359 }
362 360
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 } 434 }
437 return NULL; 435 return NULL;
438 } 436 }
439 437
440 void LocationBarView::SetStarToggled(bool on) { 438 void LocationBarView::SetStarToggled(bool on) {
441 if (star_view_) 439 if (star_view_)
442 star_view_->SetToggled(on); 440 star_view_->SetToggled(on);
443 } 441 }
444 442
445 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { 443 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) {
446 browser::ShowBookmarkBubbleView(star_view_, browser_->profile(), url, 444 browser::ShowBookmarkBubbleView(star_view_, profile_, url,
447 newly_bookmarked); 445 newly_bookmarked);
448 } 446 }
449 447
450 void LocationBarView::ShowChromeToMobileBubble() { 448 void LocationBarView::ShowChromeToMobileBubble() {
451 ChromeToMobileServiceFactory::GetForProfile(browser_->profile())-> 449 ChromeToMobileServiceFactory::GetForProfile(profile_)->
452 RequestMobileListUpdate(); 450 RequestMobileListUpdate();
453 browser::ShowChromeToMobileBubbleView(chrome_to_mobile_view_, 451 browser::ShowChromeToMobileBubbleView(chrome_to_mobile_view_,
454 browser_->profile()); 452 profile_);
455 } 453 }
456 454
457 gfx::Point LocationBarView::GetLocationEntryOrigin() const { 455 gfx::Point LocationBarView::GetLocationEntryOrigin() const {
458 gfx::Point origin(location_entry_view_->bounds().origin()); 456 gfx::Point origin(location_entry_view_->bounds().origin());
459 // If the UI layout is RTL, the coordinate system is not transformed and 457 // If the UI layout is RTL, the coordinate system is not transformed and
460 // therefore we need to adjust the X coordinate so that bubble appears on the 458 // therefore we need to adjust the X coordinate so that bubble appears on the
461 // right hand side of the location bar. 459 // right hand side of the location bar.
462 if (base::i18n::IsRTL()) 460 if (base::i18n::IsRTL())
463 origin.set_x(width() - origin.x()); 461 origin.set_x(width() - origin.x());
464 views::View::ConvertPointToScreen(this, &origin); 462 views::View::ConvertPointToScreen(this, &origin);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 if (max_edit_width < 0) 610 if (max_edit_width < 0)
613 return; 611 return;
614 const int available_width = AvailableWidth(max_edit_width); 612 const int available_width = AvailableWidth(max_edit_width);
615 613
616 const bool show_keyword_hint = !keyword.empty() && is_keyword_hint; 614 const bool show_keyword_hint = !keyword.empty() && is_keyword_hint;
617 selected_keyword_view_->SetVisible(show_selected_keyword); 615 selected_keyword_view_->SetVisible(show_selected_keyword);
618 keyword_hint_view_->SetVisible(show_keyword_hint); 616 keyword_hint_view_->SetVisible(show_keyword_hint);
619 if (show_selected_keyword) { 617 if (show_selected_keyword) {
620 if (selected_keyword_view_->keyword() != keyword) { 618 if (selected_keyword_view_->keyword() != keyword) {
621 selected_keyword_view_->SetKeyword(keyword); 619 selected_keyword_view_->SetKeyword(keyword);
622 Profile* profile = browser_->profile();
623 const TemplateURL* template_url = 620 const TemplateURL* template_url =
624 TemplateURLServiceFactory::GetForProfile(profile)-> 621 TemplateURLServiceFactory::GetForProfile(profile_)->
625 GetTemplateURLForKeyword(keyword); 622 GetTemplateURLForKeyword(keyword);
626 if (template_url && template_url->IsExtensionKeyword()) { 623 if (template_url && template_url->IsExtensionKeyword()) {
627 const SkBitmap& bitmap = profile->GetExtensionService()->GetOmniboxIcon( 624 const SkBitmap& bitmap =
628 template_url->GetExtensionId()); 625 profile_->GetExtensionService()->GetOmniboxIcon(
626 template_url->GetExtensionId());
629 selected_keyword_view_->SetImage(bitmap); 627 selected_keyword_view_->SetImage(bitmap);
630 selected_keyword_view_->set_is_extension_icon(true); 628 selected_keyword_view_->set_is_extension_icon(true);
631 } else { 629 } else {
632 selected_keyword_view_->SetImage(*ResourceBundle::GetSharedInstance(). 630 selected_keyword_view_->SetImage(*ResourceBundle::GetSharedInstance().
633 GetBitmapNamed(IDR_OMNIBOX_SEARCH)); 631 GetBitmapNamed(IDR_OMNIBOX_SEARCH));
634 selected_keyword_view_->set_is_extension_icon(false); 632 selected_keyword_view_->set_is_extension_icon(false);
635 } 633 }
636 } 634 }
637 } else if (show_keyword_hint) { 635 } else if (show_keyword_hint) {
638 if (keyword_hint_view_->keyword() != keyword) 636 if (keyword_hint_view_->keyword() != keyword)
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 content::PageTransition transition, 877 content::PageTransition transition,
880 const GURL& alternate_nav_url) { 878 const GURL& alternate_nav_url) {
881 // WARNING: don't add an early return here. The calls after the if must 879 // WARNING: don't add an early return here. The calls after the if must
882 // happen. 880 // happen.
883 if (url.is_valid()) { 881 if (url.is_valid()) {
884 location_input_ = UTF8ToUTF16(url.spec()); 882 location_input_ = UTF8ToUTF16(url.spec());
885 disposition_ = disposition; 883 disposition_ = disposition;
886 transition_ = content::PageTransitionFromInt( 884 transition_ = content::PageTransitionFromInt(
887 transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR); 885 transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR);
888 886
889 if (browser_->command_updater()) { 887 if (command_updater_) {
890 if (!alternate_nav_url.is_valid()) { 888 if (!alternate_nav_url.is_valid()) {
891 browser_->command_updater()->ExecuteCommand(IDC_OPEN_CURRENT_URL); 889 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL);
892 } else { 890 } else {
893 AlternateNavURLFetcher* fetcher = 891 AlternateNavURLFetcher* fetcher =
894 new AlternateNavURLFetcher(alternate_nav_url); 892 new AlternateNavURLFetcher(alternate_nav_url);
895 // The AlternateNavURLFetcher will listen for the pending navigation 893 // The AlternateNavURLFetcher will listen for the pending navigation
896 // notification that will be issued as a result of the "open URL." It 894 // notification that will be issued as a result of the "open URL." It
897 // will automatically install itself into that navigation controller. 895 // will automatically install itself into that navigation controller.
898 browser_->command_updater()->ExecuteCommand(IDC_OPEN_CURRENT_URL); 896 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL);
899 if (fetcher->state() == AlternateNavURLFetcher::NOT_STARTED) { 897 if (fetcher->state() == AlternateNavURLFetcher::NOT_STARTED) {
900 // I'm not sure this should be reachable, but I'm not also sure enough 898 // I'm not sure this should be reachable, but I'm not also sure enough
901 // that it shouldn't to stick in a NOTREACHED(). In any case, this is 899 // that it shouldn't to stick in a NOTREACHED(). In any case, this is
902 // harmless. 900 // harmless.
903 delete fetcher; 901 delete fetcher;
904 } else { 902 } else {
905 // The navigation controller will delete the fetcher. 903 // The navigation controller will delete the fetcher.
906 } 904 }
907 } 905 }
908 } 906 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 for (PageActionViews::const_iterator i(page_action_views_.begin()); 993 for (PageActionViews::const_iterator i(page_action_views_.begin());
996 i != page_action_views_.end(); ++i) 994 i != page_action_views_.end(); ++i)
997 RemoveChildView(*i); 995 RemoveChildView(*i);
998 STLDeleteElements(&page_action_views_); 996 STLDeleteElements(&page_action_views_);
999 } 997 }
1000 998
1001 void LocationBarView::RefreshPageActionViews() { 999 void LocationBarView::RefreshPageActionViews() {
1002 if (mode_ != NORMAL) 1000 if (mode_ != NORMAL)
1003 return; 1001 return;
1004 1002
1005 ExtensionService* service = browser_->profile()->GetExtensionService(); 1003 ExtensionService* service = profile_->GetExtensionService();
1006 if (!service) 1004 if (!service)
1007 return; 1005 return;
1008 1006
1009 std::map<ExtensionAction*, bool> old_visibility; 1007 std::map<ExtensionAction*, bool> old_visibility;
1010 for (PageActionViews::const_iterator i(page_action_views_.begin()); 1008 for (PageActionViews::const_iterator i(page_action_views_.begin());
1011 i != page_action_views_.end(); ++i) 1009 i != page_action_views_.end(); ++i)
1012 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible(); 1010 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible();
1013 1011
1014 // Remember the previous visibility of the page actions so that we can 1012 // Remember the previous visibility of the page actions so that we can
1015 // notify when this changes. 1013 // notify when this changes.
(...skipping 10 matching lines...) Expand all
1026 DeletePageActionViews(); // Delete the old views (if any). 1024 DeletePageActionViews(); // Delete the old views (if any).
1027 1025
1028 page_action_views_.resize(page_actions.size()); 1026 page_action_views_.resize(page_actions.size());
1029 View* view = chrome_to_mobile_view_ ? chrome_to_mobile_view_ : 1027 View* view = chrome_to_mobile_view_ ? chrome_to_mobile_view_ :
1030 static_cast<View*>(star_view_); 1028 static_cast<View*>(star_view_);
1031 1029
1032 // Add the page actions in reverse order, so that the child views are 1030 // Add the page actions in reverse order, so that the child views are
1033 // inserted in left-to-right order for accessibility. 1031 // inserted in left-to-right order for accessibility.
1034 for (int i = page_actions.size() - 1; i >= 0; --i) { 1032 for (int i = page_actions.size() - 1; i >= 0; --i) {
1035 page_action_views_[i] = new PageActionWithBadgeView( 1033 page_action_views_[i] = new PageActionWithBadgeView(
1036 new PageActionImageView(this, page_actions[i])); 1034 delegate_->CreatePageActionImageView(this, page_actions[i]));
1037 page_action_views_[i]->SetVisible(false); 1035 page_action_views_[i]->SetVisible(false);
1038 AddChildViewAt(page_action_views_[i], GetIndexOf(view)); 1036 AddChildViewAt(page_action_views_[i], GetIndexOf(view));
1039 } 1037 }
1040 } 1038 }
1041 1039
1042 WebContents* contents = GetWebContentsFromDelegate(delegate_); 1040 WebContents* contents = GetWebContentsFromDelegate(delegate_);
1043 if (!page_action_views_.empty() && contents) { 1041 if (!page_action_views_.empty() && contents) {
1044 GURL url = GURL(model_->GetText()); 1042 GURL url = GURL(model_->GetText());
1045 1043
1046 for (PageActionViews::const_iterator i(page_action_views_.begin()); 1044 for (PageActionViews::const_iterator i(page_action_views_.begin());
(...skipping 22 matching lines...) Expand all
1069 if (views::Widget::IsPureViews()) 1067 if (views::Widget::IsPureViews())
1070 NOTIMPLEMENTED(); 1068 NOTIMPLEMENTED();
1071 else 1069 else
1072 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); 1070 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT());
1073 } 1071 }
1074 #endif 1072 #endif
1075 1073
1076 void LocationBarView::ShowFirstRunBubbleInternal() { 1074 void LocationBarView::ShowFirstRunBubbleInternal() {
1077 #if !defined(OS_CHROMEOS) 1075 #if !defined(OS_CHROMEOS)
1078 // First run bubble doesn't make sense for Chrome OS. 1076 // First run bubble doesn't make sense for Chrome OS.
1079 FirstRunBubble::ShowBubble(browser_->profile(), location_icon_view_); 1077 FirstRunBubble::ShowBubble(profile_, location_icon_view_);
1080 #endif 1078 #endif
1081 } 1079 }
1082 1080
1083 std::string LocationBarView::GetClassName() const { 1081 std::string LocationBarView::GetClassName() const {
1084 return kViewClassName; 1082 return kViewClassName;
1085 } 1083 }
1086 1084
1087 bool LocationBarView::SkipDefaultKeyEventProcessing( 1085 bool LocationBarView::SkipDefaultKeyEventProcessing(
1088 const views::KeyEvent& event) { 1086 const views::KeyEvent& event) {
1089 #if defined(OS_WIN) 1087 #if defined(OS_WIN)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 const gfx::Point& p) { 1157 const gfx::Point& p) {
1160 return true; 1158 return true;
1161 } 1159 }
1162 1160
1163 //////////////////////////////////////////////////////////////////////////////// 1161 ////////////////////////////////////////////////////////////////////////////////
1164 // LocationBarView, LocationBar implementation: 1162 // LocationBarView, LocationBar implementation:
1165 1163
1166 void LocationBarView::ShowFirstRunBubble() { 1164 void LocationBarView::ShowFirstRunBubble() {
1167 // Wait until search engines have loaded to show the first run bubble. 1165 // Wait until search engines have loaded to show the first run bubble.
1168 TemplateURLService* url_service = 1166 TemplateURLService* url_service =
1169 TemplateURLServiceFactory::GetForProfile(browser_->profile()); 1167 TemplateURLServiceFactory::GetForProfile(profile_);
1170 if (!url_service->loaded()) { 1168 if (!url_service->loaded()) {
1171 template_url_service_ = url_service; 1169 template_url_service_ = url_service;
1172 template_url_service_->AddObserver(this); 1170 template_url_service_->AddObserver(this);
1173 template_url_service_->Load(); 1171 template_url_service_->Load();
1174 return; 1172 return;
1175 } 1173 }
1176 ShowFirstRunBubbleInternal(); 1174 ShowFirstRunBubbleInternal();
1177 } 1175 }
1178 1176
1179 void LocationBarView::SetSuggestedText(const string16& text, 1177 void LocationBarView::SetSuggestedText(const string16& text,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 !suggested_text_view_->GetText().empty(); 1304 !suggested_text_view_->GetText().empty();
1307 } 1305 }
1308 1306
1309 #if !defined(USE_AURA) 1307 #if !defined(USE_AURA)
1310 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { 1308 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() {
1311 CHECK(!views::Widget::IsPureViews()); 1309 CHECK(!views::Widget::IsPureViews());
1312 return static_cast<OmniboxViewWin*>(location_entry_.get()); 1310 return static_cast<OmniboxViewWin*>(location_entry_.get());
1313 } 1311 }
1314 #endif 1312 #endif
1315 #endif 1313 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698