| 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/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
| 16 #include "chrome/app/chrome_dll_resource.h" | 16 #include "chrome/app/chrome_dll_resource.h" |
| 17 #include "chrome/browser/accessibility/invert_bubble_views.h" | 17 #include "chrome/browser/accessibility/invert_bubble_views.h" |
| 18 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 18 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 19 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" |
| 20 #include "chrome/browser/bookmarks/bookmark_utils.h" | 20 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/debugger/devtools_window.h" | 22 #include "chrome/browser/debugger/devtools_window.h" |
| 23 #include "chrome/browser/extensions/extension_tab_helper.h" | 23 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 24 #include "chrome/browser/instant/instant_controller.h" | 24 #include "chrome/browser/instant/instant_controller.h" |
| 25 #include "chrome/browser/native_window_notification_source.h" | 25 #include "chrome/browser/native_window_notification_source.h" |
| 26 #include "chrome/browser/ntp_background_util.h" | 26 #include "chrome/browser/ntp_background_util.h" |
| 27 #include "chrome/browser/managed_mode.h" |
| 27 #include "chrome/browser/prefs/pref_service.h" | 28 #include "chrome/browser/prefs/pref_service.h" |
| 28 #include "chrome/browser/profiles/avatar_menu_model.h" | 29 #include "chrome/browser/profiles/avatar_menu_model.h" |
| 29 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/profiles/profile_info_cache.h" | 31 #include "chrome/browser/profiles/profile_info_cache.h" |
| 31 #include "chrome/browser/profiles/profile_manager.h" | 32 #include "chrome/browser/profiles/profile_manager.h" |
| 32 #include "chrome/browser/sessions/tab_restore_service.h" | 33 #include "chrome/browser/sessions/tab_restore_service.h" |
| 33 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 34 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 34 #include "chrome/browser/speech/extension_api/tts_extension_api.h" | 35 #include "chrome/browser/speech/extension_api/tts_extension_api.h" |
| 35 #include "chrome/browser/tabs/tab_strip_model.h" | 36 #include "chrome/browser/tabs/tab_strip_model.h" |
| 36 #include "chrome/browser/themes/theme_service.h" | 37 #include "chrome/browser/themes/theme_service.h" |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 462 |
| 462 bool BrowserView::IsGuestSession() const { | 463 bool BrowserView::IsGuestSession() const { |
| 463 return browser_->profile()->IsGuestSession(); | 464 return browser_->profile()->IsGuestSession(); |
| 464 } | 465 } |
| 465 | 466 |
| 466 bool BrowserView::ShouldShowAvatar() const { | 467 bool BrowserView::ShouldShowAvatar() const { |
| 467 if (!IsBrowserTypeNormal()) | 468 if (!IsBrowserTypeNormal()) |
| 468 return false; | 469 return false; |
| 469 if (IsOffTheRecord()) | 470 if (IsOffTheRecord()) |
| 470 return true; | 471 return true; |
| 472 if (ManagedMode::IsInManagedMode()) |
| 473 return true; |
| 471 | 474 |
| 472 ProfileInfoCache& cache = | 475 ProfileInfoCache& cache = |
| 473 g_browser_process->profile_manager()->GetProfileInfoCache(); | 476 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 474 if (cache.GetIndexOfProfileWithPath(browser_->profile()->GetPath()) == | 477 if (cache.GetIndexOfProfileWithPath(browser_->profile()->GetPath()) == |
| 475 std::string::npos) { | 478 std::string::npos) { |
| 476 return false; | 479 return false; |
| 477 } | 480 } |
| 478 | 481 |
| 479 return AvatarMenuModel::ShouldShowAvatarMenu(); | 482 return AvatarMenuModel::ShouldShowAvatarMenu(); |
| 480 } | 483 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 546 |
| 544 WebContents* BrowserView::GetSelectedWebContents() const { | 547 WebContents* BrowserView::GetSelectedWebContents() const { |
| 545 return browser_->GetSelectedWebContents(); | 548 return browser_->GetSelectedWebContents(); |
| 546 } | 549 } |
| 547 | 550 |
| 548 TabContentsWrapper* BrowserView::GetSelectedTabContentsWrapper() const { | 551 TabContentsWrapper* BrowserView::GetSelectedTabContentsWrapper() const { |
| 549 return browser_->GetSelectedTabContentsWrapper(); | 552 return browser_->GetSelectedTabContentsWrapper(); |
| 550 } | 553 } |
| 551 | 554 |
| 552 SkBitmap BrowserView::GetOTRAvatarIcon() const { | 555 SkBitmap BrowserView::GetOTRAvatarIcon() const { |
| 553 static SkBitmap* otr_avatar_ = new SkBitmap(); | 556 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 554 | 557 return rb.GetNativeImageNamed(IDR_OTR_ICON, |
| 555 if (otr_avatar_->isNull()) { | 558 ui::ResourceBundle::RTL_ENABLED).ToSkBitmap(); |
| 556 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 557 *otr_avatar_ = *rb.GetBitmapNamed(IDR_OTR_ICON); | |
| 558 } | |
| 559 return *otr_avatar_; | |
| 560 } | |
| 561 | |
| 562 SkBitmap BrowserView::GetGuestAvatarIcon() const { | |
| 563 #if defined(OS_CHROMEOS) | |
| 564 static SkBitmap* guest_avatar_ = new SkBitmap(); | |
| 565 | |
| 566 if (guest_avatar_->isNull()) { | |
| 567 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 568 *guest_avatar_ = *rb.GetBitmapNamed(IDR_GUEST_ICON); | |
| 569 } | |
| 570 return *guest_avatar_; | |
| 571 #else | |
| 572 NOTREACHED(); | |
| 573 return SkBitmap(); | |
| 574 #endif | |
| 575 } | 559 } |
| 576 | 560 |
| 577 // static | 561 // static |
| 578 void BrowserView::RegisterBrowserViewPrefs(PrefService* prefs) { | 562 void BrowserView::RegisterBrowserViewPrefs(PrefService* prefs) { |
| 579 prefs->RegisterIntegerPref(prefs::kPluginMessageResponseTimeout, | 563 prefs->RegisterIntegerPref(prefs::kPluginMessageResponseTimeout, |
| 580 kDefaultPluginMessageResponseTimeout); | 564 kDefaultPluginMessageResponseTimeout); |
| 581 prefs->RegisterIntegerPref(prefs::kHungPluginDetectFrequency, | 565 prefs->RegisterIntegerPref(prefs::kHungPluginDetectFrequency, |
| 582 kDefaultHungPluginDetectFrequency); | 566 kDefaultHungPluginDetectFrequency); |
| 583 } | 567 } |
| 584 | 568 |
| (...skipping 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2485 return; | 2469 return; |
| 2486 | 2470 |
| 2487 PasswordGenerationBubbleView* bubble = | 2471 PasswordGenerationBubbleView* bubble = |
| 2488 new PasswordGenerationBubbleView(bounds, | 2472 new PasswordGenerationBubbleView(bounds, |
| 2489 this, | 2473 this, |
| 2490 web_contents->GetRenderViewHost()); | 2474 web_contents->GetRenderViewHost()); |
| 2491 views::BubbleDelegateView::CreateBubble(bubble); | 2475 views::BubbleDelegateView::CreateBubble(bubble); |
| 2492 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 2476 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
| 2493 bubble->Show(); | 2477 bubble->Show(); |
| 2494 } | 2478 } |
| OLD | NEW |