| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/interstitials/chrome_controller_client.h" | 5 #include "chrome/browser/interstitials/chrome_controller_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/process/launch.h" | 10 #include "base/process/launch.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "base/base_paths_win.h" | 34 #include "base/base_paths_win.h" |
| 35 #include "base/path_service.h" | 35 #include "base/path_service.h" |
| 36 #include "base/strings/string16.h" | 36 #include "base/strings/string16.h" |
| 37 #include "base/win/windows_version.h" | 37 #include "base/win/windows_version.h" |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 using content::Referrer; | 40 using content::Referrer; |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 void LaunchDateAndTimeSettingsOnFile() { | 44 #if !defined(OS_CHROMEOS) |
| 45 void LaunchDateAndTimeSettingsOnFileThread() { |
| 45 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 46 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| 46 // The code for each OS is completely separate, in order to avoid bugs like | 47 // The code for each OS is completely separate, in order to avoid bugs like |
| 47 // https://crbug.com/430877 . | 48 // https://crbug.com/430877 . ChromeOS is handled on the UI thread. |
| 48 #if defined(OS_ANDROID) | 49 #if defined(OS_ANDROID) |
| 49 chrome::android::OpenDateAndTimeSettings(); | 50 chrome::android::OpenDateAndTimeSettings(); |
| 50 | 51 |
| 51 #elif defined(OS_CHROMEOS) | |
| 52 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), | |
| 53 chrome::kDateTimeSubPage); | |
| 54 | |
| 55 #elif defined(OS_LINUX) | 52 #elif defined(OS_LINUX) |
| 56 struct ClockCommand { | 53 struct ClockCommand { |
| 57 const char* pathname; | 54 const char* const pathname; |
| 58 const char* argument; | 55 const char* const argument; |
| 59 }; | 56 }; |
| 60 static const ClockCommand kClockCommands[] = { | 57 static const ClockCommand kClockCommands[] = { |
| 61 // Unity | 58 // Unity |
| 62 {"/usr/bin/unity-control-center", "datetime"}, | 59 {"/usr/bin/unity-control-center", "datetime"}, |
| 63 // GNOME | 60 // GNOME |
| 64 // | 61 // |
| 65 // NOTE: On old Ubuntu, naming control panels doesn't work, so it | 62 // NOTE: On old Ubuntu, naming control panels doesn't work, so it |
| 66 // opens the overview. This will have to be good enough. | 63 // opens the overview. This will have to be good enough. |
| 67 {"/usr/bin/gnome-control-center", "datetime"}, | 64 {"/usr/bin/gnome-control-center", "datetime"}, |
| 68 {"/usr/local/bin/gnome-control-center", "datetime"}, | 65 {"/usr/local/bin/gnome-control-center", "datetime"}, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 base::LaunchOptions options; | 109 base::LaunchOptions options; |
| 113 options.wait = false; | 110 options.wait = false; |
| 114 base::LaunchProcess(command, options); | 111 base::LaunchProcess(command, options); |
| 115 | 112 |
| 116 #else | 113 #else |
| 117 NOTREACHED(); | 114 NOTREACHED(); |
| 118 | 115 |
| 119 #endif | 116 #endif |
| 120 // Don't add code here! (See the comment at the beginning of the function.) | 117 // Don't add code here! (See the comment at the beginning of the function.) |
| 121 } | 118 } |
| 119 #endif |
| 122 | 120 |
| 123 } // namespace | 121 } // namespace |
| 124 | 122 |
| 125 ChromeControllerClient::ChromeControllerClient( | 123 ChromeControllerClient::ChromeControllerClient( |
| 126 content::WebContents* web_contents, | 124 content::WebContents* web_contents, |
| 127 std::unique_ptr<security_interstitials::MetricsHelper> metrics_helper) | 125 std::unique_ptr<security_interstitials::MetricsHelper> metrics_helper) |
| 128 : ControllerClient(std::move(metrics_helper)), | 126 : ControllerClient(std::move(metrics_helper)), |
| 129 web_contents_(web_contents), | 127 web_contents_(web_contents), |
| 130 interstitial_page_(nullptr) {} | 128 interstitial_page_(nullptr) {} |
| 131 | 129 |
| 132 ChromeControllerClient::~ChromeControllerClient() {} | 130 ChromeControllerClient::~ChromeControllerClient() {} |
| 133 | 131 |
| 134 void ChromeControllerClient::set_interstitial_page( | 132 void ChromeControllerClient::set_interstitial_page( |
| 135 content::InterstitialPage* interstitial_page) { | 133 content::InterstitialPage* interstitial_page) { |
| 136 interstitial_page_ = interstitial_page; | 134 interstitial_page_ = interstitial_page; |
| 137 } | 135 } |
| 138 | 136 |
| 139 bool ChromeControllerClient::CanLaunchDateAndTimeSettings() { | 137 bool ChromeControllerClient::CanLaunchDateAndTimeSettings() { |
| 140 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_LINUX) || \ | 138 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_LINUX) || \ |
| 141 defined(OS_MACOSX) || defined(OS_WIN) | 139 defined(OS_MACOSX) || defined(OS_WIN) |
| 142 return true; | 140 return true; |
| 143 #else | 141 #else |
| 144 return false; | 142 return false; |
| 145 #endif | 143 #endif |
| 146 } | 144 } |
| 147 | 145 |
| 148 void ChromeControllerClient::LaunchDateAndTimeSettings() { | 146 void ChromeControllerClient::LaunchDateAndTimeSettings() { |
| 147 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 148 |
| 149 #if defined(OS_CHROMEOS) |
| 150 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), |
| 151 chrome::kDateTimeSubPage); |
| 152 #else |
| 149 content::BrowserThread::PostTask( | 153 content::BrowserThread::PostTask( |
| 150 content::BrowserThread::FILE, FROM_HERE, | 154 content::BrowserThread::FILE, FROM_HERE, |
| 151 base::Bind(&LaunchDateAndTimeSettingsOnFile)); | 155 base::Bind(&LaunchDateAndTimeSettingsOnFileThread)); |
| 156 #endif |
| 152 } | 157 } |
| 153 | 158 |
| 154 void ChromeControllerClient::GoBack() { | 159 void ChromeControllerClient::GoBack() { |
| 155 interstitial_page_->DontProceed(); | 160 interstitial_page_->DontProceed(); |
| 156 } | 161 } |
| 157 | 162 |
| 158 void ChromeControllerClient::Proceed() { | 163 void ChromeControllerClient::Proceed() { |
| 159 interstitial_page_->Proceed(); | 164 interstitial_page_->Proceed(); |
| 160 } | 165 } |
| 161 | 166 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 176 | 181 |
| 177 PrefService* ChromeControllerClient::GetPrefService() { | 182 PrefService* ChromeControllerClient::GetPrefService() { |
| 178 Profile* profile = | 183 Profile* profile = |
| 179 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 184 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
| 180 return profile->GetPrefs(); | 185 return profile->GetPrefs(); |
| 181 } | 186 } |
| 182 | 187 |
| 183 const std::string ChromeControllerClient::GetExtendedReportingPrefName() { | 188 const std::string ChromeControllerClient::GetExtendedReportingPrefName() { |
| 184 return safe_browsing::GetExtendedReportingPrefName(*GetPrefService()); | 189 return safe_browsing::GetExtendedReportingPrefName(*GetPrefService()); |
| 185 } | 190 } |
| OLD | NEW |