| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/browser.h" | 5 #include "chrome/browser/browser.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/idle_timer.h" | 8 #include "base/idle_timer.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 259 |
| 260 // static | 260 // static |
| 261 Browser* Browser::CreateForPopup(Profile* profile) { | 261 Browser* Browser::CreateForPopup(Profile* profile) { |
| 262 Browser* browser = new Browser(TYPE_POPUP, profile); | 262 Browser* browser = new Browser(TYPE_POPUP, profile); |
| 263 browser->CreateBrowserWindow(); | 263 browser->CreateBrowserWindow(); |
| 264 return browser; | 264 return browser; |
| 265 } | 265 } |
| 266 | 266 |
| 267 // static | 267 // static |
| 268 Browser* Browser::CreateForApp(const std::wstring& app_name, | 268 Browser* Browser::CreateForApp(const std::wstring& app_name, |
| 269 Profile* profile) { | 269 Profile* profile, bool is_popup) { |
| 270 Browser* browser = new Browser(TYPE_APP, profile); | 270 Browser* browser = new Browser(is_popup? TYPE_APP_POPUP : TYPE_APP, profile); |
| 271 browser->app_name_ = app_name; | 271 browser->app_name_ = app_name; |
| 272 browser->CreateBrowserWindow(); | 272 browser->CreateBrowserWindow(); |
| 273 return browser; | 273 return browser; |
| 274 } | 274 } |
| 275 | 275 |
| 276 void Browser::CreateBrowserWindow() { | 276 void Browser::CreateBrowserWindow() { |
| 277 DCHECK(!window_); | 277 DCHECK(!window_); |
| 278 window_ = BrowserWindow::CreateBrowserWindow(this); | 278 window_ = BrowserWindow::CreateBrowserWindow(this); |
| 279 | 279 |
| 280 // Show the First Run information bubble if we've been told to. | 280 // Show the First Run information bubble if we've been told to. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 310 // TODO(eroman): should we have referrer here? | 310 // TODO(eroman): should we have referrer here? |
| 311 browser->AddTabWithURL(url, GURL(), PageTransition::LINK, true, NULL); | 311 browser->AddTabWithURL(url, GURL(), PageTransition::LINK, true, NULL); |
| 312 browser->window()->Show(); | 312 browser->window()->Show(); |
| 313 } | 313 } |
| 314 | 314 |
| 315 // static | 315 // static |
| 316 void Browser::OpenApplicationWindow(Profile* profile, const GURL& url) { | 316 void Browser::OpenApplicationWindow(Profile* profile, const GURL& url) { |
| 317 std::wstring app_name = ComputeApplicationNameFromURL(url); | 317 std::wstring app_name = ComputeApplicationNameFromURL(url); |
| 318 RegisterAppPrefs(app_name); | 318 RegisterAppPrefs(app_name); |
| 319 | 319 |
| 320 Browser* browser = Browser::CreateForApp(app_name, profile); | 320 Browser* browser = Browser::CreateForApp(app_name, profile, false); |
| 321 browser->AddTabWithURL(url, GURL(), PageTransition::START_PAGE, true, NULL); | 321 browser->AddTabWithURL(url, GURL(), PageTransition::START_PAGE, true, NULL); |
| 322 browser->window()->Show(); | 322 browser->window()->Show(); |
| 323 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial | 323 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial |
| 324 // focus explicitly. | 324 // focus explicitly. |
| 325 browser->GetSelectedTabContents()->SetInitialFocus(); | 325 browser->GetSelectedTabContents()->SetInitialFocus(); |
| 326 } | 326 } |
| 327 | 327 |
| 328 /////////////////////////////////////////////////////////////////////////////// | 328 /////////////////////////////////////////////////////////////////////////////// |
| 329 // Browser, State Storage and Retrieval for UI: | 329 // Browser, State Storage and Retrieval for UI: |
| 330 | 330 |
| 331 std::wstring Browser::GetWindowPlacementKey() const { | 331 std::wstring Browser::GetWindowPlacementKey() const { |
| 332 std::wstring name(prefs::kBrowserWindowPlacement); | 332 std::wstring name(prefs::kBrowserWindowPlacement); |
| 333 if (!app_name_.empty()) { | 333 if (!app_name_.empty()) { |
| 334 name.append(L"_"); | 334 name.append(L"_"); |
| 335 name.append(app_name_); | 335 name.append(app_name_); |
| 336 } | 336 } |
| 337 return name; | 337 return name; |
| 338 } | 338 } |
| 339 | 339 |
| 340 bool Browser::ShouldSaveWindowPlacement() const { | 340 bool Browser::ShouldSaveWindowPlacement() const { |
| 341 // We don't save window position for popups. | 341 // We don't save window position for popups. |
| 342 return type() != TYPE_POPUP; | 342 return (type() & TYPE_POPUP) == 0; |
| 343 } | 343 } |
| 344 | 344 |
| 345 void Browser::SaveWindowPlacement(const gfx::Rect& bounds, bool maximized) { | 345 void Browser::SaveWindowPlacement(const gfx::Rect& bounds, bool maximized) { |
| 346 // Save to the session storage service, used when reloading a past session. | 346 // Save to the session storage service, used when reloading a past session. |
| 347 // Note that we don't want to be the ones who cause lazy initialization of | 347 // Note that we don't want to be the ones who cause lazy initialization of |
| 348 // the session service. This function gets called during initial window | 348 // the session service. This function gets called during initial window |
| 349 // showing, and we don't want to bring in the session service this early. | 349 // showing, and we don't want to bring in the session service this early. |
| 350 if (profile()->HasSessionService()) { | 350 if (profile()->HasSessionService()) { |
| 351 SessionService* session_service = profile()->GetSessionService(); | 351 SessionService* session_service = profile()->GetSessionService(); |
| 352 if (session_service) | 352 if (session_service) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 472 |
| 473 CloseAllTabs(); | 473 CloseAllTabs(); |
| 474 } | 474 } |
| 475 | 475 |
| 476 /////////////////////////////////////////////////////////////////////////////// | 476 /////////////////////////////////////////////////////////////////////////////// |
| 477 // Browser, Tab adding/showing functions: | 477 // Browser, Tab adding/showing functions: |
| 478 | 478 |
| 479 TabContents* Browser::AddTabWithURL( | 479 TabContents* Browser::AddTabWithURL( |
| 480 const GURL& url, const GURL& referrer, PageTransition::Type transition, | 480 const GURL& url, const GURL& referrer, PageTransition::Type transition, |
| 481 bool foreground, SiteInstance* instance) { | 481 bool foreground, SiteInstance* instance) { |
| 482 if (type_ == TYPE_APP && tabstrip_model_.count() == 1) { | 482 if ((type_ & TYPE_APP) != 0 && tabstrip_model_.count() == 1) { |
| 483 NOTREACHED() << "Cannot add a tab in a mono tab application."; | 483 NOTREACHED() << "Cannot add a tab in a mono tab application."; |
| 484 return NULL; | 484 return NULL; |
| 485 } | 485 } |
| 486 | 486 |
| 487 GURL url_to_load = url; | 487 GURL url_to_load = url; |
| 488 if (url_to_load.is_empty()) | 488 if (url_to_load.is_empty()) |
| 489 url_to_load = GetHomePage(); | 489 url_to_load = GetHomePage(); |
| 490 TabContents* contents = | 490 TabContents* contents = |
| 491 CreateTabContentsForURL(url_to_load, referrer, profile_, transition, | 491 CreateTabContentsForURL(url_to_load, referrer, profile_, transition, |
| 492 false, instance); | 492 false, instance); |
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 // If you duplicate a tab that is not selected, we need to make sure to | 1303 // If you duplicate a tab that is not selected, we need to make sure to |
| 1304 // select the tab being duplicated so that DetermineInsertionIndex returns | 1304 // select the tab being duplicated so that DetermineInsertionIndex returns |
| 1305 // the right index (if tab 5 is selected and we right-click tab 1 we want | 1305 // the right index (if tab 5 is selected and we right-click tab 1 we want |
| 1306 // the new tab to appear in index position 2, not 6). | 1306 // the new tab to appear in index position 2, not 6). |
| 1307 if (tabstrip_model_.selected_index() != index) | 1307 if (tabstrip_model_.selected_index() != index) |
| 1308 tabstrip_model_.SelectTabContentsAt(index, true); | 1308 tabstrip_model_.SelectTabContentsAt(index, true); |
| 1309 tabstrip_model_.AddTabContents(new_contents, index + 1, | 1309 tabstrip_model_.AddTabContents(new_contents, index + 1, |
| 1310 PageTransition::LINK, true); | 1310 PageTransition::LINK, true); |
| 1311 } else { | 1311 } else { |
| 1312 Browser* browser = NULL; | 1312 Browser* browser = NULL; |
| 1313 if (type_ == TYPE_APP) { | 1313 if (type_ & TYPE_APP) { |
| 1314 browser = Browser::CreateForApp(app_name_, profile_); | 1314 browser = Browser::CreateForApp(app_name_, profile_, type_ & TYPE_POPUP); |
| 1315 } else if (type_ == TYPE_POPUP) { | 1315 } else if (type_ == TYPE_POPUP) { |
| 1316 browser = Browser::CreateForPopup(profile_); | 1316 browser = Browser::CreateForPopup(profile_); |
| 1317 } | 1317 } |
| 1318 | 1318 |
| 1319 // Preserve the size of the original window. The new window has already | 1319 // Preserve the size of the original window. The new window has already |
| 1320 // been given an offset by the OS, so we shouldn't copy the old bounds. | 1320 // been given an offset by the OS, so we shouldn't copy the old bounds. |
| 1321 BrowserWindow* new_window = browser->window(); | 1321 BrowserWindow* new_window = browser->window(); |
| 1322 new_window->SetBounds(gfx::Rect(new_window->GetNormalBounds().origin(), | 1322 new_window->SetBounds(gfx::Rect(new_window->GetNormalBounds().origin(), |
| 1323 window()->GetNormalBounds().size())); | 1323 window()->GetNormalBounds().size())); |
| 1324 | 1324 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1534 if (web_contents) { | 1534 if (web_contents) { |
| 1535 const GURL& current_url = web_contents->GetURL(); | 1535 const GURL& current_url = web_contents->GetURL(); |
| 1536 if (SiteInstance::IsSameWebSite(current_url, url)) | 1536 if (SiteInstance::IsSameWebSite(current_url, url)) |
| 1537 instance = web_contents->GetSiteInstance(); | 1537 instance = web_contents->GetSiteInstance(); |
| 1538 } | 1538 } |
| 1539 } | 1539 } |
| 1540 } | 1540 } |
| 1541 | 1541 |
| 1542 // If this is an application we can only have one tab so a new tab always | 1542 // If this is an application we can only have one tab so a new tab always |
| 1543 // goes into a tabbed browser window. | 1543 // goes into a tabbed browser window. |
| 1544 if (disposition != NEW_WINDOW && type_ == TYPE_APP) { | 1544 if (disposition != NEW_WINDOW && type_ & TYPE_APP) { |
| 1545 // If the disposition is OFF_THE_RECORD we don't want to create a new | 1545 // If the disposition is OFF_THE_RECORD we don't want to create a new |
| 1546 // browser that will itself create another OTR browser. This will result in | 1546 // browser that will itself create another OTR browser. This will result in |
| 1547 // a browser leak (and crash below because no tab is created or selected). | 1547 // a browser leak (and crash below because no tab is created or selected). |
| 1548 if (disposition == OFF_THE_RECORD) { | 1548 if (disposition == OFF_THE_RECORD) { |
| 1549 OpenURLOffTheRecord(profile_, url); | 1549 OpenURLOffTheRecord(profile_, url); |
| 1550 return; | 1550 return; |
| 1551 } | 1551 } |
| 1552 | 1552 |
| 1553 Browser* b = GetOrCreateTabbedBrowser(); | 1553 Browser* b = GetOrCreateTabbedBrowser(); |
| 1554 DCHECK(b); | 1554 DCHECK(b); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1659 disposition != NEW_WINDOW && disposition != NEW_POPUP && | 1659 disposition != NEW_WINDOW && disposition != NEW_POPUP && |
| 1660 type_ != TYPE_NORMAL) { | 1660 type_ != TYPE_NORMAL) { |
| 1661 Browser* b = GetOrCreateTabbedBrowser(); | 1661 Browser* b = GetOrCreateTabbedBrowser(); |
| 1662 DCHECK(b); | 1662 DCHECK(b); |
| 1663 PageTransition::Type transition = PageTransition::LINK; | 1663 PageTransition::Type transition = PageTransition::LINK; |
| 1664 // If we were called from an "installed webapp" we want to emulate the code | 1664 // If we were called from an "installed webapp" we want to emulate the code |
| 1665 // that is run from browser_init.cc for links from external applications. | 1665 // that is run from browser_init.cc for links from external applications. |
| 1666 // This means we need to open the tab with the START PAGE transition. | 1666 // This means we need to open the tab with the START PAGE transition. |
| 1667 // AddNewContents doesn't support this but the TabStripModel's | 1667 // AddNewContents doesn't support this but the TabStripModel's |
| 1668 // AddTabContents method does. | 1668 // AddTabContents method does. |
| 1669 if (type_ == TYPE_APP) | 1669 if (type_ & TYPE_APP) |
| 1670 transition = PageTransition::START_PAGE; | 1670 transition = PageTransition::START_PAGE; |
| 1671 b->tabstrip_model()->AddTabContents(new_contents, -1, transition, true); | 1671 b->tabstrip_model()->AddTabContents(new_contents, -1, transition, true); |
| 1672 b->window()->Show(); | 1672 b->window()->Show(); |
| 1673 return; | 1673 return; |
| 1674 } | 1674 } |
| 1675 | 1675 |
| 1676 if (disposition == NEW_POPUP) { | 1676 if (disposition == NEW_POPUP) { |
| 1677 BuildPopupWindow(source, new_contents, initial_pos); | 1677 BuildPopupWindow(source, new_contents, initial_pos); |
| 1678 } else if (disposition == NEW_WINDOW) { | 1678 } else if (disposition == NEW_WINDOW) { |
| 1679 Browser* browser = Browser::Create(profile_); | 1679 Browser* browser = Browser::Create(profile_); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1717 | 1717 |
| 1718 int index = tabstrip_model_.GetIndexOfTabContents(source); | 1718 int index = tabstrip_model_.GetIndexOfTabContents(source); |
| 1719 if (index == TabStripModel::kNoTab) { | 1719 if (index == TabStripModel::kNoTab) { |
| 1720 NOTREACHED() << "CloseContents called for tab not in our strip"; | 1720 NOTREACHED() << "CloseContents called for tab not in our strip"; |
| 1721 return; | 1721 return; |
| 1722 } | 1722 } |
| 1723 tabstrip_model_.CloseTabContentsAt(index); | 1723 tabstrip_model_.CloseTabContentsAt(index); |
| 1724 } | 1724 } |
| 1725 | 1725 |
| 1726 void Browser::MoveContents(TabContents* source, const gfx::Rect& pos) { | 1726 void Browser::MoveContents(TabContents* source, const gfx::Rect& pos) { |
| 1727 if (type() != TYPE_POPUP) { | 1727 if ((type() & TYPE_POPUP) == 0) { |
| 1728 NOTREACHED() << "moving invalid browser type"; | 1728 NOTREACHED() << "moving invalid browser type"; |
| 1729 return; | 1729 return; |
| 1730 } | 1730 } |
| 1731 window_->SetBounds(pos); | 1731 window_->SetBounds(pos); |
| 1732 } | 1732 } |
| 1733 | 1733 |
| 1734 bool Browser::IsPopup(TabContents* source) { | 1734 bool Browser::IsPopup(TabContents* source) { |
| 1735 // A non-tabbed BROWSER is an unconstrained popup. | 1735 // A non-tabbed BROWSER is an unconstrained popup. |
| 1736 return (type() == TYPE_POPUP); | 1736 return (type() & TYPE_POPUP); |
| 1737 } | 1737 } |
| 1738 | 1738 |
| 1739 void Browser::ToolbarSizeChanged(TabContents* source, bool is_animating) { | 1739 void Browser::ToolbarSizeChanged(TabContents* source, bool is_animating) { |
| 1740 if (source == GetSelectedTabContents() || source == NULL) { | 1740 if (source == GetSelectedTabContents() || source == NULL) { |
| 1741 // This will refresh the shelf if needed. | 1741 // This will refresh the shelf if needed. |
| 1742 window_->SelectedTabToolbarSizeChanged(is_animating); | 1742 window_->SelectedTabToolbarSizeChanged(is_animating); |
| 1743 } | 1743 } |
| 1744 } | 1744 } |
| 1745 | 1745 |
| 1746 void Browser::URLStarredChanged(TabContents* source, bool starred) { | 1746 void Browser::URLStarredChanged(TabContents* source, bool starred) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1772 PrefService* prefs = profile_->GetPrefs(); | 1772 PrefService* prefs = profile_->GetPrefs(); |
| 1773 GetStatusBubble()->SetURL(url, prefs->GetString(prefs::kAcceptLanguages)); | 1773 GetStatusBubble()->SetURL(url, prefs->GetString(prefs::kAcceptLanguages)); |
| 1774 } | 1774 } |
| 1775 } | 1775 } |
| 1776 | 1776 |
| 1777 void Browser::ContentsZoomChange(bool zoom_in) { | 1777 void Browser::ContentsZoomChange(bool zoom_in) { |
| 1778 ExecuteCommand(zoom_in ? IDC_ZOOM_PLUS : IDC_ZOOM_MINUS); | 1778 ExecuteCommand(zoom_in ? IDC_ZOOM_PLUS : IDC_ZOOM_MINUS); |
| 1779 } | 1779 } |
| 1780 | 1780 |
| 1781 bool Browser::IsApplication() const { | 1781 bool Browser::IsApplication() const { |
| 1782 return type_ == TYPE_APP; | 1782 return (type_ & TYPE_APP) != 0; |
| 1783 } | 1783 } |
| 1784 | 1784 |
| 1785 void Browser::ConvertContentsToApplication(TabContents* contents) { | 1785 void Browser::ConvertContentsToApplication(TabContents* contents) { |
| 1786 int index = tabstrip_model_.GetIndexOfTabContents(contents); | 1786 int index = tabstrip_model_.GetIndexOfTabContents(contents); |
| 1787 if (index < 0) | 1787 if (index < 0) |
| 1788 return; | 1788 return; |
| 1789 | 1789 |
| 1790 const GURL& url = contents->controller()->GetActiveEntry()->url(); | 1790 const GURL& url = contents->controller()->GetActiveEntry()->url(); |
| 1791 std::wstring app_name = ComputeApplicationNameFromURL(url); | 1791 std::wstring app_name = ComputeApplicationNameFromURL(url); |
| 1792 RegisterAppPrefs(app_name); | 1792 RegisterAppPrefs(app_name); |
| 1793 | 1793 |
| 1794 tabstrip_model_.DetachTabContentsAt(index); | 1794 tabstrip_model_.DetachTabContentsAt(index); |
| 1795 Browser* browser = Browser::CreateForApp(app_name, profile_); | 1795 Browser* browser = Browser::CreateForApp(app_name, profile_, false); |
| 1796 browser->tabstrip_model()->AppendTabContents(contents, true); | 1796 browser->tabstrip_model()->AppendTabContents(contents, true); |
| 1797 browser->window()->Show(); | 1797 browser->window()->Show(); |
| 1798 } | 1798 } |
| 1799 | 1799 |
| 1800 void Browser::ContentsStateChanged(TabContents* source) { | 1800 void Browser::ContentsStateChanged(TabContents* source) { |
| 1801 int index = tabstrip_model_.GetIndexOfTabContents(source); | 1801 int index = tabstrip_model_.GetIndexOfTabContents(source); |
| 1802 if (index != TabStripModel::kNoTab) | 1802 if (index != TabStripModel::kNoTab) |
| 1803 tabstrip_model_.UpdateTabContentsStateAt(index); | 1803 tabstrip_model_.UpdateTabContentsStateAt(index); |
| 1804 } | 1804 } |
| 1805 | 1805 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2084 | 2084 |
| 2085 void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) { | 2085 void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) { |
| 2086 const bool show_main_ui = (type() == TYPE_NORMAL) && !is_fullscreen; | 2086 const bool show_main_ui = (type() == TYPE_NORMAL) && !is_fullscreen; |
| 2087 | 2087 |
| 2088 // Navigation commands | 2088 // Navigation commands |
| 2089 command_updater_.UpdateCommandEnabled(IDC_OPEN_CURRENT_URL, show_main_ui); | 2089 command_updater_.UpdateCommandEnabled(IDC_OPEN_CURRENT_URL, show_main_ui); |
| 2090 | 2090 |
| 2091 // Window management commands | 2091 // Window management commands |
| 2092 command_updater_.UpdateCommandEnabled(IDC_PROFILE_MENU, show_main_ui); | 2092 command_updater_.UpdateCommandEnabled(IDC_PROFILE_MENU, show_main_ui); |
| 2093 command_updater_.UpdateCommandEnabled(IDC_SHOW_AS_TAB, | 2093 command_updater_.UpdateCommandEnabled(IDC_SHOW_AS_TAB, |
| 2094 (type() == TYPE_POPUP) && !is_fullscreen); | 2094 (type() & TYPE_POPUP) && !is_fullscreen); |
| 2095 | 2095 |
| 2096 // Focus various bits of UI | 2096 // Focus various bits of UI |
| 2097 command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui); | 2097 command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui); |
| 2098 command_updater_.UpdateCommandEnabled(IDC_FOCUS_LOCATION, show_main_ui); | 2098 command_updater_.UpdateCommandEnabled(IDC_FOCUS_LOCATION, show_main_ui); |
| 2099 command_updater_.UpdateCommandEnabled(IDC_FOCUS_SEARCH, show_main_ui); | 2099 command_updater_.UpdateCommandEnabled(IDC_FOCUS_SEARCH, show_main_ui); |
| 2100 | 2100 |
| 2101 // Show various bits of UI | 2101 // Show various bits of UI |
| 2102 command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, show_main_ui); | 2102 command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, show_main_ui); |
| 2103 command_updater_.UpdateCommandEnabled(IDC_NEW_PROFILE, show_main_ui); | 2103 command_updater_.UpdateCommandEnabled(IDC_NEW_PROFILE, show_main_ui); |
| 2104 command_updater_.UpdateCommandEnabled(IDC_REPORT_BUG, show_main_ui); | 2104 command_updater_.UpdateCommandEnabled(IDC_REPORT_BUG, show_main_ui); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2369 profile_, TYPE_NORMAL); | 2369 profile_, TYPE_NORMAL); |
| 2370 if (!browser) | 2370 if (!browser) |
| 2371 browser = Browser::Create(profile_); | 2371 browser = Browser::Create(profile_); |
| 2372 return browser; | 2372 return browser; |
| 2373 } | 2373 } |
| 2374 | 2374 |
| 2375 void Browser::BuildPopupWindow(TabContents* source, | 2375 void Browser::BuildPopupWindow(TabContents* source, |
| 2376 TabContents* new_contents, | 2376 TabContents* new_contents, |
| 2377 const gfx::Rect& initial_pos) { | 2377 const gfx::Rect& initial_pos) { |
| 2378 Browser* browser = | 2378 Browser* browser = |
| 2379 new Browser((type_ == TYPE_APP) ? TYPE_APP : TYPE_POPUP, profile_); | 2379 new Browser((type_ & TYPE_APP) ? TYPE_APP_POPUP : TYPE_POPUP, profile_); |
| 2380 browser->set_override_bounds(initial_pos); | 2380 browser->set_override_bounds(initial_pos); |
| 2381 browser->CreateBrowserWindow(); | 2381 browser->CreateBrowserWindow(); |
| 2382 // We need to Show before AddNewContents, otherwise AddNewContents will focus | 2382 // We need to Show before AddNewContents, otherwise AddNewContents will focus |
| 2383 // it (via BrowserView::TabSelectedAt calling RestoreFocus), triggering any | 2383 // it (via BrowserView::TabSelectedAt calling RestoreFocus), triggering any |
| 2384 // onblur="" handlers. | 2384 // onblur="" handlers. |
| 2385 browser->window()->Show(); | 2385 browser->window()->Show(); |
| 2386 // TODO(beng): See if this can be made to use | 2386 // TODO(beng): See if this can be made to use |
| 2387 // TabStripModel::AppendTabContents. | 2387 // TabStripModel::AppendTabContents. |
| 2388 browser->AddNewContents(source, new_contents, NEW_FOREGROUND_TAB, | 2388 browser->AddNewContents(source, new_contents, NEW_FOREGROUND_TAB, |
| 2389 gfx::Rect(), true); | 2389 gfx::Rect(), true); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2442 | 2442 |
| 2443 // We need to register the window position pref. | 2443 // We need to register the window position pref. |
| 2444 std::wstring window_pref(prefs::kBrowserWindowPlacement); | 2444 std::wstring window_pref(prefs::kBrowserWindowPlacement); |
| 2445 window_pref.append(L"_"); | 2445 window_pref.append(L"_"); |
| 2446 window_pref.append(app_name); | 2446 window_pref.append(app_name); |
| 2447 PrefService* prefs = g_browser_process->local_state(); | 2447 PrefService* prefs = g_browser_process->local_state(); |
| 2448 DCHECK(prefs); | 2448 DCHECK(prefs); |
| 2449 | 2449 |
| 2450 prefs->RegisterDictionaryPref(window_pref.c_str()); | 2450 prefs->RegisterDictionaryPref(window_pref.c_str()); |
| 2451 } | 2451 } |
| OLD | NEW |