| OLD | NEW | 
|---|
| 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 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1284 } | 1284 } | 
| 1285 | 1285 | 
| 1286 void Browser::Home(WindowOpenDisposition disposition) { | 1286 void Browser::Home(WindowOpenDisposition disposition) { | 
| 1287   UserMetrics::RecordAction(UserMetricsAction("Home"), profile_); | 1287   UserMetrics::RecordAction(UserMetricsAction("Home"), profile_); | 
| 1288   OpenURL(GetHomePage(), GURL(), disposition, PageTransition::AUTO_BOOKMARK); | 1288   OpenURL(GetHomePage(), GURL(), disposition, PageTransition::AUTO_BOOKMARK); | 
| 1289 } | 1289 } | 
| 1290 | 1290 | 
| 1291 void Browser::OpenCurrentURL() { | 1291 void Browser::OpenCurrentURL() { | 
| 1292   UserMetrics::RecordAction(UserMetricsAction("LoadURL"), profile_); | 1292   UserMetrics::RecordAction(UserMetricsAction("LoadURL"), profile_); | 
| 1293   LocationBar* location_bar = window_->GetLocationBar(); | 1293   LocationBar* location_bar = window_->GetLocationBar(); | 
|  | 1294   if(!location_bar) | 
|  | 1295     return; | 
|  | 1296 | 
| 1294   WindowOpenDisposition open_disposition = | 1297   WindowOpenDisposition open_disposition = | 
| 1295       location_bar->GetWindowOpenDisposition(); | 1298       location_bar->GetWindowOpenDisposition(); | 
| 1296   if (OpenInstant(open_disposition)) | 1299   if (OpenInstant(open_disposition)) | 
| 1297     return; | 1300     return; | 
| 1298 | 1301 | 
| 1299   GURL url(WideToUTF8(location_bar->GetInputString())); | 1302   GURL url(WideToUTF8(location_bar->GetInputString())); | 
| 1300   browser::NavigateParams params(this, url, location_bar->GetPageTransition()); | 1303   browser::NavigateParams params(this, url, location_bar->GetPageTransition()); | 
| 1301   params.disposition = open_disposition; | 1304   params.disposition = open_disposition; | 
| 1302   // Use ADD_INHERIT_OPENER so that all pages opened by the omnibox at least | 1305   // Use ADD_INHERIT_OPENER so that all pages opened by the omnibox at least | 
| 1303   // inherit the opener. In some cases the tabstrip will determine the group | 1306   // inherit the opener. In some cases the tabstrip will determine the group | 
| (...skipping 2565 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3869 | 3872 | 
| 3870   for (UpdateMap::const_iterator i = scheduled_updates_.begin(); | 3873   for (UpdateMap::const_iterator i = scheduled_updates_.begin(); | 
| 3871        i != scheduled_updates_.end(); ++i) { | 3874        i != scheduled_updates_.end(); ++i) { | 
| 3872     // Do not dereference |contents|, it may be out-of-date! | 3875     // Do not dereference |contents|, it may be out-of-date! | 
| 3873     const TabContents* contents = i->first; | 3876     const TabContents* contents = i->first; | 
| 3874     unsigned flags = i->second; | 3877     unsigned flags = i->second; | 
| 3875 | 3878 | 
| 3876     if (contents == GetSelectedTabContents()) { | 3879     if (contents == GetSelectedTabContents()) { | 
| 3877       // Updates that only matter when the tab is selected go here. | 3880       // Updates that only matter when the tab is selected go here. | 
| 3878 | 3881 | 
| 3879       if (flags & TabContents::INVALIDATE_PAGE_ACTIONS) | 3882       if (flags & TabContents::INVALIDATE_PAGE_ACTIONS) { | 
| 3880         window()->GetLocationBar()->UpdatePageActions(); | 3883         LocationBar* location_bar = window()->GetLocationBar(); | 
| 3881 | 3884         if(location_bar) | 
|  | 3885           location_bar->UpdatePageActions(); | 
|  | 3886       } | 
| 3882       // Updating the URL happens synchronously in ScheduleUIUpdate. | 3887       // Updating the URL happens synchronously in ScheduleUIUpdate. | 
| 3883       if (flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) { | 3888       if (flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) { | 
| 3884         GetStatusBubble()->SetStatus( | 3889         GetStatusBubble()->SetStatus( | 
| 3885             GetSelectedTabContentsWrapper()->GetStatusText()); | 3890             GetSelectedTabContentsWrapper()->GetStatusText()); | 
| 3886       } | 3891       } | 
| 3887 | 3892 | 
| 3888       if (flags & (TabContents::INVALIDATE_TAB | | 3893       if (flags & (TabContents::INVALIDATE_TAB | | 
| 3889                    TabContents::INVALIDATE_TITLE)) { | 3894                    TabContents::INVALIDATE_TITLE)) { | 
| 3890 // TODO(pinkerton): Disable app-mode in the model until we implement it | 3895 // TODO(pinkerton): Disable app-mode in the model until we implement it | 
| 3891 // on the Mac. Be sure to remove both ifdefs. http://crbug.com/13148 | 3896 // on the Mac. Be sure to remove both ifdefs. http://crbug.com/13148 | 
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4198   window_->Close(); | 4203   window_->Close(); | 
| 4199 } | 4204 } | 
| 4200 | 4205 | 
| 4201 void Browser::TabDetachedAtImpl(TabContentsWrapper* contents, int index, | 4206 void Browser::TabDetachedAtImpl(TabContentsWrapper* contents, int index, | 
| 4202                                 DetachType type) { | 4207                                 DetachType type) { | 
| 4203   if (type == DETACH_TYPE_DETACH) { | 4208   if (type == DETACH_TYPE_DETACH) { | 
| 4204     // Save the current location bar state, but only if the tab being detached | 4209     // Save the current location bar state, but only if the tab being detached | 
| 4205     // is the selected tab.  Because saving state can conditionally revert the | 4210     // is the selected tab.  Because saving state can conditionally revert the | 
| 4206     // location bar, saving the current tab's location bar state to a | 4211     // location bar, saving the current tab's location bar state to a | 
| 4207     // non-selected tab can corrupt both tabs. | 4212     // non-selected tab can corrupt both tabs. | 
| 4208     if (contents == GetSelectedTabContentsWrapper()) | 4213     if (contents == GetSelectedTabContentsWrapper()) { | 
| 4209       window_->GetLocationBar()->SaveStateToContents(contents->tab_contents()); | 4214       LocationBar* location_bar = window()->GetLocationBar(); | 
|  | 4215       if(location_bar) | 
|  | 4216         location_bar->SaveStateToContents(contents->tab_contents()); | 
|  | 4217     } | 
| 4210 | 4218 | 
| 4211     if (!tab_handler_->GetTabStripModel()->closing_all()) | 4219     if (!tab_handler_->GetTabStripModel()->closing_all()) | 
| 4212       SyncHistoryWithTabs(0); | 4220       SyncHistoryWithTabs(0); | 
| 4213   } | 4221   } | 
| 4214 | 4222 | 
| 4215   SetAsDelegate(contents, NULL); | 4223   SetAsDelegate(contents, NULL); | 
| 4216   RemoveScheduledUpdatesFor(contents->tab_contents()); | 4224   RemoveScheduledUpdatesFor(contents->tab_contents()); | 
| 4217 | 4225 | 
| 4218   if (find_bar_controller_.get() && | 4226   if (find_bar_controller_.get() && | 
| 4219       index == tab_handler_->GetTabStripModel()->selected_index()) { | 4227       index == tab_handler_->GetTabStripModel()->selected_index()) { | 
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4374     // The page transition below is only for the purpose of inserting the tab. | 4382     // The page transition below is only for the purpose of inserting the tab. | 
| 4375     browser->AddTab(view_source_contents, PageTransition::LINK); | 4383     browser->AddTab(view_source_contents, PageTransition::LINK); | 
| 4376   } | 4384   } | 
| 4377 | 4385 | 
| 4378   if (profile_->HasSessionService()) { | 4386   if (profile_->HasSessionService()) { | 
| 4379     SessionService* session_service = profile_->GetSessionService(); | 4387     SessionService* session_service = profile_->GetSessionService(); | 
| 4380     if (session_service) | 4388     if (session_service) | 
| 4381       session_service->TabRestored(&view_source_contents->controller(), false); | 4389       session_service->TabRestored(&view_source_contents->controller(), false); | 
| 4382   } | 4390   } | 
| 4383 } | 4391 } | 
| OLD | NEW | 
|---|