Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 301733006: Zoom Extension API (chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix javascript test function signature. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" 43 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
44 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h" 44 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h"
45 #include "chrome/browser/custom_handlers/register_protocol_handler_permission_re quest.h" 45 #include "chrome/browser/custom_handlers/register_protocol_handler_permission_re quest.h"
46 #include "chrome/browser/defaults.h" 46 #include "chrome/browser/defaults.h"
47 #include "chrome/browser/devtools/devtools_toggle_action.h" 47 #include "chrome/browser/devtools/devtools_toggle_action.h"
48 #include "chrome/browser/devtools/devtools_window.h" 48 #include "chrome/browser/devtools/devtools_window.h"
49 #include "chrome/browser/download/download_item_model.h" 49 #include "chrome/browser/download/download_item_model.h"
50 #include "chrome/browser/download/download_service.h" 50 #include "chrome/browser/download/download_service.h"
51 #include "chrome/browser/download/download_service_factory.h" 51 #include "chrome/browser/download/download_service_factory.h"
52 #include "chrome/browser/download/download_shelf.h" 52 #include "chrome/browser/download/download_shelf.h"
53 #include "chrome/browser/extensions/api/tabs/tabs_event_router.h"
54 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h"
53 #include "chrome/browser/extensions/browser_extension_window_controller.h" 55 #include "chrome/browser/extensions/browser_extension_window_controller.h"
54 #include "chrome/browser/extensions/extension_service.h" 56 #include "chrome/browser/extensions/extension_service.h"
55 #include "chrome/browser/extensions/tab_helper.h" 57 #include "chrome/browser/extensions/tab_helper.h"
56 #include "chrome/browser/favicon/favicon_tab_helper.h" 58 #include "chrome/browser/favicon/favicon_tab_helper.h"
57 #include "chrome/browser/file_select_helper.h" 59 #include "chrome/browser/file_select_helper.h"
58 #include "chrome/browser/first_run/first_run.h" 60 #include "chrome/browser/first_run/first_run.h"
59 #include "chrome/browser/history/top_sites.h" 61 #include "chrome/browser/history/top_sites.h"
60 #include "chrome/browser/infobars/infobar_service.h" 62 #include "chrome/browser/infobars/infobar_service.h"
61 #include "chrome/browser/infobars/simple_alert_infobar_delegate.h" 63 #include "chrome/browser/infobars/simple_alert_infobar_delegate.h"
62 #include "chrome/browser/lifetime/application_lifetime.h" 64 #include "chrome/browser/lifetime/application_lifetime.h"
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 WebContents* Browser::OpenURL(const OpenURLParams& params) { 884 WebContents* Browser::OpenURL(const OpenURLParams& params) {
883 return OpenURLFromTab(NULL, params); 885 return OpenURLFromTab(NULL, params);
884 } 886 }
885 887
886 /////////////////////////////////////////////////////////////////////////////// 888 ///////////////////////////////////////////////////////////////////////////////
887 // Browser, TabStripModelObserver implementation: 889 // Browser, TabStripModelObserver implementation:
888 890
889 void Browser::TabInsertedAt(WebContents* contents, 891 void Browser::TabInsertedAt(WebContents* contents,
890 int index, 892 int index,
891 bool foreground) { 893 bool foreground) {
892 SetAsDelegate(contents, this); 894 SetAsDelegate(contents, true);
893 SessionTabHelper* session_tab_helper = 895 SessionTabHelper* session_tab_helper =
894 SessionTabHelper::FromWebContents(contents); 896 SessionTabHelper::FromWebContents(contents);
895 session_tab_helper->SetWindowID(session_id()); 897 session_tab_helper->SetWindowID(session_id());
896 898
897 content::NotificationService::current()->Notify( 899 content::NotificationService::current()->Notify(
898 chrome::NOTIFICATION_TAB_PARENTED, 900 chrome::NOTIFICATION_TAB_PARENTED,
899 content::Source<content::WebContents>(contents), 901 content::Source<content::WebContents>(contents),
900 content::NotificationService::NoDetails()); 902 content::NotificationService::NoDetails());
901 903
902 SyncHistoryWithTabs(index); 904 SyncHistoryWithTabs(index);
(...skipping 22 matching lines...) Expand all
925 SessionService* session_service = 927 SessionService* session_service =
926 SessionServiceFactory::GetForProfile(profile_); 928 SessionServiceFactory::GetForProfile(profile_);
927 if (session_service) 929 if (session_service)
928 session_service->TabClosing(contents); 930 session_service->TabClosing(contents);
929 content::NotificationService::current()->Notify( 931 content::NotificationService::current()->Notify(
930 chrome::NOTIFICATION_TAB_CLOSING, 932 chrome::NOTIFICATION_TAB_CLOSING,
931 content::Source<NavigationController>(&contents->GetController()), 933 content::Source<NavigationController>(&contents->GetController()),
932 content::NotificationService::NoDetails()); 934 content::NotificationService::NoDetails());
933 935
934 // Sever the WebContents' connection back to us. 936 // Sever the WebContents' connection back to us.
935 SetAsDelegate(contents, NULL); 937 SetAsDelegate(contents, false);
936 } 938 }
937 939
938 void Browser::TabDetachedAt(WebContents* contents, int index) { 940 void Browser::TabDetachedAt(WebContents* contents, int index) {
939 // TabDetachedAt is called before TabStripModel has updated the 941 // TabDetachedAt is called before TabStripModel has updated the
940 // active index. 942 // active index.
941 int old_active_index = tab_strip_model_->active_index(); 943 int old_active_index = tab_strip_model_->active_index();
942 if (index < old_active_index && !tab_strip_model_->closing_all()) { 944 if (index < old_active_index && !tab_strip_model_->closing_all()) {
943 SessionService* session_service = 945 SessionService* session_service =
944 SessionServiceFactory::GetForProfileIfExisting(profile_); 946 SessionServiceFactory::GetForProfileIfExisting(profile_);
945 if (session_service) 947 if (session_service)
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1833 1835
1834 void Browser::URLStarredChanged(content::WebContents* web_contents, 1836 void Browser::URLStarredChanged(content::WebContents* web_contents,
1835 bool starred) { 1837 bool starred) {
1836 if (web_contents == tab_strip_model_->GetActiveWebContents()) 1838 if (web_contents == tab_strip_model_->GetActiveWebContents())
1837 window_->SetStarredState(starred); 1839 window_->SetStarredState(starred);
1838 } 1840 }
1839 1841
1840 /////////////////////////////////////////////////////////////////////////////// 1842 ///////////////////////////////////////////////////////////////////////////////
1841 // Browser, ZoomObserver implementation: 1843 // Browser, ZoomObserver implementation:
1842 1844
1843 void Browser::OnZoomChanged(content::WebContents* source, 1845 void Browser::OnZoomChanged(const ZoomController::ZoomChangedEventData& data) {
1844 bool can_show_bubble) { 1846 if (data.web_contents == tab_strip_model_->GetActiveWebContents()) {
1845 if (source == tab_strip_model_->GetActiveWebContents()) {
1846 // Only show the zoom bubble for zoom changes in the active window. 1847 // Only show the zoom bubble for zoom changes in the active window.
1847 window_->ZoomChangedForActiveTab(can_show_bubble && window_->IsActive() && 1848 window_->ZoomChangedForActiveTab(data.can_show_bubble &&
1848 !is_devtools()); 1849 window_->IsActive() && !is_devtools());
1849 } 1850 }
1850 } 1851 }
1851 1852
1852 /////////////////////////////////////////////////////////////////////////////// 1853 ///////////////////////////////////////////////////////////////////////////////
1853 // Browser, ui::SelectFileDialog::Listener implementation: 1854 // Browser, ui::SelectFileDialog::Listener implementation:
1854 1855
1855 void Browser::FileSelected(const base::FilePath& path, int index, 1856 void Browser::FileSelected(const base::FilePath& path, int index,
1856 void* params) { 1857 void* params) {
1857 FileSelectedWithExtraInfo(ui::SelectedFileInfo(path, path), index, params); 1858 FileSelectedWithExtraInfo(ui::SelectedFileInfo(path, path), index, params);
1858 } 1859 }
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 weak_factory_.GetWeakPtr())); 2175 weak_factory_.GetWeakPtr()));
2175 2176
2176 // Return false so the browser does not close. We'll close if the user 2177 // Return false so the browser does not close. We'll close if the user
2177 // confirms in the dialog. 2178 // confirms in the dialog.
2178 return false; 2179 return false;
2179 } 2180 }
2180 2181
2181 /////////////////////////////////////////////////////////////////////////////// 2182 ///////////////////////////////////////////////////////////////////////////////
2182 // Browser, Assorted utility functions (private): 2183 // Browser, Assorted utility functions (private):
2183 2184
2184 void Browser::SetAsDelegate(WebContents* web_contents, Browser* delegate) { 2185 void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) {
2186 Browser* delegate = set_delegate ? this : NULL;
2185 // WebContents... 2187 // WebContents...
2186 web_contents->SetDelegate(delegate); 2188 web_contents->SetDelegate(delegate);
2187 2189
2188 // ...and all the helpers. 2190 // ...and all the helpers.
2189 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); 2191 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate);
2190 WebContentsModalDialogManager::FromWebContents(web_contents)-> 2192 WebContentsModalDialogManager::FromWebContents(web_contents)->
2191 SetDelegate(delegate); 2193 SetDelegate(delegate);
2192 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); 2194 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate);
2193 SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate); 2195 SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate);
2194 SearchTabHelper::FromWebContents(web_contents)->set_delegate(delegate); 2196 SearchTabHelper::FromWebContents(web_contents)->set_delegate(delegate);
2195 ZoomController::FromWebContents(web_contents)->set_observer(delegate); 2197 if (delegate)
2198 ZoomController::FromWebContents(web_contents)->AddObserver(this);
2199 else
2200 ZoomController::FromWebContents(web_contents)->RemoveObserver(this);
2196 ChromeTranslateClient* chrome_translate_client = 2201 ChromeTranslateClient* chrome_translate_client =
2197 ChromeTranslateClient::FromWebContents(web_contents); 2202 ChromeTranslateClient::FromWebContents(web_contents);
2198 chrome_translate_client->translate_driver().set_observer( 2203 chrome_translate_client->translate_driver().set_observer(
2199 delegate ? delegate->translate_driver_observer_.get() : NULL); 2204 delegate ? delegate->translate_driver_observer_.get() : NULL);
2200 } 2205 }
2201 2206
2202 void Browser::CloseFrame() { 2207 void Browser::CloseFrame() {
2203 window_->Close(); 2208 window_->Close();
2204 } 2209 }
2205 2210
2206 void Browser::TabDetachedAtImpl(content::WebContents* contents, 2211 void Browser::TabDetachedAtImpl(content::WebContents* contents,
2207 int index, 2212 int index,
2208 DetachType type) { 2213 DetachType type) {
2209 if (type == DETACH_TYPE_DETACH) { 2214 if (type == DETACH_TYPE_DETACH) {
2210 // Save the current location bar state, but only if the tab being detached 2215 // Save the current location bar state, but only if the tab being detached
2211 // is the selected tab. Because saving state can conditionally revert the 2216 // is the selected tab. Because saving state can conditionally revert the
2212 // location bar, saving the current tab's location bar state to a 2217 // location bar, saving the current tab's location bar state to a
2213 // non-selected tab can corrupt both tabs. 2218 // non-selected tab can corrupt both tabs.
2214 if (contents == tab_strip_model_->GetActiveWebContents()) { 2219 if (contents == tab_strip_model_->GetActiveWebContents()) {
2215 LocationBar* location_bar = window()->GetLocationBar(); 2220 LocationBar* location_bar = window()->GetLocationBar();
2216 if (location_bar) 2221 if (location_bar)
2217 location_bar->SaveStateToContents(contents); 2222 location_bar->SaveStateToContents(contents);
2218 } 2223 }
2219 2224
2220 if (!tab_strip_model_->closing_all()) 2225 if (!tab_strip_model_->closing_all())
2221 SyncHistoryWithTabs(0); 2226 SyncHistoryWithTabs(0);
2222 } 2227 }
2223 2228
2224 SetAsDelegate(contents, NULL); 2229 SetAsDelegate(contents, false);
2225 RemoveScheduledUpdatesFor(contents); 2230 RemoveScheduledUpdatesFor(contents);
2226 2231
2227 if (find_bar_controller_.get() && index == tab_strip_model_->active_index()) { 2232 if (find_bar_controller_.get() && index == tab_strip_model_->active_index()) {
2228 find_bar_controller_->ChangeWebContents(NULL); 2233 find_bar_controller_->ChangeWebContents(NULL);
2229 } 2234 }
2230 2235
2231 // Stop observing search model changes for this tab. 2236 // Stop observing search model changes for this tab.
2232 search_delegate_->OnTabDetached(contents); 2237 search_delegate_->OnTabDetached(contents);
2233 2238
2234 for (size_t i = 0; i < interstitial_observers_.size(); i++) { 2239 for (size_t i = 0; i < interstitial_observers_.size(); i++) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
2417 if (contents && !allow_js_access) { 2422 if (contents && !allow_js_access) {
2418 contents->web_contents()->GetController().LoadURL( 2423 contents->web_contents()->GetController().LoadURL(
2419 target_url, 2424 target_url,
2420 content::Referrer(), 2425 content::Referrer(),
2421 content::PAGE_TRANSITION_LINK, 2426 content::PAGE_TRANSITION_LINK,
2422 std::string()); // No extra headers. 2427 std::string()); // No extra headers.
2423 } 2428 }
2424 2429
2425 return contents != NULL; 2430 return contents != NULL;
2426 } 2431 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698