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

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

Issue 10908153: [Panel refactor] Deprecate old panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix views compile, no need to delete extra mac menu items cuz not using browser command updater any… Created 8 years, 3 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 // OS_WIN 10 #endif // OS_WIN
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 116 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
117 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 117 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
118 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 118 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
119 #include "chrome/browser/ui/global_error/global_error.h" 119 #include "chrome/browser/ui/global_error/global_error.h"
120 #include "chrome/browser/ui/global_error/global_error_service.h" 120 #include "chrome/browser/ui/global_error/global_error_service.h"
121 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 121 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
122 #include "chrome/browser/ui/hung_plugin_tab_helper.h" 122 #include "chrome/browser/ui/hung_plugin_tab_helper.h"
123 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" 123 #include "chrome/browser/ui/intents/web_intent_picker_controller.h"
124 #include "chrome/browser/ui/media_stream_infobar_delegate.h" 124 #include "chrome/browser/ui/media_stream_infobar_delegate.h"
125 #include "chrome/browser/ui/omnibox/location_bar.h" 125 #include "chrome/browser/ui/omnibox/location_bar.h"
126 #include "chrome/browser/ui/panels/panel.h"
127 #include "chrome/browser/ui/panels/panel_manager.h"
128 #include "chrome/browser/ui/search/search.h" 126 #include "chrome/browser/ui/search/search.h"
129 #include "chrome/browser/ui/search/search_delegate.h" 127 #include "chrome/browser/ui/search/search_delegate.h"
130 #include "chrome/browser/ui/search/search_model.h" 128 #include "chrome/browser/ui/search/search_model.h"
131 #include "chrome/browser/ui/singleton_tabs.h" 129 #include "chrome/browser/ui/singleton_tabs.h"
132 #include "chrome/browser/ui/status_bubble.h" 130 #include "chrome/browser/ui/status_bubble.h"
133 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h" 131 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h"
134 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 132 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
135 #include "chrome/browser/ui/tab_contents/tab_contents.h" 133 #include "chrome/browser/ui/tab_contents/tab_contents.h"
136 #include "chrome/browser/ui/tabs/dock_info.h" 134 #include "chrome/browser/ui/tabs/dock_info.h"
137 #include "chrome/browser/ui/tabs/tab_menu_model.h" 135 #include "chrome/browser/ui/tabs/tab_menu_model.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 const char kBrokenPageUrl[] = 231 const char kBrokenPageUrl[] =
234 "https://www.google.com/support/chrome/bin/request.py?contact_type=" 232 "https://www.google.com/support/chrome/bin/request.py?contact_type="
235 "broken_website&format=inproduct&p.page_title=$1&p.page_url=$2"; 233 "broken_website&format=inproduct&p.page_title=$1&p.page_url=$2";
236 234
237 // The URL for the privacy dashboard. 235 // The URL for the privacy dashboard.
238 const char kPrivacyDashboardUrl[] = "https://www.google.com/dashboard"; 236 const char kPrivacyDashboardUrl[] = "https://www.google.com/dashboard";
239 237
240 // How long we wait before updating the browser chrome while loading a page. 238 // How long we wait before updating the browser chrome while loading a page.
241 const int kUIUpdateCoalescingTimeMS = 200; 239 const int kUIUpdateCoalescingTimeMS = 200;
242 240
243 bool AllowPanels(const std::string& app_name) {
244 return PanelManager::ShouldUsePanels(
245 web_app::GetExtensionIdFromApplicationName(app_name));
246 }
247
248 BrowserWindow* CreateBrowserWindow(Browser* browser) { 241 BrowserWindow* CreateBrowserWindow(Browser* browser) {
249 #if !defined(USE_ASH)
250 if (browser->is_type_panel())
251 return PanelManager::GetInstance()->CreatePanel(browser)->browser_window();
252 #endif
253 return BrowserWindow::CreateBrowserWindow(browser); 242 return BrowserWindow::CreateBrowserWindow(browser);
254 } 243 }
255 244
256 #if defined(OS_CHROMEOS) 245 #if defined(OS_CHROMEOS)
257 chrome::HostDesktopType kDefaultHostDesktopType = chrome::HOST_DESKTOP_TYPE_ASH; 246 chrome::HostDesktopType kDefaultHostDesktopType = chrome::HOST_DESKTOP_TYPE_ASH;
258 #else 247 #else
259 chrome::HostDesktopType kDefaultHostDesktopType = 248 chrome::HostDesktopType kDefaultHostDesktopType =
260 chrome::HOST_DESKTOP_TYPE_NATIVE; 249 chrome::HOST_DESKTOP_TYPE_NATIVE;
261 #endif 250 #endif
262 251
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 299
311 // static 300 // static
312 Browser::CreateParams Browser::CreateParams::CreateForApp( 301 Browser::CreateParams Browser::CreateParams::CreateForApp(
313 Type type, 302 Type type,
314 const std::string& app_name, 303 const std::string& app_name,
315 const gfx::Rect& window_bounds, 304 const gfx::Rect& window_bounds,
316 Profile* profile) { 305 Profile* profile) {
317 DCHECK(type != TYPE_TABBED); 306 DCHECK(type != TYPE_TABBED);
318 DCHECK(!app_name.empty()); 307 DCHECK(!app_name.empty());
319 308
320 if (type == TYPE_PANEL && !AllowPanels(app_name))
321 type = TYPE_POPUP;
322
323 CreateParams params(type, profile); 309 CreateParams params(type, profile);
324 params.app_name = app_name; 310 params.app_name = app_name;
325 params.app_type = APP_TYPE_CHILD; 311 params.app_type = APP_TYPE_CHILD;
326 params.initial_bounds = window_bounds; 312 params.initial_bounds = window_bounds;
327 313
328 return params; 314 return params;
329 } 315 }
330 316
331 // static 317 // static
332 Browser::CreateParams Browser::CreateParams::CreateForDevTools( 318 Browser::CreateParams Browser::CreateParams::CreateForDevTools(
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 1428
1443 if (!window()) 1429 if (!window())
1444 return; 1430 return;
1445 1431
1446 // GetDownloadShelf creates the download shelf if it was not yet created. 1432 // GetDownloadShelf creates the download shelf if it was not yet created.
1447 DownloadShelf* shelf = window()->GetDownloadShelf(); 1433 DownloadShelf* shelf = window()->GetDownloadShelf();
1448 shelf->AddDownload(new DownloadItemModel(download)); 1434 shelf->AddDownload(new DownloadItemModel(download));
1449 // Don't show the animation for "Save file" downloads. 1435 // Don't show the animation for "Save file" downloads.
1450 // For non-theme extensions, we don't show the download animation. 1436 // For non-theme extensions, we don't show the download animation.
1451 // Show animation in same window as the download shelf. Download shelf 1437 // Show animation in same window as the download shelf. Download shelf
1452 // may not be in the same window that initiated the download, e.g. 1438 // may not be in the same window that initiated the download.
1453 // Panels.
1454 // Don't show the animation if the selected tab is not visible (i.e. the 1439 // Don't show the animation if the selected tab is not visible (i.e. the
1455 // window is minimized, we're in a unit test, etc.). 1440 // window is minimized, we're in a unit test, etc.).
1456 WebContents* shelf_tab = chrome::GetActiveWebContents(shelf->browser()); 1441 WebContents* shelf_tab = chrome::GetActiveWebContents(shelf->browser());
1457 if ((download->GetTotalBytes() > 0) && 1442 if ((download->GetTotalBytes() > 0) &&
1458 !download_crx_util::IsExtensionDownload(*download) && 1443 !download_crx_util::IsExtensionDownload(*download) &&
1459 platform_util::IsVisible(shelf_tab->GetNativeView()) && 1444 platform_util::IsVisible(shelf_tab->GetNativeView()) &&
1460 ui::Animation::ShouldRenderRichAnimation()) { 1445 ui::Animation::ShouldRenderRichAnimation()) {
1461 DownloadStartedAnimation::Show(shelf_tab); 1446 DownloadStartedAnimation::Show(shelf_tab);
1462 } 1447 }
1463 1448
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 1815
1831 // Close any tabs from the unloaded extension, unless it's terminated, 1816 // Close any tabs from the unloaded extension, unless it's terminated,
1832 // in which case let the sad tabs remain. 1817 // in which case let the sad tabs remain.
1833 if (content::Details<extensions::UnloadedExtensionInfo>( 1818 if (content::Details<extensions::UnloadedExtensionInfo>(
1834 details)->reason != extension_misc::UNLOAD_REASON_TERMINATE) { 1819 details)->reason != extension_misc::UNLOAD_REASON_TERMINATE) {
1835 const Extension* extension = 1820 const Extension* extension =
1836 content::Details<extensions::UnloadedExtensionInfo>( 1821 content::Details<extensions::UnloadedExtensionInfo>(
1837 details)->extension; 1822 details)->extension;
1838 for (int i = tab_strip_model_->count() - 1; i >= 0; --i) { 1823 for (int i = tab_strip_model_->count() - 1; i >= 0; --i) {
1839 WebContents* tc = chrome::GetTabContentsAt(this, i)->web_contents(); 1824 WebContents* tc = chrome::GetTabContentsAt(this, i)->web_contents();
1840 bool close_tab_contents = 1825 if (tc->GetURL().SchemeIs(chrome::kExtensionScheme) &&
1841 tc->GetURL().SchemeIs(chrome::kExtensionScheme) && 1826 tc->GetURL().host() == extension->id())
1842 tc->GetURL().host() == extension->id();
1843 // We want to close all panels originated by the unloaded extension.
1844 close_tab_contents = close_tab_contents ||
1845 (type_ == TYPE_PANEL &&
1846 (web_app::GetExtensionIdFromApplicationName(app_name_) ==
1847 extension->id()));
1848 if (close_tab_contents)
1849 chrome::CloseWebContents(this, tc); 1827 chrome::CloseWebContents(this, tc);
1850 } 1828 }
1851 } 1829 }
1852 break; 1830 break;
1853 } 1831 }
1854 1832
1855 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { 1833 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: {
1856 Profile* profile = content::Source<Profile>(source).ptr(); 1834 Profile* profile = content::Source<Profile>(source).ptr();
1857 if (profile_->IsSameProfile(profile) && window()->GetLocationBar()) 1835 if (profile_->IsSameProfile(profile) && window()->GetLocationBar())
1858 window()->GetLocationBar()->InvalidatePageActions(); 1836 window()->GetLocationBar()->InvalidatePageActions();
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2298 if (contents && !allow_js_access) { 2276 if (contents && !allow_js_access) {
2299 contents->web_contents()->GetController().LoadURL( 2277 contents->web_contents()->GetController().LoadURL(
2300 target_url, 2278 target_url,
2301 content::Referrer(), 2279 content::Referrer(),
2302 content::PAGE_TRANSITION_LINK, 2280 content::PAGE_TRANSITION_LINK,
2303 std::string()); // No extra headers. 2281 std::string()); // No extra headers.
2304 } 2282 }
2305 2283
2306 return contents != NULL; 2284 return contents != NULL;
2307 } 2285 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698