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/toolbar/wrench_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #if defined(OS_CHROMEOS) | 59 #if defined(OS_CHROMEOS) |
60 #include "chromeos/chromeos_switches.h" | 60 #include "chromeos/chromeos_switches.h" |
61 #endif | 61 #endif |
62 | 62 |
63 #if defined(OS_WIN) | 63 #if defined(OS_WIN) |
64 #include "base/win/metro.h" | 64 #include "base/win/metro.h" |
65 #include "base/win/windows_version.h" | 65 #include "base/win/windows_version.h" |
66 #include "chrome/browser/enumerate_modules_model_win.h" | 66 #include "chrome/browser/enumerate_modules_model_win.h" |
67 #include "chrome/browser/ui/metro_pin_tab_helper_win.h" | 67 #include "chrome/browser/ui/metro_pin_tab_helper_win.h" |
68 #include "content/public/browser/gpu_data_manager.h" | 68 #include "content/public/browser/gpu_data_manager.h" |
69 #include "win8/util/win8_util.h" | |
70 #endif | 69 #endif |
71 | 70 |
72 #if defined(USE_ASH) | 71 #if defined(USE_ASH) |
73 #include "ash/shell.h" | 72 #include "ash/shell.h" |
74 #endif | 73 #endif |
75 | 74 |
76 using base::UserMetricsAction; | 75 using base::UserMetricsAction; |
77 using content::HostZoomMap; | 76 using content::HostZoomMap; |
78 using content::WebContents; | 77 using content::WebContents; |
79 | 78 |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 : ui::SimpleMenuModel(this), | 474 : ui::SimpleMenuModel(this), |
476 provider_(NULL), | 475 provider_(NULL), |
477 browser_(NULL), | 476 browser_(NULL), |
478 tab_strip_model_(NULL) { | 477 tab_strip_model_(NULL) { |
479 } | 478 } |
480 | 479 |
481 bool WrenchMenuModel::ShouldShowNewIncognitoWindowMenuItem() { | 480 bool WrenchMenuModel::ShouldShowNewIncognitoWindowMenuItem() { |
482 if (browser_->profile()->IsManaged()) | 481 if (browser_->profile()->IsManaged()) |
483 return false; | 482 return false; |
484 | 483 |
485 #if defined(OS_WIN) | |
486 if (win8::IsSingleWindowMetroMode() && | |
487 browser_->profile()->HasOffTheRecordProfile()) { | |
488 return false; | |
489 } | |
490 #endif | |
491 | |
492 return !browser_->profile()->IsGuestSession(); | 484 return !browser_->profile()->IsGuestSession(); |
493 } | 485 } |
494 | 486 |
495 bool WrenchMenuModel::ShouldShowNewWindowMenuItem() { | |
496 #if defined(OS_WIN) | |
497 if (!win8::IsSingleWindowMetroMode()) | |
498 return true; | |
499 | |
500 // In Win8's single window Metro mode, we only show the New Window options | |
501 // if there isn't already a window of the requested type (incognito or not) | |
502 // that is available. | |
503 return browser_->profile()->IsOffTheRecord() && | |
504 !chrome::FindBrowserWithProfile( | |
505 browser_->profile()->GetOriginalProfile(), | |
506 browser_->host_desktop_type()); | |
507 #else | |
508 return true; | |
509 #endif | |
510 } | |
511 | |
512 void WrenchMenuModel::Build(bool is_new_menu) { | 487 void WrenchMenuModel::Build(bool is_new_menu) { |
513 #if defined(OS_WIN) | 488 #if defined(OS_WIN) |
514 AddItem(IDC_VIEW_INCOMPATIBILITIES, | 489 AddItem(IDC_VIEW_INCOMPATIBILITIES, |
515 l10n_util::GetStringUTF16(IDS_VIEW_INCOMPATIBILITIES)); | 490 l10n_util::GetStringUTF16(IDS_VIEW_INCOMPATIBILITIES)); |
516 EnumerateModulesModel* model = | 491 EnumerateModulesModel* model = |
517 EnumerateModulesModel::GetInstance(); | 492 EnumerateModulesModel::GetInstance(); |
518 if (model->modules_to_notify_about() > 0 || | 493 if (model->modules_to_notify_about() > 0 || |
519 model->confirmed_bad_modules_detected() > 0) | 494 model->confirmed_bad_modules_detected() > 0) |
520 AddSeparator(ui::NORMAL_SEPARATOR); | 495 AddSeparator(ui::NORMAL_SEPARATOR); |
521 #endif | 496 #endif |
522 | 497 |
523 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); | 498 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); |
524 if (ShouldShowNewWindowMenuItem()) | 499 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); |
525 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); | |
526 | 500 |
527 if (ShouldShowNewIncognitoWindowMenuItem()) | 501 if (ShouldShowNewIncognitoWindowMenuItem()) |
528 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); | 502 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); |
529 | 503 |
530 #if defined(OS_WIN) && !defined(NDEBUG) && defined(USE_ASH) | 504 #if defined(OS_WIN) && !defined(NDEBUG) && defined(USE_ASH) |
531 if (base::win::GetVersion() < base::win::VERSION_WIN8 && | 505 if (base::win::GetVersion() < base::win::VERSION_WIN8 && |
532 chrome::HOST_DESKTOP_TYPE_NATIVE != chrome::HOST_DESKTOP_TYPE_ASH) { | 506 chrome::HOST_DESKTOP_TYPE_NATIVE != chrome::HOST_DESKTOP_TYPE_ASH) { |
533 AddItemWithStringId(IDC_TOGGLE_ASH_DESKTOP, | 507 AddItemWithStringId(IDC_TOGGLE_ASH_DESKTOP, |
534 ash::Shell::HasInstance() ? IDS_CLOSE_ASH_DESKTOP : | 508 ash::Shell::HasInstance() ? IDS_CLOSE_ASH_DESKTOP : |
535 IDS_OPEN_ASH_DESKTOP); | 509 IDS_OPEN_ASH_DESKTOP); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 &enable_increment, &enable_decrement); | 759 &enable_increment, &enable_decrement); |
786 } | 760 } |
787 zoom_label_ = l10n_util::GetStringFUTF16( | 761 zoom_label_ = l10n_util::GetStringFUTF16( |
788 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 762 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
789 } | 763 } |
790 | 764 |
791 void WrenchMenuModel::OnZoomLevelChanged( | 765 void WrenchMenuModel::OnZoomLevelChanged( |
792 const content::HostZoomMap::ZoomLevelChange& change) { | 766 const content::HostZoomMap::ZoomLevelChange& change) { |
793 UpdateZoomControls(); | 767 UpdateZoomControls(); |
794 } | 768 } |
OLD | NEW |