OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar_view.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/i18n/number_formatting.h" | 11 #include "base/i18n/number_formatting.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/command_updater.h" | 16 #include "chrome/browser/command_updater.h" |
17 #include "chrome/browser/extensions/extension_action.h" | 17 #include "chrome/browser/extensions/extension_action.h" |
18 #include "chrome/browser/extensions/extension_action_manager.h" | 18 #include "chrome/browser/extensions/extension_action_manager.h" |
| 19 #include "chrome/browser/extensions/extension_util.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/themes/theme_service.h" | 21 #include "chrome/browser/themes/theme_service.h" |
21 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_command_controller.h" | 23 #include "chrome/browser/ui/browser_command_controller.h" |
23 #include "chrome/browser/ui/browser_commands.h" | 24 #include "chrome/browser/ui/browser_commands.h" |
24 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" | 25 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" |
25 #include "chrome/browser/ui/browser_instant_controller.h" | 26 #include "chrome/browser/ui/browser_instant_controller.h" |
26 #include "chrome/browser/ui/browser_tabstrip.h" | 27 #include "chrome/browser/ui/browser_tabstrip.h" |
27 #include "chrome/browser/ui/browser_window.h" | 28 #include "chrome/browser/ui/browser_window.h" |
28 #include "chrome/browser/ui/global_error/global_error_service.h" | 29 #include "chrome/browser/ui/global_error/global_error_service.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // our spacing to make it match. | 97 // our spacing to make it match. |
97 const int kLeftEdgeSpacing = 3; | 98 const int kLeftEdgeSpacing = 3; |
98 const int kRightEdgeSpacing = 2; | 99 const int kRightEdgeSpacing = 2; |
99 | 100 |
100 // Ash doesn't use a rounded content area and its top edge has an extra shadow. | 101 // Ash doesn't use a rounded content area and its top edge has an extra shadow. |
101 const int kContentShadowHeightAsh = 2; | 102 const int kContentShadowHeightAsh = 2; |
102 | 103 |
103 // Non-ash uses a rounded content area with no shadow in the assets. | 104 // Non-ash uses a rounded content area with no shadow in the assets. |
104 const int kContentShadowHeight = 0; | 105 const int kContentShadowHeight = 0; |
105 | 106 |
106 bool IsStreamlinedHostedAppsEnabled() { | |
107 return CommandLine::ForCurrentProcess()->HasSwitch( | |
108 switches::kEnableStreamlinedHostedApps); | |
109 } | |
110 | |
111 #if !defined(OS_CHROMEOS) | 107 #if !defined(OS_CHROMEOS) |
112 bool HasAshShell() { | 108 bool HasAshShell() { |
113 #if defined(USE_ASH) | 109 #if defined(USE_ASH) |
114 return ash::Shell::HasInstance(); | 110 return ash::Shell::HasInstance(); |
115 #else | 111 #else |
116 return false; | 112 return false; |
117 #endif // USE_ASH | 113 #endif // USE_ASH |
118 } | 114 } |
119 #endif // OS_CHROMEOS | 115 #endif // OS_CHROMEOS |
120 | 116 |
(...skipping 24 matching lines...) Expand all Loading... |
145 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); | 141 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); |
146 | 142 |
147 chrome::AddCommandObserver(browser_, IDC_BACK, this); | 143 chrome::AddCommandObserver(browser_, IDC_BACK, this); |
148 chrome::AddCommandObserver(browser_, IDC_FORWARD, this); | 144 chrome::AddCommandObserver(browser_, IDC_FORWARD, this); |
149 chrome::AddCommandObserver(browser_, IDC_RELOAD, this); | 145 chrome::AddCommandObserver(browser_, IDC_RELOAD, this); |
150 chrome::AddCommandObserver(browser_, IDC_HOME, this); | 146 chrome::AddCommandObserver(browser_, IDC_HOME, this); |
151 chrome::AddCommandObserver(browser_, IDC_LOAD_NEW_TAB_PAGE, this); | 147 chrome::AddCommandObserver(browser_, IDC_LOAD_NEW_TAB_PAGE, this); |
152 | 148 |
153 display_mode_ = DISPLAYMODE_LOCATION; | 149 display_mode_ = DISPLAYMODE_LOCATION; |
154 if (browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) || | 150 if (browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) || |
155 (browser->is_app() && IsStreamlinedHostedAppsEnabled())) | 151 (browser->is_app() && extensions::util::IsStreamlinedHostedAppsEnabled())) |
156 display_mode_ = DISPLAYMODE_NORMAL; | 152 display_mode_ = DISPLAYMODE_NORMAL; |
157 | 153 |
158 if (OutdatedUpgradeBubbleView::IsAvailable()) { | 154 if (OutdatedUpgradeBubbleView::IsAvailable()) { |
159 registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL, | 155 registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL, |
160 content::NotificationService::AllSources()); | 156 content::NotificationService::AllSources()); |
161 registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU, | 157 registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU, |
162 content::NotificationService::AllSources()); | 158 content::NotificationService::AllSources()); |
163 } | 159 } |
164 #if defined(OS_WIN) | 160 #if defined(OS_WIN) |
165 registrar_.Add(this, chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, | 161 registrar_.Add(this, chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 | 564 |
569 forward_->SetBounds(next_element_x, child_y, | 565 forward_->SetBounds(next_element_x, child_y, |
570 forward_->GetPreferredSize().width(), child_height); | 566 forward_->GetPreferredSize().width(), child_height); |
571 next_element_x = forward_->bounds().right(); | 567 next_element_x = forward_->bounds().right(); |
572 | 568 |
573 reload_->SetBounds(next_element_x, child_y, | 569 reload_->SetBounds(next_element_x, child_y, |
574 reload_->GetPreferredSize().width(), child_height); | 570 reload_->GetPreferredSize().width(), child_height); |
575 next_element_x = reload_->bounds().right(); | 571 next_element_x = reload_->bounds().right(); |
576 | 572 |
577 if (show_home_button_.GetValue() || | 573 if (show_home_button_.GetValue() || |
578 (browser_->is_app() && IsStreamlinedHostedAppsEnabled())) { | 574 (browser_->is_app() && |
| 575 extensions::util::IsStreamlinedHostedAppsEnabled())) { |
579 home_->SetVisible(true); | 576 home_->SetVisible(true); |
580 home_->SetBounds(next_element_x, child_y, | 577 home_->SetBounds(next_element_x, child_y, |
581 home_->GetPreferredSize().width(), child_height); | 578 home_->GetPreferredSize().width(), child_height); |
582 } else { | 579 } else { |
583 home_->SetVisible(false); | 580 home_->SetVisible(false); |
584 home_->SetBounds(next_element_x, child_y, 0, child_height); | 581 home_->SetBounds(next_element_x, child_y, 0, child_height); |
585 } | 582 } |
586 next_element_x = home_->bounds().right() + kStandardSpacing; | 583 next_element_x = home_->bounds().right() + kStandardSpacing; |
587 | 584 |
588 int browser_actions_width = browser_actions_->GetPreferredSize().width(); | 585 int browser_actions_width = browser_actions_->GetPreferredSize().width(); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 | 784 |
788 void ToolbarView::OnShowHomeButtonChanged() { | 785 void ToolbarView::OnShowHomeButtonChanged() { |
789 Layout(); | 786 Layout(); |
790 SchedulePaint(); | 787 SchedulePaint(); |
791 } | 788 } |
792 | 789 |
793 int ToolbarView::content_shadow_height() const { | 790 int ToolbarView::content_shadow_height() const { |
794 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? | 791 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? |
795 kContentShadowHeightAsh : kContentShadowHeight; | 792 kContentShadowHeightAsh : kContentShadowHeight; |
796 } | 793 } |
OLD | NEW |