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

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

Issue 1036173002: Animate showing / hiding the location bar for bookmark apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac compile Created 5 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 // defined(OS_WIN) 10 #endif // defined(OS_WIN)
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" 101 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h"
102 #include "chrome/browser/ui/browser_tab_strip_model_delegate.h" 102 #include "chrome/browser/ui/browser_tab_strip_model_delegate.h"
103 #include "chrome/browser/ui/browser_tabstrip.h" 103 #include "chrome/browser/ui/browser_tabstrip.h"
104 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" 104 #include "chrome/browser/ui/browser_toolbar_model_delegate.h"
105 #include "chrome/browser/ui/browser_ui_prefs.h" 105 #include "chrome/browser/ui/browser_ui_prefs.h"
106 #include "chrome/browser/ui/browser_window.h" 106 #include "chrome/browser/ui/browser_window.h"
107 #include "chrome/browser/ui/chrome_pages.h" 107 #include "chrome/browser/ui/chrome_pages.h"
108 #include "chrome/browser/ui/chrome_select_file_policy.h" 108 #include "chrome/browser/ui/chrome_select_file_policy.h"
109 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 109 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
110 #include "chrome/browser/ui/exclusive_access/mouse_lock_controller.h" 110 #include "chrome/browser/ui/exclusive_access/mouse_lock_controller.h"
111 #include "chrome/browser/ui/extensions/bookmark_app_browser_controller.h"
111 #include "chrome/browser/ui/fast_unload_controller.h" 112 #include "chrome/browser/ui/fast_unload_controller.h"
112 #include "chrome/browser/ui/find_bar/find_bar.h" 113 #include "chrome/browser/ui/find_bar/find_bar.h"
113 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 114 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
114 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 115 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
115 #include "chrome/browser/ui/global_error/global_error.h" 116 #include "chrome/browser/ui/global_error/global_error.h"
116 #include "chrome/browser/ui/global_error/global_error_service.h" 117 #include "chrome/browser/ui/global_error/global_error_service.h"
117 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 118 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
118 #include "chrome/browser/ui/location_bar/location_bar.h" 119 #include "chrome/browser/ui/location_bar/location_bar.h"
119 #include "chrome/browser/ui/media_utils.h" 120 #include "chrome/browser/ui/media_utils.h"
120 #include "chrome/browser/ui/search/search_delegate.h" 121 #include "chrome/browser/ui/search/search_delegate.h"
(...skipping 12 matching lines...) Expand all
133 #include "chrome/browser/ui/tabs/tab_strip_model.h" 134 #include "chrome/browser/ui/tabs/tab_strip_model.h"
134 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h" 135 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h"
135 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" 136 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h"
136 #include "chrome/browser/ui/unload_controller.h" 137 #include "chrome/browser/ui/unload_controller.h"
137 #include "chrome/browser/ui/validation_message_bubble.h" 138 #include "chrome/browser/ui/validation_message_bubble.h"
138 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 139 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
139 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 140 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
140 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 141 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
141 #include "chrome/browser/ui/window_sizer/window_sizer.h" 142 #include "chrome/browser/ui/window_sizer/window_sizer.h"
142 #include "chrome/browser/upgrade_detector.h" 143 #include "chrome/browser/upgrade_detector.h"
143 #include "chrome/browser/web_applications/web_app.h"
144 #include "chrome/common/chrome_constants.h" 144 #include "chrome/common/chrome_constants.h"
145 #include "chrome/common/chrome_switches.h" 145 #include "chrome/common/chrome_switches.h"
146 #include "chrome/common/custom_handlers/protocol_handler.h" 146 #include "chrome/common/custom_handlers/protocol_handler.h"
147 #include "chrome/common/pref_names.h" 147 #include "chrome/common/pref_names.h"
148 #include "chrome/common/profiling.h" 148 #include "chrome/common/profiling.h"
149 #include "chrome/common/search_types.h" 149 #include "chrome/common/search_types.h"
150 #include "chrome/common/url_constants.h" 150 #include "chrome/common/url_constants.h"
151 #include "chrome/grit/chromium_strings.h" 151 #include "chrome/grit/chromium_strings.h"
152 #include "chrome/grit/generated_resources.h" 152 #include "chrome/grit/generated_resources.h"
153 #include "chrome/grit/locale_settings.h" 153 #include "chrome/grit/locale_settings.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 BrowserWindow* CreateBrowserWindow(Browser* browser) { 245 BrowserWindow* CreateBrowserWindow(Browser* browser) {
246 return BrowserWindow::CreateBrowserWindow(browser); 246 return BrowserWindow::CreateBrowserWindow(browser);
247 } 247 }
248 248
249 // Is the fast tab unload experiment enabled? 249 // Is the fast tab unload experiment enabled?
250 bool IsFastTabUnloadEnabled() { 250 bool IsFastTabUnloadEnabled() {
251 return base::CommandLine::ForCurrentProcess()->HasSwitch( 251 return base::CommandLine::ForCurrentProcess()->HasSwitch(
252 switches::kEnableFastUnload); 252 switches::kEnableFastUnload);
253 } 253 }
254 254
255 bool IsWebAppFrameEnabled() {
256 return base::CommandLine::ForCurrentProcess()->HasSwitch(
257 switches::kEnableWebAppFrame);
258 }
259
260 } // namespace 255 } // namespace
261 256
262 //////////////////////////////////////////////////////////////////////////////// 257 ////////////////////////////////////////////////////////////////////////////////
263 // Browser, CreateParams: 258 // Browser, CreateParams:
264 259
265 Browser::CreateParams::CreateParams(Profile* profile, 260 Browser::CreateParams::CreateParams(Profile* profile,
266 chrome::HostDesktopType host_desktop_type) 261 chrome::HostDesktopType host_desktop_type)
267 : type(TYPE_TABBED), 262 : type(TYPE_TABBED),
268 profile(profile), 263 profile(profile),
269 host_desktop_type(host_desktop_type), 264 host_desktop_type(host_desktop_type),
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 BrowserList::AddBrowser(this); 405 BrowserList::AddBrowser(this);
411 406
412 // NOTE: These prefs all need to be explicitly destroyed in the destructor 407 // NOTE: These prefs all need to be explicitly destroyed in the destructor
413 // or you'll get a nasty surprise when you run the incognito tests. 408 // or you'll get a nasty surprise when you run the incognito tests.
414 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, 409 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector,
415 profile_->GetPrefs()); 410 profile_->GetPrefs());
416 411
417 if (chrome::IsInstantExtendedAPIEnabled() && is_type_tabbed()) 412 if (chrome::IsInstantExtendedAPIEnabled() && is_type_tabbed())
418 instant_controller_.reset(new BrowserInstantController(this)); 413 instant_controller_.reset(new BrowserInstantController(this));
419 414
415 if (extensions::BookmarkAppBrowserController::IsForBookmarkApp(this)) {
416 bookmark_app_controller_.reset(
417 new extensions::BookmarkAppBrowserController(this));
418 }
419
420 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INIT); 420 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INIT);
421 421
422 ProfileMetrics::LogProfileLaunch(profile_); 422 ProfileMetrics::LogProfileLaunch(profile_);
423 423
424 window_ = params.window ? params.window : CreateBrowserWindow(this); 424 window_ = params.window ? params.window : CreateBrowserWindow(this);
425 425
426 if (bookmark_app_controller_)
427 bookmark_app_controller_->UpdateLocationBarState(false);
428
426 // Create the extension window controller before sending notifications. 429 // Create the extension window controller before sending notifications.
427 extension_window_controller_.reset( 430 extension_window_controller_.reset(
428 new BrowserExtensionWindowController(this)); 431 new BrowserExtensionWindowController(this));
429 432
430 SessionService* session_service = 433 SessionService* session_service =
431 SessionServiceFactory::GetForProfileForSessionRestore(profile_); 434 SessionServiceFactory::GetForProfileForSessionRestore(profile_);
432 if (session_service) 435 if (session_service)
433 session_service->WindowOpened(this); 436 session_service->WindowOpened(this);
434 437
435 // TODO(beng): Move BrowserList::AddBrowser() to the end of this function and 438 // TODO(beng): Move BrowserList::AddBrowser() to the end of this function and
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 tracked_objects::ScopedTracker tracking_profile2( 1407 tracked_objects::ScopedTracker tracking_profile2(
1405 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1408 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1406 "466285 Browser::NavigationStateChanged::TabStateChanged")); 1409 "466285 Browser::NavigationStateChanged::TabStateChanged"));
1407 // We can synchronously update commands since they will only change once per 1410 // We can synchronously update commands since they will only change once per
1408 // navigation, so we don't have to worry about flickering. We do, however, 1411 // navigation, so we don't have to worry about flickering. We do, however,
1409 // need to update the command state early on load to always present usable 1412 // need to update the command state early on load to always present usable
1410 // actions in the face of slow-to-commit pages. 1413 // actions in the face of slow-to-commit pages.
1411 if (changed_flags & (content::INVALIDATE_TYPE_URL | 1414 if (changed_flags & (content::INVALIDATE_TYPE_URL |
1412 content::INVALIDATE_TYPE_LOAD)) 1415 content::INVALIDATE_TYPE_LOAD))
1413 command_controller_->TabStateChanged(); 1416 command_controller_->TabStateChanged();
1417
1418 if (bookmark_app_controller_)
1419 bookmark_app_controller_->UpdateLocationBarState(true);
1414 } 1420 }
1415 1421
1416 void Browser::VisibleSSLStateChanged(const WebContents* source) { 1422 void Browser::VisibleSSLStateChanged(const WebContents* source) {
1417 // When the current tab's SSL state changes, we need to update the URL 1423 // When the current tab's SSL state changes, we need to update the URL
1418 // bar to reflect the new state. 1424 // bar to reflect the new state.
1419 DCHECK(source); 1425 DCHECK(source);
1420 if (tab_strip_model_->GetActiveWebContents() == source) 1426 if (tab_strip_model_->GetActiveWebContents() == source)
1421 UpdateToolbar(false); 1427 UpdateToolbar(false);
1422 } 1428 }
1423 1429
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
2402 for (size_t i = 0; i < interstitial_observers_.size(); i++) { 2408 for (size_t i = 0; i < interstitial_observers_.size(); i++) {
2403 if (interstitial_observers_[i]->web_contents() != contents) 2409 if (interstitial_observers_[i]->web_contents() != contents)
2404 continue; 2410 continue;
2405 2411
2406 delete interstitial_observers_[i]; 2412 delete interstitial_observers_[i];
2407 interstitial_observers_.erase(interstitial_observers_.begin() + i); 2413 interstitial_observers_.erase(interstitial_observers_.begin() + i);
2408 return; 2414 return;
2409 } 2415 }
2410 } 2416 }
2411 2417
2412 bool Browser::ShouldShowLocationBar() const { 2418 bool Browser::SupportsLocationBar() const {
2413 // Tabbed browser always show a location bar. 2419 // Tabbed browser always show a location bar.
2414 if (is_type_tabbed()) 2420 if (is_type_tabbed())
2415 return true; 2421 return true;
2416 2422
2417 // Non-app windows that aren't tabbed or system windows should always show a 2423 // Non-app windows that aren't tabbed or system windows should always show a
2418 // location bar, unless they are from a trusted source. 2424 // location bar, unless they are from a trusted source.
2419 if (!is_app()) 2425 if (!is_app())
2420 return !is_trusted_source(); 2426 return !is_trusted_source();
2421 2427
2422 if (ShouldUseWebAppFrame()) 2428 if (bookmark_app_controller_)
2423 return false; 2429 return bookmark_app_controller_->SupportsLocationBar();
2424 2430
2425 // Bookmark apps should show the location bar. 2431 return false;
2426 const std::string extension_id =
2427 web_app::GetExtensionIdFromApplicationName(app_name());
2428 const extensions::Extension* extension =
2429 extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
2430 extension_id, extensions::ExtensionRegistry::EVERYTHING);
2431 return extensions::ui_util::ShouldShowLocationBar(
2432 extension, tab_strip_model_->GetActiveWebContents());
2433 } 2432 }
2434 2433
2435 bool Browser::ShouldUseWebAppFrame() const { 2434 bool Browser::ShouldUseWebAppFrame() const {
2436 // Only use the web app frame for apps in ash, and only if the web app frame 2435 // Only use the web app frame for apps in ash, and only if the web app frame
2437 // is enabled. 2436 // is enabled.
2438 if (!is_app() || host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH || 2437 if (!is_app())
2439 !IsWebAppFrameEnabled()) {
2440 return false; 2438 return false;
2441 }
2442 2439
2443 // Use the web app frame for hosted apps. 2440 if (bookmark_app_controller_)
2444 const std::string extension_id = 2441 return bookmark_app_controller_->should_use_web_app_frame();
2445 web_app::GetExtensionIdFromApplicationName(app_name()); 2442
2446 const extensions::Extension* extension = 2443 return false;
2447 extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
2448 extension_id, extensions::ExtensionRegistry::EVERYTHING);
2449 return extension && extension->from_bookmark();
2450 } 2444 }
2451 2445
2452 bool Browser::SupportsWindowFeatureImpl(WindowFeature feature, 2446 bool Browser::SupportsWindowFeatureImpl(WindowFeature feature,
2453 bool check_fullscreen) const { 2447 bool check_fullscreen) const {
2454 bool hide_ui_for_fullscreen = check_fullscreen && ShouldHideUIForFullscreen(); 2448 bool hide_ui_for_fullscreen = check_fullscreen && ShouldHideUIForFullscreen();
2455 2449
2456 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF; 2450 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF;
2457 2451
2458 if (is_type_tabbed()) 2452 if (is_type_tabbed())
2459 features |= FEATURE_BOOKMARKBAR; 2453 features |= FEATURE_BOOKMARKBAR;
2460 2454
2461 if (!hide_ui_for_fullscreen) { 2455 if (!hide_ui_for_fullscreen) {
2462 if (!is_type_tabbed()) 2456 if (!is_type_tabbed())
2463 features |= FEATURE_TITLEBAR; 2457 features |= FEATURE_TITLEBAR;
2464 2458
2465 if (is_type_tabbed()) 2459 if (is_type_tabbed())
2466 features |= FEATURE_TABSTRIP; 2460 features |= FEATURE_TABSTRIP;
2467 2461
2468 if (is_type_tabbed()) 2462 if (is_type_tabbed())
2469 features |= FEATURE_TOOLBAR; 2463 features |= FEATURE_TOOLBAR;
2470 2464
2471 if (ShouldShowLocationBar()) 2465 if (SupportsLocationBar())
2472 features |= FEATURE_LOCATIONBAR; 2466 features |= FEATURE_LOCATIONBAR;
2473 2467
2474 if (ShouldUseWebAppFrame()) 2468 if (ShouldUseWebAppFrame())
2475 features |= FEATURE_WEBAPPFRAME; 2469 features |= FEATURE_WEBAPPFRAME;
2476 } 2470 }
2477 return !!(features & feature); 2471 return !!(features & feature);
2478 } 2472 }
2479 2473
2480 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { 2474 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) {
2481 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/467185 is 2475 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/467185 is
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2620 if (contents && !allow_js_access) { 2614 if (contents && !allow_js_access) {
2621 contents->web_contents()->GetController().LoadURL( 2615 contents->web_contents()->GetController().LoadURL(
2622 target_url, 2616 target_url,
2623 content::Referrer(), 2617 content::Referrer(),
2624 ui::PAGE_TRANSITION_LINK, 2618 ui::PAGE_TRANSITION_LINK,
2625 std::string()); // No extra headers. 2619 std::string()); // No extra headers.
2626 } 2620 }
2627 2621
2628 return contents != NULL; 2622 return contents != NULL;
2629 } 2623 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698