| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/wrench_menu.h" | 5 #include "chrome/browser/ui/views/wrench_menu.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h" | 16 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h" |
| 17 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
| 18 #include "content/browser/user_metrics.h" | 18 #include "content/browser/user_metrics.h" |
| 19 #include "content/common/content_notification_types.h" |
| 19 #include "content/common/notification_observer.h" | 20 #include "content/common/notification_observer.h" |
| 20 #include "content/common/notification_registrar.h" | 21 #include "content/common/notification_registrar.h" |
| 21 #include "content/common/notification_source.h" | 22 #include "content/common/notification_source.h" |
| 22 #include "content/common/notification_type.h" | |
| 23 #include "grit/chromium_strings.h" | 23 #include "grit/chromium_strings.h" |
| 24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 25 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
| 26 #include "third_party/skia/include/core/SkPaint.h" | 26 #include "third_party/skia/include/core/SkPaint.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
| 29 #include "ui/gfx/canvas.h" | 29 #include "ui/gfx/canvas.h" |
| 30 #include "ui/gfx/canvas_skia.h" | 30 #include "ui/gfx/canvas_skia.h" |
| 31 #include "ui/gfx/skia_util.h" | 31 #include "ui/gfx/skia_util.h" |
| 32 #include "views/background.h" | 32 #include "views/background.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 fullscreen_button_->set_background( | 431 fullscreen_button_->set_background( |
| 432 new MenuButtonBackground(MenuButtonBackground::SINGLE_BUTTON)); | 432 new MenuButtonBackground(MenuButtonBackground::SINGLE_BUTTON)); |
| 433 fullscreen_button_->SetAccessibleName( | 433 fullscreen_button_->SetAccessibleName( |
| 434 GetAccessibleNameForWrenchMenuItem( | 434 GetAccessibleNameForWrenchMenuItem( |
| 435 menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN)); | 435 menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN)); |
| 436 AddChildView(fullscreen_button_); | 436 AddChildView(fullscreen_button_); |
| 437 | 437 |
| 438 UpdateZoomControls(); | 438 UpdateZoomControls(); |
| 439 | 439 |
| 440 registrar_.Add( | 440 registrar_.Add( |
| 441 this, NotificationType::ZOOM_LEVEL_CHANGED, | 441 this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, |
| 442 Source<HostZoomMap>(menu->browser_->profile()->GetHostZoomMap())); | 442 Source<HostZoomMap>(menu->browser_->profile()->GetHostZoomMap())); |
| 443 } | 443 } |
| 444 | 444 |
| 445 gfx::Size GetPreferredSize() { | 445 gfx::Size GetPreferredSize() { |
| 446 // The increment/decrement button are forced to the same width. | 446 // The increment/decrement button are forced to the same width. |
| 447 int button_width = std::max(increment_button_->GetPreferredSize().width(), | 447 int button_width = std::max(increment_button_->GetPreferredSize().width(), |
| 448 decrement_button_->GetPreferredSize().width()); | 448 decrement_button_->GetPreferredSize().width()); |
| 449 int fullscreen_width = fullscreen_button_->GetPreferredSize().width(); | 449 int fullscreen_width = fullscreen_button_->GetPreferredSize().width(); |
| 450 // Returned height doesn't matter as MenuItemView forces everything to the | 450 // Returned height doesn't matter as MenuItemView forces everything to the |
| 451 // height of the menuitemview. | 451 // height of the menuitemview. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 481 virtual void ButtonPressed(views::Button* sender, const views::Event& event) { | 481 virtual void ButtonPressed(views::Button* sender, const views::Event& event) { |
| 482 if (sender->tag() == fullscreen_index_) { | 482 if (sender->tag() == fullscreen_index_) { |
| 483 menu_->CancelAndEvaluate(menu_model_, sender->tag()); | 483 menu_->CancelAndEvaluate(menu_model_, sender->tag()); |
| 484 } else { | 484 } else { |
| 485 // Zoom buttons don't close the menu. | 485 // Zoom buttons don't close the menu. |
| 486 menu_model_->ActivatedAt(sender->tag()); | 486 menu_model_->ActivatedAt(sender->tag()); |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 | 489 |
| 490 // NotificationObserver: | 490 // NotificationObserver: |
| 491 virtual void Observe(NotificationType type, | 491 virtual void Observe(int type, |
| 492 const NotificationSource& source, | 492 const NotificationSource& source, |
| 493 const NotificationDetails& details) { | 493 const NotificationDetails& details) { |
| 494 DCHECK_EQ(NotificationType::ZOOM_LEVEL_CHANGED, type.value); | 494 DCHECK_EQ(content::NOTIFICATION_ZOOM_LEVEL_CHANGED, type); |
| 495 UpdateZoomControls(); | 495 UpdateZoomControls(); |
| 496 } | 496 } |
| 497 | 497 |
| 498 private: | 498 private: |
| 499 void UpdateZoomControls() { | 499 void UpdateZoomControls() { |
| 500 bool enable_increment = false; | 500 bool enable_increment = false; |
| 501 bool enable_decrement = false; | 501 bool enable_decrement = false; |
| 502 TabContents* selected_tab = menu_->browser_->GetSelectedTabContents(); | 502 TabContents* selected_tab = menu_->browser_->GetSelectedTabContents(); |
| 503 int zoom = 100; | 503 int zoom = 100; |
| 504 if (selected_tab) | 504 if (selected_tab) |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 model->AddObserver(this); | 855 model->AddObserver(this); |
| 856 bookmark_menu_delegate_.reset( | 856 bookmark_menu_delegate_.reset( |
| 857 new BookmarkMenuDelegate(browser_->profile(), | 857 new BookmarkMenuDelegate(browser_->profile(), |
| 858 NULL, | 858 NULL, |
| 859 browser_->window()->GetNativeHandle(), | 859 browser_->window()->GetNativeHandle(), |
| 860 first_bookmark_command_id_)); | 860 first_bookmark_command_id_)); |
| 861 bookmark_menu_delegate_->Init( | 861 bookmark_menu_delegate_->Init( |
| 862 this, bookmark_menu_, model->GetBookmarkBarNode(), 0, | 862 this, bookmark_menu_, model->GetBookmarkBarNode(), 0, |
| 863 BookmarkMenuDelegate::SHOW_OTHER_FOLDER); | 863 BookmarkMenuDelegate::SHOW_OTHER_FOLDER); |
| 864 } | 864 } |
| OLD | NEW |