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 <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 tab->Focus(); | 1516 tab->Focus(); |
1517 if (ignore_cache) | 1517 if (ignore_cache) |
1518 tab->controller().ReloadIgnoringCache(true); | 1518 tab->controller().ReloadIgnoringCache(true); |
1519 else | 1519 else |
1520 tab->controller().Reload(true); | 1520 tab->controller().Reload(true); |
1521 } | 1521 } |
1522 | 1522 |
1523 void Browser::Home(WindowOpenDisposition disposition) { | 1523 void Browser::Home(WindowOpenDisposition disposition) { |
1524 UserMetrics::RecordAction(UserMetricsAction("Home")); | 1524 UserMetrics::RecordAction(UserMetricsAction("Home")); |
1525 OpenURL( | 1525 OpenURL( |
1526 GetHomePage(), GURL(), disposition, | 1526 profile_->GetHomePage(), GURL(), disposition, |
1527 content::PageTransitionFromInt( | 1527 content::PageTransitionFromInt( |
1528 content::PAGE_TRANSITION_AUTO_BOOKMARK | | 1528 content::PAGE_TRANSITION_AUTO_BOOKMARK | |
1529 content::PAGE_TRANSITION_HOME_PAGE)); | 1529 content::PAGE_TRANSITION_HOME_PAGE)); |
1530 } | 1530 } |
1531 | 1531 |
1532 void Browser::OpenCurrentURL() { | 1532 void Browser::OpenCurrentURL() { |
1533 UserMetrics::RecordAction(UserMetricsAction("LoadURL")); | 1533 UserMetrics::RecordAction(UserMetricsAction("LoadURL")); |
1534 LocationBar* location_bar = window_->GetLocationBar(); | 1534 LocationBar* location_bar = window_->GetLocationBar(); |
1535 if (!location_bar) | 1535 if (!location_bar) |
1536 return; | 1536 return; |
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2944 // will put it out of sync with the actual state like whether we're | 2944 // will put it out of sync with the actual state like whether we're |
2945 // displaying a favicon, which controls the throbber. If we updated it here, | 2945 // displaying a favicon, which controls the throbber. If we updated it here, |
2946 // the throbber will show the default favicon for a split second when | 2946 // the throbber will show the default favicon for a split second when |
2947 // navigating away from the new tab page. | 2947 // navigating away from the new tab page. |
2948 ScheduleUIUpdate(contents->tab_contents(), TabContents::INVALIDATE_URL); | 2948 ScheduleUIUpdate(contents->tab_contents(), TabContents::INVALIDATE_URL); |
2949 | 2949 |
2950 if (contents_is_selected) | 2950 if (contents_is_selected) |
2951 contents->tab_contents()->Focus(); | 2951 contents->tab_contents()->Focus(); |
2952 } | 2952 } |
2953 | 2953 |
2954 GURL Browser::GetHomePage() const { | |
2955 // --homepage overrides any preferences. | |
2956 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
2957 if (command_line.HasSwitch(switches::kHomePage)) { | |
2958 // TODO(evanm): clean up usage of DIR_CURRENT. | |
2959 // http://code.google.com/p/chromium/issues/detail?id=60630 | |
2960 // For now, allow this code to call getcwd(). | |
2961 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
2962 | |
2963 FilePath browser_directory; | |
2964 PathService::Get(base::DIR_CURRENT, &browser_directory); | |
2965 GURL home_page(URLFixerUpper::FixupRelativeFile(browser_directory, | |
2966 command_line.GetSwitchValuePath(switches::kHomePage))); | |
2967 if (home_page.is_valid()) | |
2968 return home_page; | |
2969 } | |
2970 | |
2971 if (profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) | |
2972 return GURL(chrome::kChromeUINewTabURL); | |
2973 GURL home_page(URLFixerUpper::FixupURL( | |
2974 profile_->GetPrefs()->GetString(prefs::kHomePage), | |
2975 std::string())); | |
2976 if (!home_page.is_valid()) | |
2977 return GURL(chrome::kChromeUINewTabURL); | |
2978 return home_page; | |
2979 } | |
2980 | |
2981 /////////////////////////////////////////////////////////////////////////////// | 2954 /////////////////////////////////////////////////////////////////////////////// |
2982 // Browser, PageNavigator implementation: | 2955 // Browser, PageNavigator implementation: |
2983 | 2956 |
2984 // TODO(adriansc): Remove this method once refactoring changed all call sites. | 2957 // TODO(adriansc): Remove this method once refactoring changed all call sites. |
2985 TabContents* Browser::OpenURL(const GURL& url, | 2958 TabContents* Browser::OpenURL(const GURL& url, |
2986 const GURL& referrer, | 2959 const GURL& referrer, |
2987 WindowOpenDisposition disposition, | 2960 WindowOpenDisposition disposition, |
2988 content::PageTransition transition) { | 2961 content::PageTransition transition) { |
2989 return OpenURLFromTab(NULL, | 2962 return OpenURLFromTab(NULL, |
2990 OpenURLParams(url, referrer, disposition, transition, | 2963 OpenURLParams(url, referrer, disposition, transition, |
(...skipping 2516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5507 } | 5480 } |
5508 | 5481 |
5509 void Browser::UpdateFullscreenExitBubbleContent() { | 5482 void Browser::UpdateFullscreenExitBubbleContent() { |
5510 GURL url; | 5483 GURL url; |
5511 if (fullscreened_tab_) | 5484 if (fullscreened_tab_) |
5512 url = fullscreened_tab_->tab_contents()->GetURL(); | 5485 url = fullscreened_tab_->tab_contents()->GetURL(); |
5513 | 5486 |
5514 window_->UpdateFullscreenExitBubbleContent( | 5487 window_->UpdateFullscreenExitBubbleContent( |
5515 url, GetFullscreenExitBubbleType()); | 5488 url, GetFullscreenExitBubbleType()); |
5516 } | 5489 } |
OLD | NEW |