OLD | NEW |
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 1929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1940 if (!was_bookmarked && profile_->IsOffTheRecord()) { | 1940 if (!was_bookmarked && profile_->IsOffTheRecord()) { |
1941 // If we're incognito the favicon may not have been saved. Save it now | 1941 // If we're incognito the favicon may not have been saved. Save it now |
1942 // so that bookmarks have an icon for the page. | 1942 // so that bookmarks have an icon for the page. |
1943 tab->favicon_tab_helper()->SaveFavicon(); | 1943 tab->favicon_tab_helper()->SaveFavicon(); |
1944 } | 1944 } |
1945 bookmark_utils::AddIfNotBookmarked(model, url, title); | 1945 bookmark_utils::AddIfNotBookmarked(model, url, title); |
1946 // Make sure the model actually added a bookmark before showing the star. A | 1946 // Make sure the model actually added a bookmark before showing the star. A |
1947 // bookmark isn't created if the url is invalid. | 1947 // bookmark isn't created if the url is invalid. |
1948 if (window_->IsActive() && model->IsBookmarked(url)) { | 1948 if (window_->IsActive() && model->IsBookmarked(url)) { |
1949 // Only show the bubble if the window is active, otherwise we may get into | 1949 // Only show the bubble if the window is active, otherwise we may get into |
1950 // weird situations were the bubble is deleted as soon as it is shown. | 1950 // weird situations where the bubble is deleted as soon as it is shown. |
1951 window_->ShowBookmarkBubble(url, was_bookmarked); | 1951 window_->ShowBookmarkBubble(url, was_bookmarked); |
1952 } | 1952 } |
1953 } | 1953 } |
1954 | 1954 |
1955 void Browser::SavePage() { | 1955 void Browser::SavePage() { |
1956 content::RecordAction(UserMetricsAction("SavePage")); | 1956 content::RecordAction(UserMetricsAction("SavePage")); |
1957 WebContents* current_tab = GetSelectedWebContents(); | 1957 WebContents* current_tab = GetSelectedWebContents(); |
1958 if (current_tab && current_tab->GetContentsMimeType() == "application/pdf") | 1958 if (current_tab && current_tab->GetContentsMimeType() == "application/pdf") |
1959 content::RecordAction(UserMetricsAction("PDF.SavePage")); | 1959 content::RecordAction(UserMetricsAction("PDF.SavePage")); |
1960 GetSelectedWebContents()->OnSavePage(); | 1960 GetSelectedWebContents()->OnSavePage(); |
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3026 #endif | 3026 #endif |
3027 | 3027 |
3028 // Page-related commands | 3028 // Page-related commands |
3029 case IDC_SAVE_PAGE: SavePage(); break; | 3029 case IDC_SAVE_PAGE: SavePage(); break; |
3030 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; | 3030 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; |
3031 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; | 3031 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; |
3032 case IDC_VIEW_SOURCE: ViewSelectedSource(); break; | 3032 case IDC_VIEW_SOURCE: ViewSelectedSource(); break; |
3033 case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; | 3033 case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; |
3034 case IDC_PRINT: Print(); break; | 3034 case IDC_PRINT: Print(); break; |
3035 case IDC_ADVANCED_PRINT: AdvancedPrint(); break; | 3035 case IDC_ADVANCED_PRINT: AdvancedPrint(); break; |
| 3036 case IDC_CHROME_TO_MOBILE_PAGE: ShowChromeToMobileBubble(); break; |
3036 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; | 3037 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; |
3037 case IDC_ENCODING_UTF8: | 3038 case IDC_ENCODING_UTF8: |
3038 case IDC_ENCODING_UTF16LE: | 3039 case IDC_ENCODING_UTF16LE: |
3039 case IDC_ENCODING_ISO88591: | 3040 case IDC_ENCODING_ISO88591: |
3040 case IDC_ENCODING_WINDOWS1252: | 3041 case IDC_ENCODING_WINDOWS1252: |
3041 case IDC_ENCODING_GBK: | 3042 case IDC_ENCODING_GBK: |
3042 case IDC_ENCODING_GB18030: | 3043 case IDC_ENCODING_GB18030: |
3043 case IDC_ENCODING_BIG5HKSCS: | 3044 case IDC_ENCODING_BIG5HKSCS: |
3044 case IDC_ENCODING_BIG5: | 3045 case IDC_ENCODING_BIG5: |
3045 case IDC_ENCODING_KOREAN: | 3046 case IDC_ENCODING_KOREAN: |
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4013 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); | 4014 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); |
4014 | 4015 |
4015 if (CommandLine::ForCurrentProcess()->HasSwitch( | 4016 if (CommandLine::ForCurrentProcess()->HasSwitch( |
4016 switches::kEnableWebsiteSettings)) { | 4017 switches::kEnableWebsiteSettings)) { |
4017 window()->ShowWebsiteSettings(profile, wrapper, url, ssl, show_history); | 4018 window()->ShowWebsiteSettings(profile, wrapper, url, ssl, show_history); |
4018 } else { | 4019 } else { |
4019 window()->ShowPageInfo(profile, url, ssl, show_history); | 4020 window()->ShowPageInfo(profile, url, ssl, show_history); |
4020 } | 4021 } |
4021 } | 4022 } |
4022 | 4023 |
| 4024 void Browser::ShowChromeToMobileBubble() { |
| 4025 // Only show the bubble if the window is active, otherwise we may get into |
| 4026 // weird situations where the bubble is deleted as soon as it is shown. |
| 4027 if (window_->IsActive()) |
| 4028 window_->ShowChromeToMobileBubble(); |
| 4029 } |
| 4030 |
4023 void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) { | 4031 void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) { |
4024 DCHECK(source); | 4032 DCHECK(source); |
4025 TabContentsWrapper* wrapper = GetTabContentsWrapperAt( | 4033 TabContentsWrapper* wrapper = GetTabContentsWrapperAt( |
4026 tab_handler_->GetTabStripModel()->GetWrapperIndex(source)); | 4034 tab_handler_->GetTabStripModel()->GetWrapperIndex(source)); |
4027 ViewSource(wrapper); | 4035 ViewSource(wrapper); |
4028 } | 4036 } |
4029 | 4037 |
4030 void Browser::ViewSourceForFrame(WebContents* source, | 4038 void Browser::ViewSourceForFrame(WebContents* source, |
4031 const GURL& frame_url, | 4039 const GURL& frame_url, |
4032 const std::string& frame_content_state) { | 4040 const std::string& frame_content_state) { |
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5649 } else { | 5657 } else { |
5650 LoginUIServiceFactory::GetForProfile( | 5658 LoginUIServiceFactory::GetForProfile( |
5651 profile()->GetOriginalProfile())->ShowLoginUI(); | 5659 profile()->GetOriginalProfile())->ShowLoginUI(); |
5652 } | 5660 } |
5653 #endif | 5661 #endif |
5654 } | 5662 } |
5655 | 5663 |
5656 void Browser::ToggleSpeechInput() { | 5664 void Browser::ToggleSpeechInput() { |
5657 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); | 5665 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); |
5658 } | 5666 } |
OLD | NEW |