Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / renderer_context_menu / context_menu_delegate.cc
blob4a03b41a025487a3fc7d280d232b01637dcc9ed3
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/renderer_context_menu/context_menu_delegate.h"
7 #include "content/public/browser/web_contents.h"
9 namespace {
11 const char kMenuDelegateUserDataKey[] = "RendererContextMenuMenuDelegate";
13 class ContextMenuDelegateUserData : public base::SupportsUserData::Data {
14 public:
15 explicit ContextMenuDelegateUserData(ContextMenuDelegate* menu_delegate)
16 : menu_delegate_(menu_delegate) {
18 virtual ~ContextMenuDelegateUserData() {}
19 ContextMenuDelegate* menu_delegate() { return menu_delegate_; }
21 private:
22 ContextMenuDelegate* menu_delegate_; // not owned by us.
25 } // namespace
27 ContextMenuDelegate::ContextMenuDelegate(content::WebContents* web_contents) {
28 web_contents->SetUserData(&kMenuDelegateUserDataKey,
29 new ContextMenuDelegateUserData(this));
32 ContextMenuDelegate::~ContextMenuDelegate() {
35 // static
36 ContextMenuDelegate* ContextMenuDelegate::FromWebContents(
37 content::WebContents* web_contents) {
38 ContextMenuDelegateUserData* user_data =
39 static_cast<ContextMenuDelegateUserData*>(
40 web_contents->GetUserData(&kMenuDelegateUserDataKey));
41 return user_data ? user_data->menu_delegate() : NULL;