Support generation of flag attribute in java_cpp_enum.py

RefreshType in task_manager_observer.h is a real example of the enums
needing this handling. Unless we generate it with the flag attribute,
we can't concatenate the constants with `|`, seeing the error like this:

```
../../chrome/browser/task_manager/internal/android/java/src/org/chromium/chrome/browser/task_manager/TaskManagerActivity.java:32: Error: Flag not allowed here [WrongConstant]
                        observer, REFRESH_TIME_MS, RefreshType.MEMORY_FOOTPRINT | RefreshType.CPU);
```

Bug: 353596679
Change-Id: I382678b39dd9ff85e619cc1881eb087b463d22bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6034170
Auto-Submit: Keigo Oka <[email protected]>
Commit-Queue: Andrew Grieve <[email protected]>
Reviewed-by: Andrew Grieve <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1384981}
diff --git a/docs/android_accessing_cpp_enums_in_java.md b/docs/android_accessing_cpp_enums_in_java.md
index b49f97e0..668160ae 100644
--- a/docs/android_accessing_cpp_enums_in_java.md
+++ b/docs/android_accessing_cpp_enums_in_java.md
@@ -20,6 +20,7 @@
 the `GENERATED_JAVA_PREFIX_TO_STRIP` directive (optional)
 * Follows best practices by using
 [IntDef Instead of Enum](/styleguide/java/java.md#IntDef-Instead-of-Enum)
+* Generate the `flag` attribute using the `GENERATED_JAVA_IS_FLAG` directive (optional)
 * Copies comments that directly precede enum entries into the generated Java
 class
 
@@ -32,9 +33,10 @@
     // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome
     // GENERATED_JAVA_CLASS_NAME_OVERRIDE: FooBar
     // GENERATED_JAVA_PREFIX_TO_STRIP: BAR_
+    // GENERATED_JAVA_IS_FLAG: true
     enum SomeEnum {
-      BAR_A,
-      BAR_B,
+      BAR_A = 1 << 0,
+      BAR_B = 1 << 1,
       BAR_C = BAR_B,
     };
     ```
@@ -80,14 +82,14 @@
     import java.lang.annotation.Retention;
     import java.lang.annotation.RetentionPolicy;
 
-    @IntDef({
+    @IntDef(flag = true, value = {
         FooBar.A, FooBar.B, FooBar.C
     })
     @Retention(RetentionPolicy.SOURCE)
     public @interface FooBar {
-      int A = 0;
-      int B = 1;
-      int C = 1;
+      int A = 1 << 0;
+      int B = 1 << 1;
+      int C = 1 << 1;
     }
     ```