15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file.
45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_VIEW_H_
65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_VIEW_H_
75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <vector>
95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class PermissionBubbleRequest;
115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class PermissionBubbleManager;
125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// This class is the platform-independent interface through which the permission
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// bubble managers (which are one per tab) communicate to the UI surface.
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// When the visible tab changes, the UI code must provide an object of this type
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// to the manager for the visible tab.
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class PermissionBubbleView {
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public:
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The delegate will receive events caused by user action which need to
205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // be persisted in the per-tab UI state.
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  class Delegate {
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)   public:
23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    virtual ~Delegate() {}
24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    virtual void ToggleAccept(int index, bool new_value) = 0;
265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    virtual void SetCustomizationMode() = 0;
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    virtual void Accept() = 0;
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    virtual void Deny() = 0;
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    virtual void Closing() = 0;
30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    virtual void SetView(PermissionBubbleView* view) = 0;
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  };
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  virtual ~PermissionBubbleView() {}
34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Sets the delegate which will receive UI events forwarded from the bubble.
365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void SetDelegate(Delegate* delegate) = 0;
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Causes the bubble to show up with the given contents. This method may be
39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // called with mostly-identical contents to the existing contents. This can
40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // happen, for instance, if a new permission is requested and
41a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // CanAcceptRequestUpdate() is true.
42010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // Important: the view must not store any of the request objects it receives
43010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // in this call.
445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void Show(
455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const std::vector<PermissionBubbleRequest*>& requests,
465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const std::vector<bool>& accept_state,
47a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      bool customization_mode) = 0;
48a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Returns true if the view can accept a new Show() command to coalesce
50a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // requests. Currently the policy is that this should return true if the view
51a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // is being shown and the mouse is not over the view area (!IsMouseHovered).
52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  virtual bool CanAcceptRequestUpdate() = 0;
535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Hides the permission bubble.
555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void Hide() = 0;
565f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
575f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Returns true if there is a bubble currently showing.
585f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual bool IsVisible() = 0;
595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)};
605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif  // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_VIEW_H_
62