OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CREATE_APPLICATION_SHORTCUT_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_CREATE_APPLICATION_SHORTCUT_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_CREATE_APPLICATION_SHORTCUT_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_CREATE_APPLICATION_SHORTCUT_VIEW_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // URL shortcuts have an info frame at the top with a thumbnail, title and | 45 // URL shortcuts have an info frame at the top with a thumbnail, title and |
46 // description. | 46 // description. |
47 DIALOG_LAYOUT_URL_SHORTCUT, | 47 DIALOG_LAYOUT_URL_SHORTCUT, |
48 | 48 |
49 // App shortcuts don't have an info frame, since they are launched from | 49 // App shortcuts don't have an info frame, since they are launched from |
50 // places where it's clear what app they are from. | 50 // places where it's clear what app they are from. |
51 DIALOG_LAYOUT_APP_SHORTCUT | 51 DIALOG_LAYOUT_APP_SHORTCUT |
52 }; | 52 }; |
53 | 53 |
54 explicit CreateApplicationShortcutView(Profile* profile); | 54 explicit CreateApplicationShortcutView(Profile* profile); |
55 virtual ~CreateApplicationShortcutView(); | 55 ~CreateApplicationShortcutView() override; |
56 | 56 |
57 // Initialize the controls on the dialog. | 57 // Initialize the controls on the dialog. |
58 void InitControls(DialogLayout dialog_layout); | 58 void InitControls(DialogLayout dialog_layout); |
59 | 59 |
60 // Overridden from views::View: | 60 // Overridden from views::View: |
61 virtual gfx::Size GetPreferredSize() const override; | 61 gfx::Size GetPreferredSize() const override; |
62 | 62 |
63 // Overridden from views::DialogDelegate: | 63 // Overridden from views::DialogDelegate: |
64 virtual base::string16 GetDialogButtonLabel( | 64 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; |
65 ui::DialogButton button) const override; | 65 bool IsDialogButtonEnabled(ui::DialogButton button) const override; |
66 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const override; | 66 ui::ModalType GetModalType() const override; |
67 virtual ui::ModalType GetModalType() const override; | 67 base::string16 GetWindowTitle() const override; |
68 virtual base::string16 GetWindowTitle() const override; | 68 bool Accept() override; |
69 virtual bool Accept() override; | |
70 | 69 |
71 // Overridden from views::ButtonListener: | 70 // Overridden from views::ButtonListener: |
72 virtual void ButtonPressed(views::Button* sender, | 71 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
73 const ui::Event& event) override; | |
74 | 72 |
75 protected: | 73 protected: |
76 // Adds a new check-box as a child to the view. | 74 // Adds a new check-box as a child to the view. |
77 views::Checkbox* AddCheckbox(const base::string16& text, bool checked); | 75 views::Checkbox* AddCheckbox(const base::string16& text, bool checked); |
78 | 76 |
79 // Profile in which the shortcuts will be created. | 77 // Profile in which the shortcuts will be created. |
80 Profile* profile_; | 78 Profile* profile_; |
81 | 79 |
82 // UI elements on the dialog. | 80 // UI elements on the dialog. |
83 // May be NULL if we are not displaying the app's info. | 81 // May be NULL if we are not displaying the app's info. |
84 views::View* app_info_; | 82 views::View* app_info_; |
85 views::Label* create_shortcuts_label_; | 83 views::Label* create_shortcuts_label_; |
86 views::Checkbox* desktop_check_box_; | 84 views::Checkbox* desktop_check_box_; |
87 views::Checkbox* menu_check_box_; | 85 views::Checkbox* menu_check_box_; |
88 views::Checkbox* quick_launch_check_box_; | 86 views::Checkbox* quick_launch_check_box_; |
89 | 87 |
90 // Target shortcut and file handler info. | 88 // Target shortcut and file handler info. |
91 web_app::ShortcutInfo shortcut_info_; | 89 web_app::ShortcutInfo shortcut_info_; |
92 extensions::FileHandlersInfo file_handlers_info_; | 90 extensions::FileHandlersInfo file_handlers_info_; |
93 // If false, the shortcut will be created in the root level of the Start Menu. | 91 // If false, the shortcut will be created in the root level of the Start Menu. |
94 bool create_in_chrome_apps_subdir_; | 92 bool create_in_chrome_apps_subdir_; |
95 | 93 |
96 DISALLOW_COPY_AND_ASSIGN(CreateApplicationShortcutView); | 94 DISALLOW_COPY_AND_ASSIGN(CreateApplicationShortcutView); |
97 }; | 95 }; |
98 | 96 |
99 // Create an application shortcut pointing to a URL. | 97 // Create an application shortcut pointing to a URL. |
100 class CreateUrlApplicationShortcutView : public CreateApplicationShortcutView { | 98 class CreateUrlApplicationShortcutView : public CreateApplicationShortcutView { |
101 public: | 99 public: |
102 explicit CreateUrlApplicationShortcutView(content::WebContents* web_contents); | 100 explicit CreateUrlApplicationShortcutView(content::WebContents* web_contents); |
103 virtual ~CreateUrlApplicationShortcutView(); | 101 ~CreateUrlApplicationShortcutView() override; |
104 | 102 |
105 virtual bool Accept() override; | 103 bool Accept() override; |
106 | 104 |
107 private: | 105 private: |
108 // Fetch the largest unprocessed icon. | 106 // Fetch the largest unprocessed icon. |
109 // The first largest icon downloaded and decoded successfully will be used. | 107 // The first largest icon downloaded and decoded successfully will be used. |
110 void FetchIcon(); | 108 void FetchIcon(); |
111 | 109 |
112 // Favicon download callback. | 110 // Favicon download callback. |
113 void DidDownloadFavicon( | 111 void DidDownloadFavicon( |
114 int requested_size, | 112 int requested_size, |
115 int id, | 113 int id, |
(...skipping 17 matching lines...) Expand all Loading... |
133 }; | 131 }; |
134 | 132 |
135 // Create an application shortcut pointing to a chrome application. | 133 // Create an application shortcut pointing to a chrome application. |
136 class CreateChromeApplicationShortcutView | 134 class CreateChromeApplicationShortcutView |
137 : public CreateApplicationShortcutView { | 135 : public CreateApplicationShortcutView { |
138 public: | 136 public: |
139 CreateChromeApplicationShortcutView( | 137 CreateChromeApplicationShortcutView( |
140 Profile* profile, | 138 Profile* profile, |
141 const extensions::Extension* app, | 139 const extensions::Extension* app, |
142 const base::Callback<void(bool)>& close_callback); | 140 const base::Callback<void(bool)>& close_callback); |
143 virtual ~CreateChromeApplicationShortcutView(); | 141 ~CreateChromeApplicationShortcutView() override; |
144 virtual bool Accept() override; | 142 bool Accept() override; |
145 virtual bool Cancel() override; | 143 bool Cancel() override; |
146 | 144 |
147 private: | 145 private: |
148 // Called when the app's ShortcutInfo (with icon) and FileHandlersInfo is | 146 // Called when the app's ShortcutInfo (with icon) and FileHandlersInfo is |
149 // loaded. | 147 // loaded. |
150 void OnAppInfoLoaded(const web_app::ShortcutInfo& shortcut_info, | 148 void OnAppInfoLoaded(const web_app::ShortcutInfo& shortcut_info, |
151 const extensions::FileHandlersInfo& file_handlers_info); | 149 const extensions::FileHandlersInfo& file_handlers_info); |
152 | 150 |
153 base::Callback<void(bool)> close_callback_; | 151 base::Callback<void(bool)> close_callback_; |
154 | 152 |
155 base::WeakPtrFactory<CreateChromeApplicationShortcutView> weak_ptr_factory_; | 153 base::WeakPtrFactory<CreateChromeApplicationShortcutView> weak_ptr_factory_; |
156 | 154 |
157 DISALLOW_COPY_AND_ASSIGN(CreateChromeApplicationShortcutView); | 155 DISALLOW_COPY_AND_ASSIGN(CreateChromeApplicationShortcutView); |
158 }; | 156 }; |
159 | 157 |
160 #endif // CHROME_BROWSER_UI_VIEWS_CREATE_APPLICATION_SHORTCUT_VIEW_H_ | 158 #endif // CHROME_BROWSER_UI_VIEWS_CREATE_APPLICATION_SHORTCUT_VIEW_H_ |
OLD | NEW |