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

Side by Side Diff: chrome/browser/ui/permission_bubble/permission_prompt.h

Issue 2868783002: Move requests from Show() argument to PermissionPrompt::Delegate (Closed)
Patch Set: tweak comment Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_PROMPT_H_ 5 #ifndef CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_PROMPT_H_
6 #define CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_PROMPT_H_ 6 #define CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_PROMPT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 11 matching lines...) Expand all
22 // When the visible tab changes, the UI code must provide an object of this type 22 // When the visible tab changes, the UI code must provide an object of this type
23 // to the manager for the visible tab. 23 // to the manager for the visible tab.
24 class PermissionPrompt { 24 class PermissionPrompt {
25 public: 25 public:
26 // The delegate will receive events caused by user action which need to 26 // The delegate will receive events caused by user action which need to
27 // be persisted in the per-tab UI state. 27 // be persisted in the per-tab UI state.
28 class Delegate { 28 class Delegate {
29 public: 29 public:
30 virtual ~Delegate() {} 30 virtual ~Delegate() {}
31 31
32 // These pointers should not be stored as the actual request objects may be
33 // deleted upon navigation and so on.
34 virtual const std::vector<PermissionRequest*>& Requests() = 0;
35 virtual const std::vector<bool>& AcceptStates() = 0;
36
32 virtual void ToggleAccept(int index, bool new_value) = 0; 37 virtual void ToggleAccept(int index, bool new_value) = 0;
33 virtual void TogglePersist(bool new_value) = 0; 38 virtual void TogglePersist(bool new_value) = 0;
34 virtual void Accept() = 0; 39 virtual void Accept() = 0;
35 virtual void Deny() = 0; 40 virtual void Deny() = 0;
36 virtual void Closing() = 0; 41 virtual void Closing() = 0;
37 }; 42 };
38 43
39 typedef base::Callback<std::unique_ptr<PermissionPrompt>( 44 typedef base::Callback<std::unique_ptr<PermissionPrompt>(
40 content::WebContents*)> 45 content::WebContents*)>
41 Factory; 46 Factory;
42 47
43 // Create a platform specific instance. 48 // Create a platform specific instance.
44 static std::unique_ptr<PermissionPrompt> Create( 49 static std::unique_ptr<PermissionPrompt> Create(
45 content::WebContents* web_contents); 50 content::WebContents* web_contents);
46 virtual ~PermissionPrompt() {} 51 virtual ~PermissionPrompt() {}
47 52
48 // Sets the delegate which will receive UI events forwarded from the prompt. 53 // Sets the delegate which will receive UI events forwarded from the prompt.
49 virtual void SetDelegate(Delegate* delegate) = 0; 54 virtual void SetDelegate(Delegate* delegate) = 0;
50 55
51 // Causes the request UI to show up with the given contents. This method may 56 // Show a prompt with the requests from the delegate. This will only be called
52 // be called with mostly-identical contents to the existing contents. This can 57 // if there is no prompt showing.
53 // happen, for instance, if a new permission is requested and 58 virtual void Show() = 0;
54 // CanAcceptRequestUpdate() is true.
55 // Important: the view must not store any of the request objects it receives
56 // in this call.
57 virtual void Show(const std::vector<PermissionRequest*>& requests,
58 const std::vector<bool>& accept_state) = 0;
59 59
60 // Returns true if the view can accept a new Show() command to coalesce 60 // Returns true if the view can accept a new Show() command to coalesce
61 // requests. Currently the policy is that this should return true if the view 61 // requests. Currently the policy is that this should return true if the view
62 // is being shown and the mouse is not over the view area (!IsMouseHovered). 62 // is being shown and the mouse is not over the view area (!IsMouseHovered).
63 virtual bool CanAcceptRequestUpdate() = 0; 63 virtual bool CanAcceptRequestUpdate() = 0;
64 64
65 // Returns true if the prompt UI will manage hiding itself when the user 65 // Returns true if the prompt UI will manage hiding itself when the user
66 // resolves the prompt, on page navigation/destruction, and on tab switching. 66 // resolves the prompt, on page navigation/destruction, and on tab switching.
67 virtual bool HidesAutomatically() = 0; 67 virtual bool HidesAutomatically() = 0;
68 68
69 // Hides the permission prompt. 69 // Hides the permission prompt.
70 virtual void Hide() = 0; 70 virtual void Hide() = 0;
71 71
72 // Updates where the prompt should be anchored. ex: fullscreen toggle. 72 // Updates where the prompt should be anchored. ex: fullscreen toggle.
73 virtual void UpdateAnchorPosition() = 0; 73 virtual void UpdateAnchorPosition() = 0;
74 74
75 // Returns a reference to this prompt's native window. 75 // Returns a reference to this prompt's native window.
76 // TODO(hcarmona): Remove this as part of the bubble API work. 76 // TODO(hcarmona): Remove this as part of the bubble API work.
77 virtual gfx::NativeWindow GetNativeWindow() = 0; 77 virtual gfx::NativeWindow GetNativeWindow() = 0;
78 }; 78 };
79 79
80 #endif // CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_PROMPT_H_ 80 #endif // CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_PROMPT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698