Chromium Code Reviews| 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" | |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 14 #include "chrome/browser/download/download_shelf.h" | 15 #include "chrome/browser/download/download_shelf.h" |
| 15 #include "chrome/browser/extensions/launch_util.h" | 16 #include "chrome/browser/extensions/launch_util.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
| 20 #include "chrome/browser/ui/browser_navigator_params.h" | 21 #include "chrome/browser/ui/browser_navigator_params.h" |
| 21 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 22 #include "chrome/browser/ui/extensions/app_launch_params.h" | 23 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 23 #include "chrome/browser/ui/extensions/application_launch.h" | 24 #include "chrome/browser/ui/extensions/application_launch.h" |
| 24 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 25 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 25 #include "chrome/browser/ui/settings_window_manager.h" | 26 #include "chrome/browser/ui/settings_window_manager.h" |
| 26 #include "chrome/browser/ui/singleton_tabs.h" | 27 #include "chrome/browser/ui/singleton_tabs.h" |
| 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 28 #include "chrome/browser/ui/webui/options/content_settings_handler.h" | 29 #include "chrome/browser/ui/webui/options/content_settings_handler.h" |
| 29 #include "chrome/browser/ui/webui/site_settings_helper.h" | 30 #include "chrome/browser/ui/webui/site_settings_helper.h" |
| 31 #include "chrome/common/chrome_features.h" | |
| 30 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 31 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 32 #include "components/signin/core/browser/signin_header_helper.h" | 34 #include "components/signin/core/browser/signin_header_helper.h" |
| 33 #include "components/signin/core/common/profile_management_switches.h" | 35 #include "components/signin/core/common/profile_management_switches.h" |
| 34 #include "content/public/browser/user_metrics.h" | 36 #include "content/public/browser/user_metrics.h" |
| 35 #include "content/public/browser/web_contents.h" | 37 #include "content/public/browser/web_contents.h" |
| 36 #include "extensions/browser/extension_prefs.h" | 38 #include "extensions/browser/extension_prefs.h" |
| 37 #include "extensions/common/constants.h" | 39 #include "extensions/common/constants.h" |
| 38 #include "google_apis/gaia/gaia_urls.h" | 40 #include "google_apis/gaia/gaia_urls.h" |
| 39 #include "net/base/url_util.h" | 41 #include "net/base/url_util.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 } | 128 } |
| 127 std::unique_ptr<ScopedTabbedBrowserDisplayer> displayer; | 129 std::unique_ptr<ScopedTabbedBrowserDisplayer> displayer; |
| 128 if (!browser) { | 130 if (!browser) { |
| 129 displayer.reset(new ScopedTabbedBrowserDisplayer(profile)); | 131 displayer.reset(new ScopedTabbedBrowserDisplayer(profile)); |
| 130 browser = displayer->browser(); | 132 browser = displayer->browser(); |
| 131 } | 133 } |
| 132 ShowSingletonTab(browser, url); | 134 ShowSingletonTab(browser, url); |
| 133 #endif | 135 #endif |
| 134 } | 136 } |
| 135 | 137 |
| 138 // This list overrides the group names defined in site_settings_helper for the | |
| 139 // purposes of URL generation for MD Settings only. We need this because some | |
| 140 // of the old group names are no longer appropriate: i.e. "plugins" => "flash". | |
| 141 // | |
| 142 // TODO(tommycli): Update the group names defined in site_settings_helper once | |
| 143 // Options is removed from Chrome. Then this list will no longer be needed. | |
| 144 const site_settings::ContentSettingsTypeNameEntry | |
|
Peter Kasting
2016/10/28 21:13:34
Nit: Scope this kind of a constant inside the func
tommycli
2016/10/28 21:57:13
Done.
| |
| 145 kSettingsContentTypePathOverrides[] = { | |
|
Dan Beam
2016/10/27 23:44:41
why are these "Override"s?
tommycli
2016/10/28 00:01:24
They override the group names that have been used
| |
| 146 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "automaticDownloads"}, | |
| 147 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, "backgroundSync"}, | |
| 148 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "microphone"}, | |
| 149 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, "camera"}, | |
| 150 {CONTENT_SETTINGS_TYPE_PLUGINS, "flash"}, | |
| 151 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, "unsandboxedPlugins"}, | |
| 152 }; | |
| 153 | |
| 136 std::string GenerateContentSettingsExceptionsSubPage(ContentSettingsType type) { | 154 std::string GenerateContentSettingsExceptionsSubPage(ContentSettingsType type) { |
| 137 return kContentSettingsExceptionsSubPage + std::string(kHashMark) + | 155 if (base::FeatureList::IsEnabled(features::kMaterialDesignSettings)) { |
|
Peter Kasting
2016/10/28 21:13:34
Nit: If you reverse this condition, the body effec
tommycli
2016/10/28 21:57:13
Done.
| |
| 138 site_settings::ContentSettingsTypeToGroupName(type); | 156 // In MD Settings, the exceptions no longer have a separate subpage. |
| 157 std::string content_type_path = | |
| 158 site_settings::ContentSettingsTypeToGroupName(type); | |
| 159 for (size_t i = 0; i < arraysize(kSettingsContentTypePathOverrides); ++i) { | |
|
Peter Kasting
2016/10/28 21:13:34
Nit: Personally I would find it more intuitive her
tommycli
2016/10/28 21:57:13
Done.
| |
| 160 if (type == kSettingsContentTypePathOverrides[i].type) | |
| 161 content_type_path = kSettingsContentTypePathOverrides[i].name; | |
| 162 } | |
| 163 | |
| 164 return std::string(kContentSettingsSubPage) + "/" + content_type_path; | |
| 165 } else { | |
|
Peter Kasting
2016/10/28 21:13:34
Nit: No else after return.
tommycli
2016/10/28 21:57:13
Done.
| |
| 166 return kDeprecatedOptionsContentSettingsExceptionsSubPage + | |
| 167 std::string(kHashMark) + | |
| 168 site_settings::ContentSettingsTypeToGroupName(type); | |
| 169 } | |
| 139 } | 170 } |
| 140 | 171 |
| 141 } // namespace | 172 } // namespace |
| 142 | 173 |
| 143 void ShowBookmarkManager(Browser* browser) { | 174 void ShowBookmarkManager(Browser* browser) { |
| 144 content::RecordAction(UserMetricsAction("ShowBookmarkManager")); | 175 content::RecordAction(UserMetricsAction("ShowBookmarkManager")); |
| 145 content::RecordAction(UserMetricsAction("ShowBookmarks")); | 176 content::RecordAction(UserMetricsAction("ShowBookmarks")); |
| 146 ShowSingletonTabOverwritingNTP( | 177 ShowSingletonTabOverwritingNTP( |
| 147 browser, | 178 browser, |
| 148 GetSingletonTabNavigateParams(browser, GURL(kChromeUIBookmarksURL))); | 179 GetSingletonTabNavigateParams(browser, GURL(kChromeUIBookmarksURL))); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 SigninManagerFactory::GetForProfile(original_profile); | 427 SigninManagerFactory::GetForProfile(original_profile); |
| 397 DCHECK(manager->IsSigninAllowed()); | 428 DCHECK(manager->IsSigninAllowed()); |
| 398 if (manager->IsAuthenticated()) | 429 if (manager->IsAuthenticated()) |
| 399 ShowSettings(browser); | 430 ShowSettings(browser); |
| 400 else | 431 else |
| 401 ShowBrowserSignin(browser, access_point); | 432 ShowBrowserSignin(browser, access_point); |
| 402 } | 433 } |
| 403 #endif | 434 #endif |
| 404 | 435 |
| 405 } // namespace chrome | 436 } // namespace chrome |
| OLD | NEW |