Chromium Code Reviews| 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/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #endif // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 #include "chrome/browser/sessions/tab_restore_service.h" | 78 #include "chrome/browser/sessions/tab_restore_service.h" |
| 79 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 79 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 80 #include "chrome/browser/sync/profile_sync_service.h" | 80 #include "chrome/browser/sync/profile_sync_service.h" |
| 81 #include "chrome/browser/sync/profile_sync_service_factory.h" | 81 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 82 #include "chrome/browser/sync/sync_ui_util.h" | 82 #include "chrome/browser/sync/sync_ui_util.h" |
| 83 #include "chrome/browser/tab_contents/background_contents.h" | 83 #include "chrome/browser/tab_contents/background_contents.h" |
| 84 #include "chrome/browser/tab_contents/retargeting_details.h" | 84 #include "chrome/browser/tab_contents/retargeting_details.h" |
| 85 #include "chrome/browser/tab_contents/tab_util.h" | 85 #include "chrome/browser/tab_contents/tab_util.h" |
| 86 #include "chrome/browser/themes/theme_service.h" | 86 #include "chrome/browser/themes/theme_service.h" |
| 87 #include "chrome/browser/themes/theme_service_factory.h" | 87 #include "chrome/browser/themes/theme_service_factory.h" |
| 88 #include "chrome/browser/translate/translate_tab_helper.h" | |
| 88 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" | 89 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" |
| 89 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" | 90 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" |
| 90 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 91 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
| 91 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 92 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 92 #include "chrome/browser/ui/browser_command_controller.h" | 93 #include "chrome/browser/ui/browser_command_controller.h" |
| 93 #include "chrome/browser/ui/browser_commands.h" | 94 #include "chrome/browser/ui/browser_commands.h" |
| 94 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" | 95 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" |
| 95 #include "chrome/browser/ui/browser_dialogs.h" | 96 #include "chrome/browser/ui/browser_dialogs.h" |
| 96 #include "chrome/browser/ui/browser_finder.h" | 97 #include "chrome/browser/ui/browser_finder.h" |
| 97 #include "chrome/browser/ui/browser_instant_controller.h" | 98 #include "chrome/browser/ui/browser_instant_controller.h" |
| 98 #include "chrome/browser/ui/browser_iterator.h" | 99 #include "chrome/browser/ui/browser_iterator.h" |
| 100 #include "chrome/browser/ui/browser_language_state_observer.h" | |
| 99 #include "chrome/browser/ui/browser_list.h" | 101 #include "chrome/browser/ui/browser_list.h" |
| 100 #include "chrome/browser/ui/browser_navigator.h" | 102 #include "chrome/browser/ui/browser_navigator.h" |
| 101 #include "chrome/browser/ui/browser_tab_contents.h" | 103 #include "chrome/browser/ui/browser_tab_contents.h" |
| 102 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" | 104 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" |
| 103 #include "chrome/browser/ui/browser_tab_strip_model_delegate.h" | 105 #include "chrome/browser/ui/browser_tab_strip_model_delegate.h" |
| 104 #include "chrome/browser/ui/browser_tabstrip.h" | 106 #include "chrome/browser/ui/browser_tabstrip.h" |
| 105 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" | 107 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" |
| 106 #include "chrome/browser/ui/browser_ui_prefs.h" | 108 #include "chrome/browser/ui/browser_ui_prefs.h" |
| 107 #include "chrome/browser/ui/browser_window.h" | 109 #include "chrome/browser/ui/browser_window.h" |
| 108 #include "chrome/browser/ui/chrome_pages.h" | 110 #include "chrome/browser/ui/chrome_pages.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 content_setting_bubble_model_delegate_( | 339 content_setting_bubble_model_delegate_( |
| 338 new BrowserContentSettingBubbleModelDelegate(this)), | 340 new BrowserContentSettingBubbleModelDelegate(this)), |
| 339 toolbar_model_delegate_(new BrowserToolbarModelDelegate(this)), | 341 toolbar_model_delegate_(new BrowserToolbarModelDelegate(this)), |
| 340 tab_restore_service_delegate_(new BrowserTabRestoreServiceDelegate(this)), | 342 tab_restore_service_delegate_(new BrowserTabRestoreServiceDelegate(this)), |
| 341 synced_window_delegate_(new BrowserSyncedWindowDelegate(this)), | 343 synced_window_delegate_(new BrowserSyncedWindowDelegate(this)), |
| 342 bookmark_bar_state_(BookmarkBar::HIDDEN), | 344 bookmark_bar_state_(BookmarkBar::HIDDEN), |
| 343 command_controller_(new chrome::BrowserCommandController( | 345 command_controller_(new chrome::BrowserCommandController( |
| 344 this, g_browser_process->profile_manager())), | 346 this, g_browser_process->profile_manager())), |
| 345 window_has_shown_(false), | 347 window_has_shown_(false), |
| 346 chrome_updater_factory_(this), | 348 chrome_updater_factory_(this), |
| 347 weak_factory_(this) { | 349 weak_factory_(this), |
| 350 language_state_observer_(new BrowserLanguageStateObserver(this)) { | |
| 348 // If this causes a crash then a window is being opened using a profile type | 351 // If this causes a crash then a window is being opened using a profile type |
| 349 // that is disallowed by policy. The crash prevents the disabled window type | 352 // that is disallowed by policy. The crash prevents the disabled window type |
| 350 // from opening at all, but the path that triggered it should be fixed. | 353 // from opening at all, but the path that triggered it should be fixed. |
| 351 CHECK(IncognitoModePrefs::CanOpenBrowser(profile_)); | 354 CHECK(IncognitoModePrefs::CanOpenBrowser(profile_)); |
| 352 | 355 |
| 353 // TODO(jeremy): Move to initializer list once flag is removed. | 356 // TODO(jeremy): Move to initializer list once flag is removed. |
| 354 if (IsFastTabUnloadEnabled()) | 357 if (IsFastTabUnloadEnabled()) |
| 355 fast_unload_controller_.reset(new chrome::FastUnloadController(this)); | 358 fast_unload_controller_.reset(new chrome::FastUnloadController(this)); |
| 356 else | 359 else |
| 357 unload_controller_.reset(new chrome::UnloadController(this)); | 360 unload_controller_.reset(new chrome::UnloadController(this)); |
| (...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1752 // Browser, ZoomObserver implementation: | 1755 // Browser, ZoomObserver implementation: |
| 1753 | 1756 |
| 1754 void Browser::OnZoomChanged(content::WebContents* source, | 1757 void Browser::OnZoomChanged(content::WebContents* source, |
| 1755 bool can_show_bubble) { | 1758 bool can_show_bubble) { |
| 1756 if (source == tab_strip_model_->GetActiveWebContents()) { | 1759 if (source == tab_strip_model_->GetActiveWebContents()) { |
| 1757 // Only show the zoom bubble for zoom changes in the active window. | 1760 // Only show the zoom bubble for zoom changes in the active window. |
| 1758 window_->ZoomChangedForActiveTab(can_show_bubble && window_->IsActive()); | 1761 window_->ZoomChangedForActiveTab(can_show_bubble && window_->IsActive()); |
| 1759 } | 1762 } |
| 1760 } | 1763 } |
| 1761 | 1764 |
| 1765 /*void Browser::OnTranslateEnabledChanged(content::WebContents* source) { | |
|
sky
2013/10/22 16:09:22
?
hajimehoshi
2013/10/23 10:45:09
Sorry, done.
| |
| 1766 if (source == tab_strip_model_->GetActiveWebContents()) | |
| 1767 window_->UpdateToolbar(source); | |
| 1768 }*/ | |
| 1769 | |
| 1762 /////////////////////////////////////////////////////////////////////////////// | 1770 /////////////////////////////////////////////////////////////////////////////// |
| 1763 // Browser, ui::SelectFileDialog::Listener implementation: | 1771 // Browser, ui::SelectFileDialog::Listener implementation: |
| 1764 | 1772 |
| 1765 void Browser::FileSelected(const base::FilePath& path, int index, | 1773 void Browser::FileSelected(const base::FilePath& path, int index, |
| 1766 void* params) { | 1774 void* params) { |
| 1767 FileSelectedWithExtraInfo(ui::SelectedFileInfo(path, path), index, params); | 1775 FileSelectedWithExtraInfo(ui::SelectedFileInfo(path, path), index, params); |
| 1768 } | 1776 } |
| 1769 | 1777 |
| 1770 void Browser::FileSelectedWithExtraInfo(const ui::SelectedFileInfo& file_info, | 1778 void Browser::FileSelectedWithExtraInfo(const ui::SelectedFileInfo& file_info, |
| 1771 int index, | 1779 int index, |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2080 // WebContents... | 2088 // WebContents... |
| 2081 web_contents->SetDelegate(delegate); | 2089 web_contents->SetDelegate(delegate); |
| 2082 | 2090 |
| 2083 // ...and all the helpers. | 2091 // ...and all the helpers. |
| 2084 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2092 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
| 2085 WebContentsModalDialogManager::FromWebContents(web_contents)-> | 2093 WebContentsModalDialogManager::FromWebContents(web_contents)-> |
| 2086 SetDelegate(delegate); | 2094 SetDelegate(delegate); |
| 2087 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2095 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
| 2088 SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2096 SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
| 2089 ZoomController::FromWebContents(web_contents)->set_observer(delegate); | 2097 ZoomController::FromWebContents(web_contents)->set_observer(delegate); |
| 2098 TranslateTabHelper* translate_tab_helper = | |
| 2099 TranslateTabHelper::FromWebContents(web_contents); | |
| 2100 translate_tab_helper->language_state().set_observer( | |
| 2101 delegate->language_state_observer_.get()); | |
| 2090 } | 2102 } |
| 2091 | 2103 |
| 2092 void Browser::CloseFrame() { | 2104 void Browser::CloseFrame() { |
| 2093 window_->Close(); | 2105 window_->Close(); |
| 2094 } | 2106 } |
| 2095 | 2107 |
| 2096 void Browser::TabDetachedAtImpl(content::WebContents* contents, | 2108 void Browser::TabDetachedAtImpl(content::WebContents* contents, |
| 2097 int index, | 2109 int index, |
| 2098 DetachType type) { | 2110 DetachType type) { |
| 2099 if (type == DETACH_TYPE_DETACH) { | 2111 if (type == DETACH_TYPE_DETACH) { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2279 if (contents && !allow_js_access) { | 2291 if (contents && !allow_js_access) { |
| 2280 contents->web_contents()->GetController().LoadURL( | 2292 contents->web_contents()->GetController().LoadURL( |
| 2281 target_url, | 2293 target_url, |
| 2282 content::Referrer(), | 2294 content::Referrer(), |
| 2283 content::PAGE_TRANSITION_LINK, | 2295 content::PAGE_TRANSITION_LINK, |
| 2284 std::string()); // No extra headers. | 2296 std::string()); // No extra headers. |
| 2285 } | 2297 } |
| 2286 | 2298 |
| 2287 return contents != NULL; | 2299 return contents != NULL; |
| 2288 } | 2300 } |
| OLD | NEW |