| 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/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/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" | |
| 14 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "chrome/browser/ui/global_error_service.h" | 14 #include "chrome/browser/ui/global_error_service.h" |
| 16 #include "chrome/browser/ui/global_error_service_factory.h" | 15 #include "chrome/browser/ui/global_error_service_factory.h" |
| 17 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 16 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| 18 #include "chrome/browser/ui/view_ids.h" | 17 #include "chrome/browser/ui/view_ids.h" |
| 19 #include "chrome/browser/ui/views/browser_actions_container.h" | 18 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 20 #include "chrome/browser/ui/views/event_utils.h" | 19 #include "chrome/browser/ui/views/event_utils.h" |
| 21 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | |
| 22 #include "chrome/browser/ui/views/window.h" | 20 #include "chrome/browser/ui/views/window.h" |
| 23 #include "chrome/browser/ui/views/wrench_menu.h" | 21 #include "chrome/browser/ui/views/wrench_menu.h" |
| 24 #include "chrome/browser/upgrade_detector.h" | 22 #include "chrome/browser/upgrade_detector.h" |
| 25 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
| 26 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 27 #include "content/public/browser/browser_accessibility_state.h" | 25 #include "content/public/browser/browser_accessibility_state.h" |
| 28 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/user_metrics.h" | 27 #include "content/public/browser/user_metrics.h" |
| 30 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
| 31 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 162 |
| 165 forward_ = new views::ButtonDropDown(this, forward_menu_model_.get()); | 163 forward_ = new views::ButtonDropDown(this, forward_menu_model_.get()); |
| 166 forward_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | | 164 forward_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | |
| 167 ui::EF_MIDDLE_MOUSE_BUTTON); | 165 ui::EF_MIDDLE_MOUSE_BUTTON); |
| 168 forward_->set_tag(IDC_FORWARD); | 166 forward_->set_tag(IDC_FORWARD); |
| 169 forward_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_FORWARD)); | 167 forward_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_FORWARD)); |
| 170 forward_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FORWARD)); | 168 forward_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FORWARD)); |
| 171 forward_->set_id(VIEW_ID_FORWARD_BUTTON); | 169 forward_->set_id(VIEW_ID_FORWARD_BUTTON); |
| 172 | 170 |
| 173 // Have to create this before |reload_| as |reload_|'s constructor needs it. | 171 // Have to create this before |reload_| as |reload_|'s constructor needs it. |
| 174 location_bar_ = new LocationBarView( | 172 location_bar_ = new LocationBarView(browser_, model_, this, |
| 175 browser_->profile(), | |
| 176 browser_->command_updater(), | |
| 177 model_, | |
| 178 this, | |
| 179 (display_mode_ == DISPLAYMODE_LOCATION) ? | 173 (display_mode_ == DISPLAYMODE_LOCATION) ? |
| 180 LocationBarView::POPUP : LocationBarView::NORMAL); | 174 LocationBarView::POPUP : LocationBarView::NORMAL); |
| 181 | 175 |
| 182 reload_ = new ReloadButton(location_bar_, browser_->command_updater()); | 176 reload_ = new ReloadButton(location_bar_, browser_); |
| 183 reload_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | | 177 reload_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | |
| 184 ui::EF_MIDDLE_MOUSE_BUTTON); | 178 ui::EF_MIDDLE_MOUSE_BUTTON); |
| 185 reload_->set_tag(IDC_RELOAD); | 179 reload_->set_tag(IDC_RELOAD); |
| 186 reload_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_RELOAD)); | 180 reload_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_RELOAD)); |
| 187 reload_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_RELOAD)); | 181 reload_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_RELOAD)); |
| 188 reload_->set_id(VIEW_ID_RELOAD_BUTTON); | 182 reload_->set_id(VIEW_ID_RELOAD_BUTTON); |
| 189 | 183 |
| 190 home_ = new views::ImageButton(this); | 184 home_ = new views::ImageButton(this); |
| 191 home_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | | 185 home_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | |
| 192 ui::EF_MIDDLE_MOUSE_BUTTON); | 186 ui::EF_MIDDLE_MOUSE_BUTTON); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 // ToolbarView, LocationBarView::Delegate implementation: | 359 // ToolbarView, LocationBarView::Delegate implementation: |
| 366 | 360 |
| 367 TabContentsWrapper* ToolbarView::GetTabContentsWrapper() const { | 361 TabContentsWrapper* ToolbarView::GetTabContentsWrapper() const { |
| 368 return browser_->GetSelectedTabContentsWrapper(); | 362 return browser_->GetSelectedTabContentsWrapper(); |
| 369 } | 363 } |
| 370 | 364 |
| 371 InstantController* ToolbarView::GetInstant() { | 365 InstantController* ToolbarView::GetInstant() { |
| 372 return browser_->instant(); | 366 return browser_->instant(); |
| 373 } | 367 } |
| 374 | 368 |
| 375 ContentSettingBubbleModelDelegate* | |
| 376 ToolbarView::GetContentSettingBubbleModelDelegate() { | |
| 377 return browser_->content_setting_bubble_model_delegate(); | |
| 378 } | |
| 379 | |
| 380 void ToolbarView::ShowPageInfo(content::WebContents* web_contents, | |
| 381 const GURL& url, | |
| 382 const content::SSLStatus& ssl, | |
| 383 bool show_history) { | |
| 384 browser_->ShowPageInfo(web_contents, url, ssl, show_history); | |
| 385 } | |
| 386 | |
| 387 views::Widget* ToolbarView::CreateViewsBubble( | |
| 388 views::BubbleDelegateView* bubble_delegate) { | |
| 389 return browser::CreateViewsBubble(bubble_delegate); | |
| 390 } | |
| 391 | |
| 392 PageActionImageView* ToolbarView::CreatePageActionImageView( | |
| 393 LocationBarView* owner, ExtensionAction* action) { | |
| 394 return new PageActionImageView(owner, action, browser_); | |
| 395 } | |
| 396 | |
| 397 void ToolbarView::OnInputInProgress(bool in_progress) { | 369 void ToolbarView::OnInputInProgress(bool in_progress) { |
| 398 // The edit should make sure we're only notified when something changes. | 370 // The edit should make sure we're only notified when something changes. |
| 399 DCHECK(model_->input_in_progress() != in_progress); | 371 DCHECK(model_->input_in_progress() != in_progress); |
| 400 | 372 |
| 401 model_->set_input_in_progress(in_progress); | 373 model_->set_input_in_progress(in_progress); |
| 402 location_bar_->Update(NULL); | 374 location_bar_->Update(NULL); |
| 403 } | 375 } |
| 404 | 376 |
| 405 //////////////////////////////////////////////////////////////////////////////// | 377 //////////////////////////////////////////////////////////////////////////////// |
| 406 // ToolbarView, CommandUpdater::CommandObserver implementation: | 378 // ToolbarView, CommandUpdater::CommandObserver implementation: |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 accname_app = l10n_util::GetStringFUTF16( | 747 accname_app = l10n_util::GetStringFUTF16( |
| 776 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); | 748 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); |
| 777 } | 749 } |
| 778 app_menu_->SetAccessibleName(accname_app); | 750 app_menu_->SetAccessibleName(accname_app); |
| 779 | 751 |
| 780 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); | 752 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); |
| 781 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 753 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); |
| 782 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 754 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); |
| 783 SchedulePaint(); | 755 SchedulePaint(); |
| 784 } | 756 } |
| OLD | NEW |