| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/browser/profiles/avatar_menu.h" | 27 #include "chrome/browser/profiles/avatar_menu.h" |
| 28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
| 29 #include "chrome/browser/profiles/profile_info_cache.h" | 29 #include "chrome/browser/profiles/profile_info_cache.h" |
| 30 #include "chrome/browser/profiles/profile_manager.h" | 30 #include "chrome/browser/profiles/profile_manager.h" |
| 31 #include "chrome/browser/search/search.h" | 31 #include "chrome/browser/search/search.h" |
| 32 #include "chrome/browser/sessions/tab_restore_service.h" | 32 #include "chrome/browser/sessions/tab_restore_service.h" |
| 33 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 33 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 34 #include "chrome/browser/speech/tts_controller.h" | 34 #include "chrome/browser/speech/tts_controller.h" |
| 35 #include "chrome/browser/themes/theme_properties.h" | 35 #include "chrome/browser/themes/theme_properties.h" |
| 36 #include "chrome/browser/themes/theme_service_factory.h" | 36 #include "chrome/browser/themes/theme_service_factory.h" |
| 37 #include "chrome/browser/translate/translate_tab_helper.h" |
| 37 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 38 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
| 38 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 39 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
| 39 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" | 40 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" |
| 40 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h" | 41 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h" |
| 41 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h" | 42 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h" |
| 42 #include "chrome/browser/ui/browser.h" | 43 #include "chrome/browser/ui/browser.h" |
| 43 #include "chrome/browser/ui/browser_command_controller.h" | 44 #include "chrome/browser/ui/browser_command_controller.h" |
| 44 #include "chrome/browser/ui/browser_commands.h" | 45 #include "chrome/browser/ui/browser_commands.h" |
| 45 #include "chrome/browser/ui/browser_dialogs.h" | 46 #include "chrome/browser/ui/browser_dialogs.h" |
| 46 #include "chrome/browser/ui/browser_finder.h" | 47 #include "chrome/browser/ui/browser_finder.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 76 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 77 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 77 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 78 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 78 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 79 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 79 #include "chrome/browser/ui/views/omnibox/omnibox_views.h" | 80 #include "chrome/browser/ui/views/omnibox/omnibox_views.h" |
| 80 #include "chrome/browser/ui/views/password_generation_bubble_view.h" | 81 #include "chrome/browser/ui/views/password_generation_bubble_view.h" |
| 81 #include "chrome/browser/ui/views/status_bubble_views.h" | 82 #include "chrome/browser/ui/views/status_bubble_views.h" |
| 82 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" | 83 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" |
| 83 #include "chrome/browser/ui/views/tabs/tab.h" | 84 #include "chrome/browser/ui/views/tabs/tab.h" |
| 84 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 85 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 85 #include "chrome/browser/ui/views/toolbar_view.h" | 86 #include "chrome/browser/ui/views/toolbar_view.h" |
| 87 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" |
| 86 #include "chrome/browser/ui/views/update_recommended_message_box.h" | 88 #include "chrome/browser/ui/views/update_recommended_message_box.h" |
| 87 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" | 89 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" |
| 88 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 90 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 89 #include "chrome/common/chrome_switches.h" | 91 #include "chrome/common/chrome_switches.h" |
| 90 #include "chrome/common/pref_names.h" | 92 #include "chrome/common/pref_names.h" |
| 91 #include "chrome/common/url_constants.h" | 93 #include "chrome/common/url_constants.h" |
| 92 #include "content/public/browser/download_manager.h" | 94 #include "content/public/browser/download_manager.h" |
| 93 #include "content/public/browser/native_web_keyboard_event.h" | 95 #include "content/public/browser/native_web_keyboard_event.h" |
| 94 #include "content/public/browser/notification_service.h" | 96 #include "content/public/browser/notification_service.h" |
| 95 #include "content/public/browser/render_view_host.h" | 97 #include "content/public/browser/render_view_host.h" |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 delegate.Pass(), | 1155 delegate.Pass(), |
| 1154 browser_->profile(), | 1156 browser_->profile(), |
| 1155 url, | 1157 url, |
| 1156 !already_bookmarked); | 1158 !already_bookmarked); |
| 1157 } | 1159 } |
| 1158 | 1160 |
| 1159 void BrowserView::ShowBookmarkPrompt() { | 1161 void BrowserView::ShowBookmarkPrompt() { |
| 1160 GetLocationBarView()->ShowBookmarkPrompt(); | 1162 GetLocationBarView()->ShowBookmarkPrompt(); |
| 1161 } | 1163 } |
| 1162 | 1164 |
| 1165 void BrowserView::ShowTranslateBubble( |
| 1166 content::WebContents* web_contents, |
| 1167 TranslateBubbleModel::ViewState view_state) { |
| 1168 if (web_contents != browser_->tab_strip_model()->GetActiveWebContents()) |
| 1169 return; |
| 1170 |
| 1171 TranslateTabHelper* translate_tab_helper = |
| 1172 TranslateTabHelper::FromWebContents(web_contents); |
| 1173 LanguageState& language_state = translate_tab_helper->language_state(); |
| 1174 language_state.SetTranslateEnabled(true); |
| 1175 |
| 1176 TranslateBubbleView::ShowBubble(GetToolbarView()->GetTranslateBubbleAnchor(), |
| 1177 web_contents, view_state, browser_.get()); |
| 1178 } |
| 1179 |
| 1163 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 1180 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
| 1164 void BrowserView::ShowOneClickSigninBubble( | 1181 void BrowserView::ShowOneClickSigninBubble( |
| 1165 OneClickSigninBubbleType type, | 1182 OneClickSigninBubbleType type, |
| 1166 const string16& email, | 1183 const string16& email, |
| 1167 const string16& error_message, | 1184 const string16& error_message, |
| 1168 const StartSyncCallback& start_sync_callback) { | 1185 const StartSyncCallback& start_sync_callback) { |
| 1169 scoped_ptr<OneClickSigninBubbleDelegate> delegate; | 1186 scoped_ptr<OneClickSigninBubbleDelegate> delegate; |
| 1170 delegate.reset(new OneClickSigninBubbleLinksDelegate(browser())); | 1187 delegate.reset(new OneClickSigninBubbleLinksDelegate(browser())); |
| 1171 | 1188 |
| 1172 views::View* anchor_view; | 1189 views::View* anchor_view; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 } | 1430 } |
| 1414 | 1431 |
| 1415 views::View* BrowserView::GetTabContentsContainerView() const { | 1432 views::View* BrowserView::GetTabContentsContainerView() const { |
| 1416 return contents_web_view_; | 1433 return contents_web_view_; |
| 1417 } | 1434 } |
| 1418 | 1435 |
| 1419 ToolbarView* BrowserView::GetToolbarView() const { | 1436 ToolbarView* BrowserView::GetToolbarView() const { |
| 1420 return toolbar_; | 1437 return toolbar_; |
| 1421 } | 1438 } |
| 1422 | 1439 |
| 1440 TranslateBubbleModel* BrowserView::GetTranslateBubbleModel() const { |
| 1441 TranslateBubbleView* view = TranslateBubbleView::GetCurrentBubble(); |
| 1442 if (!view) |
| 1443 return NULL; |
| 1444 |
| 1445 return view->model(); |
| 1446 } |
| 1447 |
| 1423 /////////////////////////////////////////////////////////////////////////////// | 1448 /////////////////////////////////////////////////////////////////////////////// |
| 1424 // BrowserView, TabStripModelObserver implementation: | 1449 // BrowserView, TabStripModelObserver implementation: |
| 1425 | 1450 |
| 1426 void BrowserView::TabDetachedAt(WebContents* contents, int index) { | 1451 void BrowserView::TabDetachedAt(WebContents* contents, int index) { |
| 1427 // We use index here rather than comparing |contents| because by this time | 1452 // We use index here rather than comparing |contents| because by this time |
| 1428 // the model has already removed |contents| from its list, so | 1453 // the model has already removed |contents| from its list, so |
| 1429 // browser_->GetActiveWebContents() will return NULL or something else. | 1454 // browser_->GetActiveWebContents() will return NULL or something else. |
| 1430 if (index == browser_->tab_strip_model()->active_index()) { | 1455 if (index == browser_->tab_strip_model()->active_index()) { |
| 1431 // We need to reset the current tab contents to NULL before it gets | 1456 // We need to reset the current tab contents to NULL before it gets |
| 1432 // freed. This is because the focus manager performs some operations | 1457 // freed. This is because the focus manager performs some operations |
| (...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2672 // The +1 in the next line creates a 1-px gap between icon and arrow tip. | 2697 // The +1 in the next line creates a 1-px gap between icon and arrow tip. |
| 2673 gfx::Point icon_bottom(0, location_icon_view->GetImageBounds().bottom() - | 2698 gfx::Point icon_bottom(0, location_icon_view->GetImageBounds().bottom() - |
| 2674 LocationBarView::kIconInternalPadding + 1); | 2699 LocationBarView::kIconInternalPadding + 1); |
| 2675 ConvertPointToTarget(location_icon_view, this, &icon_bottom); | 2700 ConvertPointToTarget(location_icon_view, this, &icon_bottom); |
| 2676 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); | 2701 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); |
| 2677 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2702 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
| 2678 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2703 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
| 2679 } | 2704 } |
| 2680 return top_arrow_height; | 2705 return top_arrow_height; |
| 2681 } | 2706 } |
| OLD | NEW |