| OLD | NEW |
| 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_VIEWS_EXTENSIONS_BOOKMARK_APP_BUBBLE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BOOKMARK_APP_BUBBLE_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BOOKMARK_APP_BUBBLE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BOOKMARK_APP_BUBBLE_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "chrome/browser/extensions/app_icon_loader.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| 11 #include "chrome/common/web_application_info.h" | 11 #include "chrome/common/web_application_info.h" |
| 12 #include "ui/views/bubble/bubble_delegate.h" | 12 #include "ui/views/bubble/bubble_delegate.h" |
| 13 #include "ui/views/controls/button/button.h" | 13 #include "ui/views/controls/button/button.h" |
| 14 | 14 |
| 15 class Profile; | |
| 16 | |
| 17 namespace extensions { | |
| 18 class AppIconLoader; | |
| 19 } | |
| 20 | |
| 21 namespace gfx { | 15 namespace gfx { |
| 22 class ImageSkia; | 16 class ImageSkia; |
| 23 } | 17 } |
| 24 | 18 |
| 25 namespace views { | 19 namespace views { |
| 26 class Checkbox; | 20 class Checkbox; |
| 27 class ImageView; | 21 class ImageView; |
| 28 class LabelButton; | 22 class LabelButton; |
| 29 class Textfield; | 23 class Textfield; |
| 30 } | 24 } |
| 31 | 25 |
| 32 // BookmarkAppBubbleView is a view intended to be used as the content of a | 26 // BookmarkAppBubbleView is a view intended to be used as the content of a |
| 33 // Bubble. BookmarkAppBubbleView provides views for editing the bookmark app it | 27 // Bubble. BookmarkAppBubbleView provides views for editing the details to |
| 34 // is created with. Don't create a BookmarkAppBubbleView directly, instead use | 28 // create a bookmark app with. Don't create a BookmarkAppBubbleView directly, |
| 35 // the static ShowBubble method. | 29 // instead use the static ShowBubble method. |
| 36 class BookmarkAppBubbleView : public views::BubbleDelegateView, | 30 class BookmarkAppBubbleView : public views::BubbleDelegateView, |
| 37 public views::ButtonListener, | 31 public views::ButtonListener { |
| 38 public extensions::AppIconLoader::Delegate { | |
| 39 public: | 32 public: |
| 40 ~BookmarkAppBubbleView() override; | 33 ~BookmarkAppBubbleView() override; |
| 41 | 34 |
| 42 static void ShowBubble(views::View* anchor_view, | 35 static void ShowBubble( |
| 43 Profile* profile, | 36 views::View* anchor_view, |
| 44 const WebApplicationInfo& web_app_info, | 37 const WebApplicationInfo& web_app_info, |
| 45 const std::string& extension_id); | 38 const BrowserWindow::ShowBookmarkAppBubbleCallback& callback); |
| 46 | 39 |
| 47 private: | 40 private: |
| 48 // Creates a BookmarkAppBubbleView. | 41 // Creates a BookmarkAppBubbleView. |
| 49 BookmarkAppBubbleView(views::View* anchor_view, | 42 BookmarkAppBubbleView( |
| 50 Profile* profile, | 43 views::View* anchor_view, |
| 51 const WebApplicationInfo& web_app_info, | 44 const WebApplicationInfo& web_app_info, |
| 52 const std::string& extension_id); | 45 const BrowserWindow::ShowBookmarkAppBubbleCallback& callback); |
| 53 | 46 |
| 54 // Overriden from views::BubbleDelegateView: | 47 // Overriden from views::BubbleDelegateView: |
| 55 void Init() override; | 48 void Init() override; |
| 56 views::View* GetInitiallyFocusedView() override; | 49 views::View* GetInitiallyFocusedView() override; |
| 57 | 50 |
| 58 // Overridden from views::WidgetDelegate: | 51 // Overridden from views::WidgetDelegate: |
| 59 void WindowClosing() override; | 52 void WindowClosing() override; |
| 60 | 53 |
| 61 // Overridden from views::View: | 54 // Overridden from views::View: |
| 62 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 55 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 63 gfx::Size GetMinimumSize() const override; | 56 gfx::Size GetMinimumSize() const override; |
| 64 | 57 |
| 65 // Overridden from views::ButtonListener: | 58 // Overridden from views::ButtonListener: |
| 66 // Closes the bubble or opens the edit dialog. | 59 // Closes the bubble or opens the edit dialog. |
| 67 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 60 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 68 | 61 |
| 69 // Overridden from extensions::AppIconLoader::Delegate: | |
| 70 void SetAppImage(const std::string& id, const gfx::ImageSkia& image) override; | |
| 71 | |
| 72 // Handle the message when the user presses a button. | 62 // Handle the message when the user presses a button. |
| 73 void HandleButtonPressed(views::Button* sender); | 63 void HandleButtonPressed(views::Button* sender); |
| 74 | 64 |
| 75 // Sets the title and launch type of the app. | 65 // The WebApplicationInfo that the user is editing. |
| 76 void ApplyEdits(); | 66 WebApplicationInfo web_app_info_; |
| 77 | 67 |
| 78 // The bookmark app bubble, if we're showing one. | 68 // Whether the user has accepted the dialog. |
| 79 static BookmarkAppBubbleView* bookmark_app_bubble_; | 69 bool user_accepted_; |
| 80 | 70 |
| 81 // The profile. | 71 // The callback to be invoked when the dialog is completed. |
| 82 Profile* profile_; | 72 BrowserWindow::ShowBookmarkAppBubbleCallback callback_; |
| 83 | |
| 84 // The WebApplicationInfo being used to create the app. | |
| 85 const WebApplicationInfo web_app_info_; | |
| 86 | |
| 87 // The extension id of the bookmark app. | |
| 88 const std::string extension_id_; | |
| 89 | 73 |
| 90 // Button for removing the bookmark. | 74 // Button for removing the bookmark. |
| 91 views::LabelButton* add_button_; | 75 views::LabelButton* add_button_; |
| 92 | 76 |
| 93 // Button to close the window. | 77 // Button to close the window. |
| 94 views::LabelButton* cancel_button_; | 78 views::LabelButton* cancel_button_; |
| 95 | 79 |
| 96 // Checkbox to launch as a window. | 80 // Checkbox to launch as a window. |
| 97 views::Checkbox* open_as_window_checkbox_; | 81 views::Checkbox* open_as_window_checkbox_; |
| 98 | 82 |
| 99 // Textfield showing the title of the app. | 83 // Textfield showing the title of the app. |
| 100 views::Textfield* title_tf_; | 84 views::Textfield* title_tf_; |
| 101 | 85 |
| 102 // Image showing the icon of the app. | 86 // Image showing the icon of the app. |
| 103 views::ImageView* icon_image_view_; | 87 views::ImageView* icon_image_view_; |
| 104 | 88 |
| 105 // When the destructor is invoked should the app be removed? | |
| 106 bool remove_app_; | |
| 107 | |
| 108 // Used to load the icon. | |
| 109 scoped_ptr<extensions::AppIconLoader> app_icon_loader_; | |
| 110 | |
| 111 DISALLOW_COPY_AND_ASSIGN(BookmarkAppBubbleView); | 89 DISALLOW_COPY_AND_ASSIGN(BookmarkAppBubbleView); |
| 112 }; | 90 }; |
| 113 | 91 |
| 114 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BOOKMARK_APP_BUBBLE_VIEW_H_ | 92 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BOOKMARK_APP_BUBBLE_VIEW_H_ |
| OLD | NEW |