| 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 324 } |
| 325 | 325 |
| 326 // static | 326 // static |
| 327 Browser* Browser::Create(Profile* profile) { | 327 Browser* Browser::Create(Profile* profile) { |
| 328 Browser* browser = new Browser(TYPE_NORMAL, profile); | 328 Browser* browser = new Browser(TYPE_NORMAL, profile); |
| 329 browser->CreateBrowserWindow(); | 329 browser->CreateBrowserWindow(); |
| 330 return browser; | 330 return browser; |
| 331 } | 331 } |
| 332 | 332 |
| 333 // static | 333 // static |
| 334 TabRestoreServiceDelegate* TabRestoreServiceDelegate::Create(Profile* profile) { |
| 335 return Browser::Create(profile); |
| 336 } |
| 337 |
| 338 // static |
| 334 Browser* Browser::CreateForPopup(Type type, | 339 Browser* Browser::CreateForPopup(Type type, |
| 335 Profile* profile, | 340 Profile* profile, |
| 336 TabContents* new_contents, | 341 TabContents* new_contents, |
| 337 const gfx::Rect& initial_bounds) { | 342 const gfx::Rect& initial_bounds) { |
| 338 DCHECK(type & TYPE_POPUP); | 343 DCHECK(type & TYPE_POPUP); |
| 339 Browser* browser = new Browser(type, profile); | 344 Browser* browser = new Browser(type, profile); |
| 340 browser->set_override_bounds(initial_bounds); | 345 browser->set_override_bounds(initial_bounds); |
| 341 browser->CreateBrowserWindow(); | 346 browser->CreateBrowserWindow(); |
| 342 TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents); | 347 TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents); |
| 343 browser->tabstrip_model()->AppendTabContents(wrapper, true); | 348 browser->tabstrip_model()->AppendTabContents(wrapper, true); |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 TabContentsWrapper* wrapper = tabstrip_model()->GetTabContentsAt(index); | 964 TabContentsWrapper* wrapper = tabstrip_model()->GetTabContentsAt(index); |
| 960 if (wrapper) | 965 if (wrapper) |
| 961 return wrapper->tab_contents(); | 966 return wrapper->tab_contents(); |
| 962 return NULL; | 967 return NULL; |
| 963 } | 968 } |
| 964 | 969 |
| 965 void Browser::SelectTabContentsAt(int index, bool user_gesture) { | 970 void Browser::SelectTabContentsAt(int index, bool user_gesture) { |
| 966 tab_handler_->GetTabStripModel()->SelectTabContentsAt(index, user_gesture); | 971 tab_handler_->GetTabStripModel()->SelectTabContentsAt(index, user_gesture); |
| 967 } | 972 } |
| 968 | 973 |
| 974 bool Browser::IsTabPinned(int index) const { |
| 975 return tabstrip_model()->IsTabPinned(index); |
| 976 } |
| 977 |
| 969 void Browser::CloseAllTabs() { | 978 void Browser::CloseAllTabs() { |
| 970 tab_handler_->GetTabStripModel()->CloseAllTabs(); | 979 tab_handler_->GetTabStripModel()->CloseAllTabs(); |
| 971 } | 980 } |
| 972 | 981 |
| 973 //////////////////////////////////////////////////////////////////////////////// | 982 //////////////////////////////////////////////////////////////////////////////// |
| 974 // Browser, Tab adding/showing functions: | 983 // Browser, Tab adding/showing functions: |
| 975 | 984 |
| 976 bool Browser::IsTabStripEditable() const { | 985 bool Browser::IsTabStripEditable() const { |
| 977 return window()->IsTabStripEditable(); | 986 return window()->IsTabStripEditable(); |
| 978 } | 987 } |
| (...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2088 if (index != TabStripModel::kNoTab) { | 2097 if (index != TabStripModel::kNoTab) { |
| 2089 if (index_result) | 2098 if (index_result) |
| 2090 *index_result = index; | 2099 *index_result = index; |
| 2091 return *it; | 2100 return *it; |
| 2092 } | 2101 } |
| 2093 } | 2102 } |
| 2094 | 2103 |
| 2095 return NULL; | 2104 return NULL; |
| 2096 } | 2105 } |
| 2097 | 2106 |
| 2107 // static |
| 2108 TabRestoreServiceDelegate* TabRestoreServiceDelegate::GetBrowserForController( |
| 2109 const NavigationController* controller, int* index) { |
| 2110 return Browser::GetBrowserForController(controller, index); |
| 2111 } |
| 2112 |
| 2098 void Browser::ExecuteCommandWithDisposition( | 2113 void Browser::ExecuteCommandWithDisposition( |
| 2099 int id, WindowOpenDisposition disposition) { | 2114 int id, WindowOpenDisposition disposition) { |
| 2100 // No commands are enabled if there is not yet any selected tab. | 2115 // No commands are enabled if there is not yet any selected tab. |
| 2101 // TODO(pkasting): It seems like we should not need this, because either | 2116 // TODO(pkasting): It seems like we should not need this, because either |
| 2102 // most/all commands should not have been enabled yet anyway or the ones that | 2117 // most/all commands should not have been enabled yet anyway or the ones that |
| 2103 // are enabled should be global, or safe themselves against having no selected | 2118 // are enabled should be global, or safe themselves against having no selected |
| 2104 // tab. However, Ben says he tried removing this before and got lots of | 2119 // tab. However, Ben says he tried removing this before and got lots of |
| 2105 // crashes, e.g. from Windows sending WM_COMMANDs at random times during | 2120 // crashes, e.g. from Windows sending WM_COMMANDs at random times during |
| 2106 // window construction. This probably could use closer examination someday. | 2121 // window construction. This probably could use closer examination someday. |
| 2107 if (!GetSelectedTabContentsWrapper()) | 2122 if (!GetSelectedTabContentsWrapper()) |
| (...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4386 // The page transition below is only for the purpose of inserting the tab. | 4401 // The page transition below is only for the purpose of inserting the tab. |
| 4387 browser->AddTab(view_source_contents, PageTransition::LINK); | 4402 browser->AddTab(view_source_contents, PageTransition::LINK); |
| 4388 } | 4403 } |
| 4389 | 4404 |
| 4390 if (profile_->HasSessionService()) { | 4405 if (profile_->HasSessionService()) { |
| 4391 SessionService* session_service = profile_->GetSessionService(); | 4406 SessionService* session_service = profile_->GetSessionService(); |
| 4392 if (session_service) | 4407 if (session_service) |
| 4393 session_service->TabRestored(&view_source_contents->controller(), false); | 4408 session_service->TabRestored(&view_source_contents->controller(), false); |
| 4394 } | 4409 } |
| 4395 } | 4410 } |
| OLD | NEW |