| OLD | NEW |
| 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/bind.h" |
| 7 #include "base/i18n/number_formatting.h" | 8 #include "base/i18n/number_formatting.h" |
| 8 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/command_updater.h" | 11 #include "chrome/browser/command_updater.h" |
| 11 #include "chrome/browser/event_disposition.h" | 12 #include "chrome/browser/event_disposition.h" |
| 12 #include "chrome/browser/infobars/infobar_tab_helper.h" | 13 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/themes/theme_service.h" | 16 #include "chrome/browser/themes/theme_service.h" |
| 16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 105 |
| 105 // Top margin for the wrench menu badges (badge is placed in the upper right | 106 // Top margin for the wrench menu badges (badge is placed in the upper right |
| 106 // corner of the wrench menu). | 107 // corner of the wrench menu). |
| 107 const int kBadgeTopMargin = 2; | 108 const int kBadgeTopMargin = 2; |
| 108 | 109 |
| 109 // Added padding for search toolbar. | 110 // Added padding for search toolbar. |
| 110 const int kSearchTopButtonSpacing = 3; | 111 const int kSearchTopButtonSpacing = 3; |
| 111 const int kSearchTopLocationBarSpacing = 2; | 112 const int kSearchTopLocationBarSpacing = 2; |
| 112 const int kSearchToolbarSpacing = 5; | 113 const int kSearchToolbarSpacing = 5; |
| 113 | 114 |
| 114 // How often to show the disabled extension (sideload wipeout) bubble. | |
| 115 const int kShowSideloadWipeoutBubbleMax = 3; | |
| 116 | |
| 117 gfx::ImageSkia* kPopupBackgroundEdge = NULL; | 115 gfx::ImageSkia* kPopupBackgroundEdge = NULL; |
| 118 | 116 |
| 119 // The omnibox border has some additional shadow, so we use less vertical | 117 // The omnibox border has some additional shadow, so we use less vertical |
| 120 // spacing than ToolbarView::kVertSpacing. | 118 // spacing than ToolbarView::kVertSpacing. |
| 121 int location_bar_vert_spacing() { | 119 int location_bar_vert_spacing() { |
| 122 static int value = -1; | 120 static int value = -1; |
| 123 if (value == -1) { | 121 if (value == -1) { |
| 124 switch (ui::GetDisplayLayout()) { | 122 switch (ui::GetDisplayLayout()) { |
| 125 case ui::LAYOUT_ASH: | 123 case ui::LAYOUT_ASH: |
| 126 case ui::LAYOUT_DESKTOP: | 124 case ui::LAYOUT_DESKTOP: |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 AddChildView(back_); | 304 AddChildView(back_); |
| 307 AddChildView(forward_); | 305 AddChildView(forward_); |
| 308 AddChildView(reload_); | 306 AddChildView(reload_); |
| 309 AddChildView(home_); | 307 AddChildView(home_); |
| 310 AddChildView(browser_actions_); | 308 AddChildView(browser_actions_); |
| 311 AddChildView(app_menu_); | 309 AddChildView(app_menu_); |
| 312 | 310 |
| 313 location_bar_->Init(popup_parent_view); | 311 location_bar_->Init(popup_parent_view); |
| 314 show_home_button_.Init(prefs::kShowHomeButton, | 312 show_home_button_.Init(prefs::kShowHomeButton, |
| 315 browser_->profile()->GetPrefs(), this); | 313 browser_->profile()->GetPrefs(), this); |
| 316 sideload_wipeout_bubble_shown_.Init( | |
| 317 prefs::kExtensionsSideloadWipeoutBubbleShown, | |
| 318 browser_->profile()->GetPrefs(), NULL); | |
| 319 | 314 |
| 320 browser_actions_->Init(); | 315 browser_actions_->Init(); |
| 321 | 316 |
| 322 // Accessibility specific tooltip text. | 317 // Accessibility specific tooltip text. |
| 323 if (BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { | 318 if (BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { |
| 324 back_->SetTooltipText( | 319 back_->SetTooltipText( |
| 325 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK)); | 320 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK)); |
| 326 forward_->SetTooltipText( | 321 forward_->SetTooltipText( |
| 327 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD)); | 322 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD)); |
| 328 } | 323 } |
| 329 | 324 |
| 330 int bubble_shown_count = sideload_wipeout_bubble_shown_.GetValue(); | 325 MessageLoop::current()->PostTask( |
| 331 if (bubble_shown_count < kShowSideloadWipeoutBubbleMax && | 326 FROM_HERE, |
| 332 DisabledExtensionsView::MaybeShow(browser_, app_menu_)) | 327 base::Bind(&DisabledExtensionsView::MaybeShow, browser_, app_menu_)); |
| 333 sideload_wipeout_bubble_shown_.SetValue(++bubble_shown_count); | |
| 334 } | 328 } |
| 335 | 329 |
| 336 void ToolbarView::Update(WebContents* tab, bool should_restore_state) { | 330 void ToolbarView::Update(WebContents* tab, bool should_restore_state) { |
| 337 if (location_bar_) | 331 if (location_bar_) |
| 338 location_bar_->Update(should_restore_state ? tab : NULL); | 332 location_bar_->Update(should_restore_state ? tab : NULL); |
| 339 | 333 |
| 340 if (browser_actions_) | 334 if (browser_actions_) |
| 341 browser_actions_->RefreshBrowserActionViews(); | 335 browser_actions_->RefreshBrowserActionViews(); |
| 342 | 336 |
| 343 if (reload_) | 337 if (reload_) |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 // LocationBarContainer is not a child of the ToolbarView. | 1042 // LocationBarContainer is not a child of the ToolbarView. |
| 1049 gfx::Point origin(bounds.origin()); | 1043 gfx::Point origin(bounds.origin()); |
| 1050 views::View::ConvertPointToTarget(this, location_bar_container_->parent(), | 1044 views::View::ConvertPointToTarget(this, location_bar_container_->parent(), |
| 1051 &origin); | 1045 &origin); |
| 1052 gfx::Rect target_bounds(origin, bounds.size()); | 1046 gfx::Rect target_bounds(origin, bounds.size()); |
| 1053 if (location_bar_container_->GetTargetBounds() != target_bounds) { | 1047 if (location_bar_container_->GetTargetBounds() != target_bounds) { |
| 1054 location_bar_container_->SetInToolbar(true); | 1048 location_bar_container_->SetInToolbar(true); |
| 1055 location_bar_container_->SetBoundsRect(target_bounds); | 1049 location_bar_container_->SetBoundsRect(target_bounds); |
| 1056 } | 1050 } |
| 1057 } | 1051 } |
| OLD | NEW |