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

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

Issue 6794035: Move dispatching and sending of the last extension specific messages out of TabContents and Rende... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <shellapi.h> 8 #include <shellapi.h>
9 #include <windows.h> 9 #include <windows.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 NavigationEntry* entry = current_tab->controller().GetLastCommittedEntry(); 1796 NavigationEntry* entry = current_tab->controller().GetLastCommittedEntry();
1797 if (!entry) 1797 if (!entry)
1798 return; 1798 return;
1799 1799
1800 // RVH's GetApplicationInfo should not be called before it returns. 1800 // RVH's GetApplicationInfo should not be called before it returns.
1801 DCHECK(pending_web_app_action_ == NONE); 1801 DCHECK(pending_web_app_action_ == NONE);
1802 pending_web_app_action_ = CREATE_SHORTCUT; 1802 pending_web_app_action_ = CREATE_SHORTCUT;
1803 1803
1804 // Start fetching web app info for CreateApplicationShortcut dialog and show 1804 // Start fetching web app info for CreateApplicationShortcut dialog and show
1805 // the dialog when the data is available in OnDidGetApplicationInfo. 1805 // the dialog when the data is available in OnDidGetApplicationInfo.
1806 current_tab->render_view_host()->GetApplicationInfo(entry->page_id()); 1806 current_tab->extension_tab_helper()->GetApplicationInfo(entry->page_id());
1807 #else 1807 #else
1808 NOTIMPLEMENTED(); 1808 NOTIMPLEMENTED();
1809 #endif 1809 #endif
1810 } 1810 }
1811 1811
1812 void Browser::ToggleDevToolsWindow(DevToolsToggleAction action) { 1812 void Browser::ToggleDevToolsWindow(DevToolsToggleAction action) {
1813 std::string uma_string; 1813 std::string uma_string;
1814 switch (action) { 1814 switch (action) {
1815 case DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE: 1815 case DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE:
1816 uma_string = "DevTools_ToggleConsole"; 1816 uma_string = "DevTools_ToggleConsole";
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2928 } 2928 }
2929 2929
2930 if (!source->is_loading() && 2930 if (!source->is_loading() &&
2931 pending_web_app_action_ == UPDATE_SHORTCUT) { 2931 pending_web_app_action_ == UPDATE_SHORTCUT) {
2932 // Schedule a shortcut update when web application info is available if 2932 // Schedule a shortcut update when web application info is available if
2933 // last committed entry is not NULL. Last committed entry could be NULL 2933 // last committed entry is not NULL. Last committed entry could be NULL
2934 // when an interstitial page is injected (e.g. bad https certificate, 2934 // when an interstitial page is injected (e.g. bad https certificate,
2935 // malware site etc). When this happens, we abort the shortcut update. 2935 // malware site etc). When this happens, we abort the shortcut update.
2936 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); 2936 NavigationEntry* entry = source->controller().GetLastCommittedEntry();
2937 if (entry) { 2937 if (entry) {
2938 source->render_view_host()->GetApplicationInfo(entry->page_id()); 2938 TabContentsWrapper::GetCurrentWrapperForContents(source)->
2939 extension_tab_helper()->GetApplicationInfo(entry->page_id());
2939 } else { 2940 } else {
2940 pending_web_app_action_ = NONE; 2941 pending_web_app_action_ = NONE;
2941 } 2942 }
2942 } 2943 }
2943 } 2944 }
2944 } 2945 }
2945 2946
2946 void Browser::CloseContents(TabContents* source) { 2947 void Browser::CloseContents(TabContents* source) {
2947 if (is_attempting_to_close_browser_) { 2948 if (is_attempting_to_close_browser_) {
2948 // If we're trying to close the browser, just clear the state related to 2949 // If we're trying to close the browser, just clear the state related to
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
3229 window()->ShowCollectedCookiesDialog(tab_contents); 3230 window()->ShowCollectedCookiesDialog(tab_contents);
3230 } 3231 }
3231 3232
3232 bool Browser::ShouldAddNavigationToHistory( 3233 bool Browser::ShouldAddNavigationToHistory(
3233 const history::HistoryAddPageArgs& add_page_args, 3234 const history::HistoryAddPageArgs& add_page_args,
3234 NavigationType::Type navigation_type) { 3235 NavigationType::Type navigation_type) {
3235 // Don't update history if running as app. 3236 // Don't update history if running as app.
3236 return !IsApplication(); 3237 return !IsApplication();
3237 } 3238 }
3238 3239
3239 void Browser::OnDidGetApplicationInfo(TabContents* tab_contents, 3240 void Browser::ContentRestrictionsChanged(TabContents* source) {
3241 UpdateCommandsForContentRestrictionState();
3242 }
3243
3244 void Browser::WorkerCrashed() {
3245 TabContents* tab_contents = GetSelectedTabContents();
3246 if (!tab_contents)
3247 return;
3248 tab_contents->AddInfoBar(new SimpleAlertInfoBarDelegate(tab_contents, NULL,
3249 l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), true));
3250 }
3251
3252 ///////////////////////////////////////////////////////////////////////////////
3253 // Browser, TabContentsWrapperDelegate implementation:
3254
3255 void Browser::URLStarredChanged(TabContentsWrapper* source, bool starred) {
3256 if (source == GetSelectedTabContentsWrapper())
3257 window_->SetStarredState(starred);
3258 }
3259
3260 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source,
3240 int32 page_id) { 3261 int32 page_id) {
3241 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); 3262 if (GetSelectedTabContentsWrapper() != source)
3242 if (current_tab->tab_contents() != tab_contents)
3243 return; 3263 return;
3244 3264
3245 NavigationEntry* entry = current_tab->controller().GetLastCommittedEntry(); 3265 NavigationEntry* entry = source->controller().GetLastCommittedEntry();
3246 if (!entry || (entry->page_id() != page_id)) 3266 if (!entry || (entry->page_id() != page_id))
3247 return; 3267 return;
3248 3268
3249 switch (pending_web_app_action_) { 3269 switch (pending_web_app_action_) {
3250 case CREATE_SHORTCUT: { 3270 case CREATE_SHORTCUT: {
3251 window()->ShowCreateWebAppShortcutsDialog(current_tab); 3271 window()->ShowCreateWebAppShortcutsDialog(source);
3252 break; 3272 break;
3253 } 3273 }
3254 case UPDATE_SHORTCUT: { 3274 case UPDATE_SHORTCUT: {
3255 web_app::UpdateShortcutForTabContents(current_tab); 3275 web_app::UpdateShortcutForTabContents(source);
3256 break; 3276 break;
3257 } 3277 }
3258 default: 3278 default:
3259 NOTREACHED(); 3279 NOTREACHED();
3260 break; 3280 break;
3261 } 3281 }
3262 3282
3263 pending_web_app_action_ = NONE; 3283 pending_web_app_action_ = NONE;
3264 } 3284 }
3265 3285
3266 void Browser::OnInstallApplication(TabContents* source, 3286 void Browser::OnInstallApplication(TabContentsWrapper* source,
3267 const WebApplicationInfo& web_app) { 3287 const WebApplicationInfo& web_app) {
3268 ExtensionService* extensions_service = profile()->GetExtensionService(); 3288 ExtensionService* extensions_service = profile()->GetExtensionService();
3269 if (!extensions_service) 3289 if (!extensions_service)
3270 return; 3290 return;
3271 3291
3272 scoped_refptr<CrxInstaller> installer( 3292 scoped_refptr<CrxInstaller> installer(
3273 new CrxInstaller(extensions_service, 3293 new CrxInstaller(extensions_service,
3274 extensions_service->show_extensions_prompts() ? 3294 extensions_service->show_extensions_prompts() ?
3275 new ExtensionInstallUI(profile()) : NULL)); 3295 new ExtensionInstallUI(profile()) : NULL));
3276 installer->InstallWebApp(web_app); 3296 installer->InstallWebApp(web_app);
3277 } 3297 }
3278 3298
3279 void Browser::ContentRestrictionsChanged(TabContents* source) {
3280 UpdateCommandsForContentRestrictionState();
3281 }
3282
3283 void Browser::WorkerCrashed() {
3284 TabContents* tab_contents = GetSelectedTabContents();
3285 if (!tab_contents)
3286 return;
3287 tab_contents->AddInfoBar(new SimpleAlertInfoBarDelegate(tab_contents, NULL,
3288 l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), true));
3289 }
3290
3291 ///////////////////////////////////////////////////////////////////////////////
3292 // Browser, TabContentsWrapperDelegate implementation:
3293
3294 void Browser::URLStarredChanged(TabContentsWrapper* source, bool starred) {
3295 if (source == GetSelectedTabContentsWrapper())
3296 window_->SetStarredState(starred);
3297 }
3298
3299 /////////////////////////////////////////////////////////////////////////////// 3299 ///////////////////////////////////////////////////////////////////////////////
3300 // Browser, SearchEngineTabHelperDelegate implementation: 3300 // Browser, SearchEngineTabHelperDelegate implementation:
3301 3301
3302 void Browser::ConfirmSetDefaultSearchProvider( 3302 void Browser::ConfirmSetDefaultSearchProvider(
3303 TabContents* tab_contents, 3303 TabContents* tab_contents,
3304 TemplateURL* template_url, 3304 TemplateURL* template_url,
3305 TemplateURLModel* template_url_model) { 3305 TemplateURLModel* template_url_model) {
3306 window()->ConfirmSetDefaultSearchProvider(tab_contents, template_url, 3306 window()->ConfirmSetDefaultSearchProvider(tab_contents, template_url,
3307 template_url_model); 3307 template_url_model);
3308 } 3308 }
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
4414 // The page transition below is only for the purpose of inserting the tab. 4414 // The page transition below is only for the purpose of inserting the tab.
4415 browser->AddTab(view_source_contents, PageTransition::LINK); 4415 browser->AddTab(view_source_contents, PageTransition::LINK);
4416 } 4416 }
4417 4417
4418 if (profile_->HasSessionService()) { 4418 if (profile_->HasSessionService()) {
4419 SessionService* session_service = profile_->GetSessionService(); 4419 SessionService* session_service = profile_->GetSessionService();
4420 if (session_service) 4420 if (session_service)
4421 session_service->TabRestored(&view_source_contents->controller(), false); 4421 session_service->TabRestored(&view_source_contents->controller(), false);
4422 } 4422 }
4423 } 4423 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698