Clarify documentation on difference between WebContentsObserver and WebContentsDelegate.

Also move a method out of WebContentsObserver that shouldn't be on it as it changes state.

Change-Id: If587104a0aef3fe68f16492ae46cdd3c83058777
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2737784
Commit-Queue: John Abd-El-Malek <[email protected]>
Auto-Submit: John Abd-El-Malek <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#860356}
diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h
index e752b5bd..2640715 100644
--- a/content/public/browser/web_contents_delegate.h
+++ b/content/public/browser/web_contents_delegate.h
@@ -112,7 +112,11 @@
 };
 
 // Objects implement this interface to get notified about changes in the
-// WebContents and to provide necessary functionality.
+// WebContents and to provide necessary functionality. If a method doesn't
+// change state, e.g. has no return value, then it can move to
+// WebContentsObserver if many places want to observe the change. If the
+// implementation of one of the methods below would be shared by many or all of
+// WebContentsDelegate implementations then it can go on ContentBrowserClient.
 class CONTENT_EXPORT WebContentsDelegate {
  public:
   WebContentsDelegate();
diff --git a/content/public/browser/web_contents_observer.cc b/content/public/browser/web_contents_observer.cc
index 172bd71..b6754c23 100644
--- a/content/public/browser/web_contents_observer.cc
+++ b/content/public/browser/web_contents_observer.cc
@@ -43,19 +43,6 @@
   return false;
 }
 
-bool WebContentsObserver::ShowPopupMenu(
-    RenderFrameHost* render_frame_host,
-    mojo::PendingRemote<blink::mojom::PopupMenuClient>* popup_client,
-    const gfx::Rect& bounds,
-    int32_t item_height,
-    double font_size,
-    int32_t selected_item,
-    std::vector<blink::mojom::MenuItemPtr>* menu_items,
-    bool right_aligned,
-    bool allow_multiple_selection) {
-  return false;
-}
-
 bool WebContentsObserver::OnMessageReceived(const IPC::Message& message) {
   return false;
 }
diff --git a/content/public/browser/web_contents_observer.h b/content/public/browser/web_contents_observer.h
index d9e4448..ecc02ba 100644
--- a/content/public/browser/web_contents_observer.h
+++ b/content/public/browser/web_contents_observer.h
@@ -25,7 +25,6 @@
 #include "services/service_manager/public/cpp/bind_source_info.h"
 #include "third_party/blink/public/common/input/web_input_event.h"
 #include "third_party/blink/public/common/user_agent/user_agent_metadata.h"
-#include "third_party/blink/public/mojom/choosers/popup_menu.mojom.h"
 #include "third_party/blink/public/mojom/devtools/console_message.mojom.h"
 #include "third_party/blink/public/mojom/loader/resource_load_info.mojom-forward.h"
 #include "third_party/skia/include/core/SkColor.h"
@@ -61,7 +60,10 @@
 struct Referrer;
 
 // An observer API implemented by classes which are interested in various page
-// load events from WebContents.  They also get a chance to filter IPC messages.
+// events from WebContents.  They also get a chance to filter IPC messages.
+// The difference between WebContentsDelegate (WCD) and WebContentsObserver
+// (WCO) is that there is one WCD per WebContents and many WCOs. Methods which
+// have a return value, e.g. are expected to change state, should be on WCD.
 //
 // Since a WebContents can be a delegate to almost arbitrarily many
 // RenderViewHosts, it is important to check in those WebContentsObserver
@@ -653,17 +655,6 @@
   virtual void OnServiceWorkerAccessed(NavigationHandle* navigation_handle,
                                        const GURL& scope,
                                        AllowServiceWorkerResult allowed) {}
-  virtual bool ShowPopupMenu(
-      RenderFrameHost* render_frame_host,
-      mojo::PendingRemote<blink::mojom::PopupMenuClient>* popup_client,
-      const gfx::Rect& bounds,
-      int32_t item_height,
-      double font_size,
-      int32_t selected_item,
-      std::vector<blink::mojom::MenuItemPtr>* menu_items,
-      bool right_aligned,
-      bool allow_multiple_selection);
-
   // IPC::Listener implementation.
   // DEPRECATED: Use (i.e. override) the other overload instead:
   //     virtual bool OnMessageReceived(const IPC::Message& message,