Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Unified Diff: chrome/browser/about_flags.cc

Issue 16770002: Restart Chrome if per session flags have been specified on ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to ToT and addressed Nico's comments. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/about_flags.cc
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 834073d9bebb9d6d4f70b67fcb8cb5b73b067f8a..a8ea0b07db61c9a643d6efc767daeeaf1b9b5b2f 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -38,6 +38,7 @@
#if defined(OS_CHROMEOS)
#include "chromeos/chromeos_switches.h"
+#include "third_party/cros_system_api/switches/chrome_switches.h"
#endif
using content::UserMetricsAction;
@@ -83,6 +84,39 @@ void AddOsStrings(unsigned bitmask, ListValue* list) {
list->Append(new StringValue(kBitsToOs[i].name));
}
+// Convert switch constants to proper CommandLine::StringType strings.
+CommandLine::StringType GetSwitchString(const std::string& flag) {
+ CommandLine cmd_line(CommandLine::NO_PROGRAM);
+ cmd_line.AppendSwitch(flag);
+ DCHECK(cmd_line.argv().size() == 2);
+ return cmd_line.argv()[1];
+}
+
+// Scoops flags from a command line.
+std::set<CommandLine::StringType> ExtractFlagsFromCommandLine(
+ const CommandLine& cmdline) {
+ std::set<CommandLine::StringType> flags;
+ // First do the ones between --flag-switches-begin and --flag-switches-end.
+ CommandLine::StringVector::const_iterator first =
+ std::find(cmdline.argv().begin(), cmdline.argv().end(),
+ GetSwitchString(switches::kFlagSwitchesBegin));
+ CommandLine::StringVector::const_iterator last =
+ std::find(cmdline.argv().begin(), cmdline.argv().end(),
+ GetSwitchString(switches::kFlagSwitchesEnd));
+ if (first != cmdline.argv().end() && last != cmdline.argv().end())
+ flags.insert(first + 1, last);
+#if defined(OS_CHROMEOS)
+ // Then add those between --policy-switches-begin and --policy-switches-end.
+ first = std::find(cmdline.argv().begin(), cmdline.argv().end(),
+ GetSwitchString(chromeos::switches::kPolicySwitchesBegin));
+ last = std::find(cmdline.argv().begin(), cmdline.argv().end(),
+ GetSwitchString(chromeos::switches::kPolicySwitchesEnd));
+ if (first != cmdline.argv().end() && last != cmdline.argv().end())
+ flags.insert(first + 1, last);
+#endif
+ return flags;
+}
+
const Experiment::Choice
kOmniboxHistoryQuickProviderReorderForInliningChoices[] = {
{ IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_AUTOMATIC,
@@ -1726,6 +1760,20 @@ void ConvertFlagsToSwitches(FlagsStorage* flags_storage,
command_line);
}
+bool AreSwitchesIdenticalToCurrentCommandLine(
+ const CommandLine& new_cmdline, const CommandLine& active_cmdline) {
+ std::set<CommandLine::StringType> new_flags =
+ ExtractFlagsFromCommandLine(new_cmdline);
+ std::set<CommandLine::StringType> active_flags =
+ ExtractFlagsFromCommandLine(active_cmdline);
+
+ // Needed because std::equal doesn't check if the 2nd set is empty.
+ if (new_flags.size() != active_flags.size())
+ return false;
+
+ return std::equal(new_flags.begin(), new_flags.end(), active_flags.begin());
+}
+
void GetFlagsExperimentsData(FlagsStorage* flags_storage,
FlagAccess access,
base::ListValue* supported_experiments,

Powered by Google App Engine
This is Rietveld 408576698