| 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/chrome_pages.h" | 5 #include "chrome/browser/ui/chrome_pages.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" | |
| 11 #include "base/logging.h" | 10 #include "base/logging.h" |
| 12 #include "base/macros.h" | 11 #include "base/macros.h" |
| 13 #include "base/metrics/user_metrics.h" | 12 #include "base/metrics/user_metrics.h" |
| 14 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 16 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 17 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 18 #include "chrome/browser/download/download_shelf.h" | 17 #include "chrome/browser/download/download_shelf.h" |
| 19 #include "chrome/browser/extensions/launch_util.h" | 18 #include "chrome/browser/extensions/launch_util.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
| 22 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_finder.h" | 22 #include "chrome/browser/ui/browser_finder.h" |
| 24 #include "chrome/browser/ui/browser_navigator_params.h" | 23 #include "chrome/browser/ui/browser_navigator_params.h" |
| 25 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
| 26 #include "chrome/browser/ui/extensions/app_launch_params.h" | 25 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 27 #include "chrome/browser/ui/extensions/application_launch.h" | 26 #include "chrome/browser/ui/extensions/application_launch.h" |
| 28 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 27 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 29 #include "chrome/browser/ui/settings_window_manager.h" | 28 #include "chrome/browser/ui/settings_window_manager.h" |
| 30 #include "chrome/browser/ui/singleton_tabs.h" | 29 #include "chrome/browser/ui/singleton_tabs.h" |
| 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 32 #include "chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.h" | 31 #include "chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.h" |
| 33 #include "chrome/browser/ui/webui/options/content_settings_handler.h" | 32 #include "chrome/browser/ui/webui/options/content_settings_handler.h" |
| 34 #include "chrome/browser/ui/webui/site_settings_helper.h" | 33 #include "chrome/browser/ui/webui/site_settings_helper.h" |
| 35 #include "chrome/common/chrome_features.h" | |
| 36 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| 37 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
| 38 #include "components/bookmarks/browser/bookmark_model.h" | 36 #include "components/bookmarks/browser/bookmark_model.h" |
| 39 #include "components/bookmarks/browser/bookmark_node.h" | 37 #include "components/bookmarks/browser/bookmark_node.h" |
| 40 #include "components/signin/core/browser/signin_header_helper.h" | 38 #include "components/signin/core/browser/signin_header_helper.h" |
| 41 #include "components/signin/core/common/profile_management_switches.h" | 39 #include "components/signin/core/common/profile_management_switches.h" |
| 42 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
| 43 #include "extensions/browser/extension_prefs.h" | 41 #include "extensions/browser/extension_prefs.h" |
| 44 #include "extensions/common/constants.h" | 42 #include "extensions/common/constants.h" |
| 45 #include "google_apis/gaia/gaia_urls.h" | 43 #include "google_apis/gaia/gaia_urls.h" |
| 46 #include "net/base/url_util.h" | 44 #include "net/base/url_util.h" |
| 47 #include "ui/base/window_open_disposition.h" | 45 #include "ui/base/window_open_disposition.h" |
| 48 | 46 |
| 49 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
| 50 #include "chrome/browser/win/enumerate_modules_model.h" | 48 #include "chrome/browser/win/enumerate_modules_model.h" |
| 51 #endif | 49 #endif |
| 52 | 50 |
| 53 #if defined(OS_CHROMEOS) | 51 #if defined(OS_CHROMEOS) |
| 54 #include "base/feature_list.h" | |
| 55 #include "chrome/browser/chromeos/genius_app/app_id.h" | 52 #include "chrome/browser/chromeos/genius_app/app_id.h" |
| 56 #include "chrome/common/chrome_features.h" | |
| 57 #include "chrome/grit/generated_resources.h" | 53 #include "chrome/grit/generated_resources.h" |
| 58 #include "extensions/browser/extension_registry.h" | 54 #include "extensions/browser/extension_registry.h" |
| 59 #include "ui/base/l10n/l10n_util.h" | 55 #include "ui/base/l10n/l10n_util.h" |
| 60 #endif | 56 #endif |
| 61 | 57 |
| 62 #if !defined(OS_ANDROID) | 58 #if !defined(OS_ANDROID) |
| 63 #include "chrome/browser/signin/signin_manager_factory.h" | 59 #include "chrome/browser/signin/signin_manager_factory.h" |
| 64 #include "components/signin/core/browser/signin_manager.h" | 60 #include "components/signin/core/browser/signin_manager.h" |
| 65 #endif | 61 #endif |
| 66 | 62 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 std::unique_ptr<ScopedTabbedBrowserDisplayer> displayer; | 131 std::unique_ptr<ScopedTabbedBrowserDisplayer> displayer; |
| 136 if (!browser) { | 132 if (!browser) { |
| 137 displayer.reset(new ScopedTabbedBrowserDisplayer(profile)); | 133 displayer.reset(new ScopedTabbedBrowserDisplayer(profile)); |
| 138 browser = displayer->browser(); | 134 browser = displayer->browser(); |
| 139 } | 135 } |
| 140 ShowSingletonTab(browser, url); | 136 ShowSingletonTab(browser, url); |
| 141 #endif | 137 #endif |
| 142 } | 138 } |
| 143 | 139 |
| 144 std::string GenerateContentSettingsExceptionsSubPage(ContentSettingsType type) { | 140 std::string GenerateContentSettingsExceptionsSubPage(ContentSettingsType type) { |
| 145 if (!base::FeatureList::IsEnabled(features::kMaterialDesignSettings)) { | |
| 146 return kDeprecatedOptionsContentSettingsExceptionsSubPage + | |
| 147 std::string(kHashMark) + | |
| 148 site_settings::ContentSettingsTypeToGroupName(type); | |
| 149 } | |
| 150 | |
| 151 // In MD Settings, the exceptions no longer have a separate subpage. | 141 // In MD Settings, the exceptions no longer have a separate subpage. |
| 152 // This list overrides the group names defined in site_settings_helper for the | 142 // This list overrides the group names defined in site_settings_helper for the |
| 153 // purposes of URL generation for MD Settings only. We need this because some | 143 // purposes of URL generation for MD Settings only. We need this because some |
| 154 // of the old group names are no longer appropriate: i.e. "plugins" => | 144 // of the old group names are no longer appropriate: i.e. "plugins" => |
| 155 // "flash". | 145 // "flash". |
| 156 // | 146 // |
| 157 // TODO(tommycli): Update the group names defined in site_settings_helper once | 147 // TODO(crbug.com/728353): Update the group names defined in |
| 158 // Options is removed from Chrome. Then this list will no longer be needed. | 148 // site_settings_helper once Options is removed from Chrome. Then this list |
| 149 // will no longer be needed. |
| 159 typedef std::map<ContentSettingsType, std::string> ContentSettingPathMap; | 150 typedef std::map<ContentSettingsType, std::string> ContentSettingPathMap; |
| 160 CR_DEFINE_STATIC_LOCAL( | 151 CR_DEFINE_STATIC_LOCAL( |
| 161 ContentSettingPathMap, kSettingsPathOverrides, | 152 ContentSettingPathMap, kSettingsPathOverrides, |
| 162 ({{CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "automaticDownloads"}, | 153 ({{CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "automaticDownloads"}, |
| 163 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, "backgroundSync"}, | 154 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, "backgroundSync"}, |
| 164 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "microphone"}, | 155 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "microphone"}, |
| 165 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, "camera"}, | 156 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, "camera"}, |
| 166 {CONTENT_SETTINGS_TYPE_PLUGINS, "flash"}, | 157 {CONTENT_SETTINGS_TYPE_PLUGINS, "flash"}, |
| 167 {CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER, "subresourceFilter"}, | 158 {CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER, "subresourceFilter"}, |
| 168 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, "unsandboxedPlugins"}})); | 159 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, "unsandboxedPlugins"}})); |
| 169 const auto it = kSettingsPathOverrides.find(type); | 160 const auto it = kSettingsPathOverrides.find(type); |
| 170 const std::string content_type_path = | 161 const std::string content_type_path = |
| 171 (it == kSettingsPathOverrides.end()) | 162 (it == kSettingsPathOverrides.end()) |
| 172 ? site_settings::ContentSettingsTypeToGroupName(type) | 163 ? site_settings::ContentSettingsTypeToGroupName(type) |
| 173 : it->second; | 164 : it->second; |
| 174 | 165 |
| 175 return std::string(kContentSettingsSubPage) + "/" + content_type_path; | 166 return std::string(kContentSettingsSubPage) + "/" + content_type_path; |
| 176 } | 167 } |
| 177 | 168 |
| 178 #if defined(OS_CHROMEOS) | |
| 179 std::string GenerateContentSettingsSearchQueryPath(int query_message_id) { | |
| 180 return std::string(chrome::kDeprecatedOptionsSearchSubPage) + kHashMark + | |
| 181 l10n_util::GetStringUTF8(query_message_id); | |
| 182 } | |
| 183 #endif | |
| 184 | |
| 185 } // namespace | 169 } // namespace |
| 186 | 170 |
| 187 void ShowBookmarkManager(Browser* browser) { | 171 void ShowBookmarkManager(Browser* browser) { |
| 188 base::RecordAction(UserMetricsAction("ShowBookmarkManager")); | 172 base::RecordAction(UserMetricsAction("ShowBookmarkManager")); |
| 189 if (MdBookmarksUI::IsEnabled()) { | 173 if (MdBookmarksUI::IsEnabled()) { |
| 190 const bookmarks::BookmarkNode* bookmark_bar_node = | 174 const bookmarks::BookmarkNode* bookmark_bar_node = |
| 191 BookmarkModelFactory::GetForBrowserContext(browser->profile()) | 175 BookmarkModelFactory::GetForBrowserContext(browser->profile()) |
| 192 ->bookmark_bar_node(); | 176 ->bookmark_bar_node(); |
| 193 OpenBookmarkManagerForNode(browser, bookmark_bar_node->id()); | 177 OpenBookmarkManagerForNode(browser, bookmark_bar_node->id()); |
| 194 return; | 178 return; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 ShowSettingsSubPageForProfile(browser->profile(), sub_page); | 294 ShowSettingsSubPageForProfile(browser->profile(), sub_page); |
| 311 return; | 295 return; |
| 312 } | 296 } |
| 313 ShowSettingsSubPageInTabbedBrowser(browser, sub_page); | 297 ShowSettingsSubPageInTabbedBrowser(browser, sub_page); |
| 314 } | 298 } |
| 315 | 299 |
| 316 void ShowSettingsSubPageForProfile(Profile* profile, | 300 void ShowSettingsSubPageForProfile(Profile* profile, |
| 317 const std::string& sub_page) { | 301 const std::string& sub_page) { |
| 318 std::string sub_page_path = sub_page; | 302 std::string sub_page_path = sub_page; |
| 319 | 303 |
| 320 #if defined(OS_CHROMEOS) | |
| 321 if (!base::FeatureList::IsEnabled(features::kMaterialDesignSettings)) { | |
| 322 if (sub_page == chrome::kAccessibilitySubPage) { | |
| 323 sub_page_path = GenerateContentSettingsSearchQueryPath( | |
| 324 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY); | |
| 325 } else if (sub_page == chrome::kBluetoothSubPage) { | |
| 326 sub_page_path = GenerateContentSettingsSearchQueryPath( | |
| 327 IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH); | |
| 328 } else if (sub_page == chrome::kDateTimeSubPage) { | |
| 329 sub_page_path = GenerateContentSettingsSearchQueryPath( | |
| 330 IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME); | |
| 331 } else if (sub_page == chrome::kStylusSubPage || | |
| 332 sub_page == chrome::kPowerSubPage) { | |
| 333 sub_page_path += "-overlay"; | |
| 334 } | |
| 335 } | |
| 336 #endif | |
| 337 | |
| 338 if (::switches::SettingsWindowEnabled()) { | 304 if (::switches::SettingsWindowEnabled()) { |
| 339 base::RecordAction(base::UserMetricsAction("ShowOptions")); | 305 base::RecordAction(base::UserMetricsAction("ShowOptions")); |
| 340 SettingsWindowManager::GetInstance()->ShowChromePageForProfile( | 306 SettingsWindowManager::GetInstance()->ShowChromePageForProfile( |
| 341 profile, GetSettingsUrl(sub_page_path)); | 307 profile, GetSettingsUrl(sub_page_path)); |
| 342 return; | 308 return; |
| 343 } | 309 } |
| 344 Browser* browser = chrome::FindTabbedBrowser(profile, false); | 310 Browser* browser = chrome::FindTabbedBrowser(profile, false); |
| 345 if (!browser) { | 311 if (!browser) { |
| 346 browser = new Browser(Browser::CreateParams(profile, true)); | 312 browser = new Browser(Browser::CreateParams(profile, true)); |
| 347 } | 313 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 SigninManagerFactory::GetForProfile(original_profile); | 429 SigninManagerFactory::GetForProfile(original_profile); |
| 464 DCHECK(manager->IsSigninAllowed()); | 430 DCHECK(manager->IsSigninAllowed()); |
| 465 if (manager->IsAuthenticated()) | 431 if (manager->IsAuthenticated()) |
| 466 ShowSettings(browser); | 432 ShowSettings(browser); |
| 467 else | 433 else |
| 468 ShowBrowserSignin(browser, access_point); | 434 ShowBrowserSignin(browser, access_point); |
| 469 } | 435 } |
| 470 #endif | 436 #endif |
| 471 | 437 |
| 472 } // namespace chrome | 438 } // namespace chrome |
| OLD | NEW |