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

Side by Side Diff: chrome/browser/ui/views/toolbar_view.cc

Issue 10854017: Basic metro snap view omnibox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix chromeos compilation. Created 8 years, 4 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
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/toolbar_view.h" 5 #include "chrome/browser/ui/views/toolbar_view.h"
6 6
7 #include "base/i18n/number_formatting.h" 7 #include "base/i18n/number_formatting.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/command_updater.h" 10 #include "chrome/browser/command_updater.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // NOTE: Don't remove the command observers here. This object gets destroyed 213 // NOTE: Don't remove the command observers here. This object gets destroyed
214 // after the Browser (which owns the CommandUpdater), so the CommandUpdater is 214 // after the Browser (which owns the CommandUpdater), so the CommandUpdater is
215 // already gone. 215 // already gone.
216 216
217 // TODO(kuan): Reset the search model observer in ~BrowserView before we lose 217 // TODO(kuan): Reset the search model observer in ~BrowserView before we lose
218 // browser. 218 // browser.
219 } 219 }
220 220
221 void ToolbarView::Init(views::View* location_bar_parent, 221 void ToolbarView::Init(views::View* location_bar_parent,
222 views::View* popup_parent_view) { 222 views::View* popup_parent_view) {
223 // Remember the popup_parent_view_ in case we need to swap out the
224 // LocationBarView later.
225 popup_parent_view_ = popup_parent_view;
226
223 back_ = new views::ButtonDropDown(this, new BackForwardMenuModel( 227 back_ = new views::ButtonDropDown(this, new BackForwardMenuModel(
224 browser_, BackForwardMenuModel::BACKWARD_MENU)); 228 browser_, BackForwardMenuModel::BACKWARD_MENU));
225 back_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | 229 back_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON |
226 ui::EF_MIDDLE_MOUSE_BUTTON); 230 ui::EF_MIDDLE_MOUSE_BUTTON);
227 back_->set_tag(IDC_BACK); 231 back_->set_tag(IDC_BACK);
228 back_->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, 232 back_->SetImageAlignment(views::ImageButton::ALIGN_RIGHT,
229 views::ImageButton::ALIGN_TOP); 233 views::ImageButton::ALIGN_TOP);
230 back_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_BACK)); 234 back_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_BACK));
231 back_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_BACK)); 235 back_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_BACK));
232 back_->set_id(VIEW_ID_BACK_BUTTON); 236 back_->set_id(VIEW_ID_BACK_BUTTON);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 LoadImages(); 300 LoadImages();
297 301
298 // Always add children in order from left to right, for accessibility. 302 // Always add children in order from left to right, for accessibility.
299 AddChildView(back_); 303 AddChildView(back_);
300 AddChildView(forward_); 304 AddChildView(forward_);
301 AddChildView(reload_); 305 AddChildView(reload_);
302 AddChildView(home_); 306 AddChildView(home_);
303 AddChildView(browser_actions_); 307 AddChildView(browser_actions_);
304 AddChildView(app_menu_); 308 AddChildView(app_menu_);
305 309
306 location_bar_->Init(popup_parent_view); 310 location_bar_->Init(popup_parent_view_);
307 show_home_button_.Init(prefs::kShowHomeButton, 311 show_home_button_.Init(prefs::kShowHomeButton,
308 browser_->profile()->GetPrefs(), this); 312 browser_->profile()->GetPrefs(), this);
309 browser_actions_->Init(); 313 browser_actions_->Init();
310 314
311 // Accessibility specific tooltip text. 315 // Accessibility specific tooltip text.
312 if (BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { 316 if (BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) {
313 back_->SetTooltipText( 317 back_->SetTooltipText(
314 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK)); 318 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK));
315 forward_->SetTooltipText( 319 forward_->SetTooltipText(
316 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD)); 320 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD));
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 // ImageSkia takes ownership of |source|. 404 // ImageSkia takes ownership of |source|.
401 return gfx::ImageSkia(source, source->size()); 405 return gfx::ImageSkia(source, source->size());
402 } 406 }
403 407
404 void ToolbarView::LayoutForSearch() { 408 void ToolbarView::LayoutForSearch() {
405 if (chrome::search::IsInstantExtendedAPIEnabled(browser_->profile()) && 409 if (chrome::search::IsInstantExtendedAPIEnabled(browser_->profile()) &&
406 browser_->search_model()->mode().is_ntp()) 410 browser_->search_model()->mode().is_ntp())
407 LayoutLocationBarNTP(); 411 LayoutLocationBarNTP();
408 } 412 }
409 413
414 void ToolbarView::SetMetroSnapDisplayMode(bool enable) {
415 if ((enable && display_mode_ == DISPLAYMODE_METROSNAP) ||
416 (!enable && display_mode_ != DISPLAYMODE_METROSNAP))
417 return;
418
419 LocationBarView::Mode location_bar_mode = LocationBarView::NORMAL;
420 views::View* parent_view = NULL;
421 if (enable) {
422 display_mode_ = DISPLAYMODE_METROSNAP;
423 location_bar_mode = LocationBarView::METRO_SNAP;
424 } else {
425 display_mode_ = DISPLAYMODE_NORMAL;
426 parent_view = popup_parent_view_;
427 }
428
429 // Create a new location bar to swap with the current one.
430 LocationBarView* new_location_bar_view = new LocationBarView(
431 browser_,
432 browser_->profile(),
433 browser_->command_controller()->command_updater(),
434 model_,
435 this,
436 browser_->search_model(),
437 location_bar_mode);
438 location_bar_container_->SetLocationBarView(new_location_bar_view);
439
440 // Since it has now been removed from the view hierarchy, it is safe to
441 // delete the old view location bar.
442 delete location_bar_;
443
444 location_bar_ = new_location_bar_view;
445 location_bar_->Init(parent_view);
446 location_bar_->Layout();
447
448 Layout();
449 LayoutForSearch();
450 SchedulePaint();
451 }
452
410 //////////////////////////////////////////////////////////////////////////////// 453 ////////////////////////////////////////////////////////////////////////////////
411 // ToolbarView, AccessiblePaneView overrides: 454 // ToolbarView, AccessiblePaneView overrides:
412 455
413 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { 456 bool ToolbarView::SetPaneFocus(views::View* initial_focus) {
414 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) 457 if (!AccessiblePaneView::SetPaneFocus(initial_focus))
415 return false; 458 return false;
416 459
417 location_bar_->SetShowFocusRect(true); 460 location_bar_->SetShowFocusRect(true);
418 return true; 461 return true;
419 } 462 }
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 // LocationBarContainer is not a child of the ToolbarView. 1055 // LocationBarContainer is not a child of the ToolbarView.
1013 gfx::Point origin(bounds.origin()); 1056 gfx::Point origin(bounds.origin());
1014 views::View::ConvertPointToView(this, location_bar_container_->parent(), 1057 views::View::ConvertPointToView(this, location_bar_container_->parent(),
1015 &origin); 1058 &origin);
1016 gfx::Rect target_bounds(origin, bounds.size()); 1059 gfx::Rect target_bounds(origin, bounds.size());
1017 if (location_bar_container_->GetTargetBounds() != target_bounds) { 1060 if (location_bar_container_->GetTargetBounds() != target_bounds) {
1018 location_bar_container_->SetInToolbar(true); 1061 location_bar_container_->SetInToolbar(true);
1019 location_bar_container_->SetBoundsRect(target_bounds); 1062 location_bar_container_->SetBoundsRect(target_bounds);
1020 } 1063 }
1021 } 1064 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698