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