| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_CHOOSER_CONTROLLER_CHOOSER_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_CHOOSER_CONTROLLER_CHOOSER_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_CHOOSER_CONTROLLER_CHOOSER_CONTROLLER_H_ | 6 #define CHROME_BROWSER_CHOOSER_CONTROLLER_CHOOSER_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <utility> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 10 | 12 |
| 11 namespace content { | 13 namespace content { |
| 12 class RenderFrameHost; | 14 class RenderFrameHost; |
| 13 } | 15 } |
| 14 | 16 |
| 15 // Subclass ChooserController to implement a chooser, which has some | 17 // Subclass ChooserController to implement a chooser, which has some |
| 16 // introductory text and a list of options that users can pick one of. | 18 // introductory text and a list of options that users can pick one of. |
| 17 // Your subclass must define the set of options users can pick from; | 19 // Your subclass must define the set of options users can pick from; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 42 // options have been moved earlier by 1 slot. Calling GetOption(index) | 44 // options have been moved earlier by 1 slot. Calling GetOption(index) |
| 43 // from inside a call to OnOptionRemoved will NOT see the removed string | 45 // from inside a call to OnOptionRemoved will NOT see the removed string |
| 44 // since the options have already been updated. | 46 // since the options have already been updated. |
| 45 virtual void OnOptionRemoved(size_t index) = 0; | 47 virtual void OnOptionRemoved(size_t index) = 0; |
| 46 | 48 |
| 47 protected: | 49 protected: |
| 48 virtual ~Observer() {} | 50 virtual ~Observer() {} |
| 49 }; | 51 }; |
| 50 | 52 |
| 51 // Returns the text to be displayed in the chooser title. | 53 // Returns the text to be displayed in the chooser title. |
| 52 base::string16 GetTitle() const; | 54 virtual base::string16 GetTitle() const = 0; |
| 53 | 55 |
| 54 // Returns the label for OK button. | 56 // Returns the label for OK button. |
| 55 virtual base::string16 GetOkButtonLabel() const = 0; | 57 virtual base::string16 GetOkButtonLabel() const = 0; |
| 56 | 58 |
| 57 // The number of options users can pick from. For example, it can be | 59 // The number of options users can pick from. For example, it can be |
| 58 // the number of USB/Bluetooth device names which are listed in the | 60 // the number of USB/Bluetooth device names which are listed in the |
| 59 // chooser so that users can grant permission. | 61 // chooser so that users can grant permission. |
| 60 virtual size_t NumOptions() const = 0; | 62 virtual size_t NumOptions() const = 0; |
| 61 | 63 |
| 62 // The |index|th option string which is listed in the chooser. | 64 // The |index|th option string which is listed in the chooser. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 74 // closes without the user taking an explicit action. | 76 // closes without the user taking an explicit action. |
| 75 virtual void Close() = 0; | 77 virtual void Close() = 0; |
| 76 | 78 |
| 77 // Open help center URL. | 79 // Open help center URL. |
| 78 virtual void OpenHelpCenterUrl() const = 0; | 80 virtual void OpenHelpCenterUrl() const = 0; |
| 79 | 81 |
| 80 // Only one observer may be registered at a time. | 82 // Only one observer may be registered at a time. |
| 81 void set_observer(Observer* observer) { observer_ = observer; } | 83 void set_observer(Observer* observer) { observer_ = observer; } |
| 82 Observer* observer() const { return observer_; } | 84 Observer* observer() const { return observer_; } |
| 83 | 85 |
| 86 protected: |
| 87 // The pair is a (chooser title prefix, URL origin(true)/otherwise(false)). |
| 88 std::pair<base::string16, bool> GetTitlePrefix() const; |
| 89 |
| 84 private: | 90 private: |
| 85 content::RenderFrameHost* owning_frame_; | 91 content::RenderFrameHost* owning_frame_; |
| 86 Observer* observer_ = nullptr; | 92 Observer* observer_ = nullptr; |
| 87 | 93 |
| 88 DISALLOW_COPY_AND_ASSIGN(ChooserController); | 94 DISALLOW_COPY_AND_ASSIGN(ChooserController); |
| 89 }; | 95 }; |
| 90 | 96 |
| 91 #endif // CHROME_BROWSER_CHOOSER_CONTROLLER_CHOOSER_CONTROLLER_H_ | 97 #endif // CHROME_BROWSER_CHOOSER_CONTROLLER_CHOOSER_CONTROLLER_H_ |
| OLD | NEW |