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

Side by Side Diff: chrome/browser/views/create_application_shortcut_view.h

Issue 482003: Get web app icon via FavIconHelper and auto repair/update (Closed)
Patch Set: miranda's review 1 Created 11 years 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_VIEWS_CREATE_APPLICATION_SHORTCUT_VIEW_H_ 5 #ifndef CHROME_BROWSER_VIEWS_CREATE_APPLICATION_SHORTCUT_VIEW_H_
6 #define CHROME_BROWSER_VIEWS_CREATE_APPLICATION_SHORTCUT_VIEW_H_ 6 #define CHROME_BROWSER_VIEWS_CREATE_APPLICATION_SHORTCUT_VIEW_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "chrome/browser/net/url_fetcher.h"
12 #include "chrome/browser/web_applications/web_app.h" 11 #include "chrome/browser/web_applications/web_app.h"
13 #include "views/controls/label.h" 12 #include "views/controls/label.h"
14 #include "views/view.h" 13 #include "views/view.h"
15 #include "views/window/dialog_delegate.h" 14 #include "views/window/dialog_delegate.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
17 #include "webkit/glue/dom_operations.h"
18 16
19 namespace views { 17 namespace views {
20 class Checkbox; 18 class Checkbox;
21 class Label; 19 class Label;
22 class Window; 20 class Window;
23 }; // namespace views 21 }; // namespace views
24 22
25 class MessageLoop; 23 class MessageLoop;
26 class Profile; 24 class Profile;
27 class TabContents; 25 class TabContents;
28 26
29 // CreateShortcutView implements a dialog that asks user where to create 27 // CreateShortcutView implements a dialog that asks user where to create
30 // the shortcut for given web app. 28 // the shortcut for given web app.
31 class CreateApplicationShortcutView : public views::View, 29 class CreateApplicationShortcutView : public views::View,
32 public views::DialogDelegate, 30 public views::DialogDelegate,
33 public views::ButtonListener, 31 public views::ButtonListener {
34 public URLFetcher::Delegate {
35 public: 32 public:
36 explicit CreateApplicationShortcutView(TabContents* tab_contents); 33 explicit CreateApplicationShortcutView(TabContents* tab_contents);
37 virtual ~CreateApplicationShortcutView(); 34 virtual ~CreateApplicationShortcutView();
38 35
39 // Initialize the controls on the dialog. 36 // Initialize the controls on the dialog.
40 void Init(); 37 void Init();
41 38
42 // Overridden from views::View: 39 // Overridden from views::View:
43 virtual gfx::Size GetPreferredSize(); 40 virtual gfx::Size GetPreferredSize();
44 41
45 // Overridden from views::DialogDelegate: 42 // Overridden from views::DialogDelegate:
46 virtual std::wstring GetDialogButtonLabel( 43 virtual std::wstring GetDialogButtonLabel(
47 MessageBoxFlags::DialogButton button) const; 44 MessageBoxFlags::DialogButton button) const;
48 virtual bool IsDialogButtonEnabled( 45 virtual bool IsDialogButtonEnabled(
49 MessageBoxFlags::DialogButton button) const; 46 MessageBoxFlags::DialogButton button) const;
50 virtual bool CanResize() const; 47 virtual bool CanResize() const;
51 virtual bool CanMaximize() const; 48 virtual bool CanMaximize() const;
52 virtual bool IsAlwaysOnTop() const; 49 virtual bool IsAlwaysOnTop() const;
53 virtual bool HasAlwaysOnTopMenu() const; 50 virtual bool HasAlwaysOnTopMenu() const;
54 virtual bool IsModal() const; 51 virtual bool IsModal() const;
55 virtual std::wstring GetWindowTitle() const; 52 virtual std::wstring GetWindowTitle() const;
56 virtual bool Accept(); 53 virtual bool Accept();
57 virtual views::View* GetContentsView(); 54 virtual views::View* GetContentsView();
58 55
59 // Overridden from views::ButtonListener: 56 // Overridden from views::ButtonListener:
60 virtual void ButtonPressed(views::Button* sender, const views::Event& event); 57 virtual void ButtonPressed(views::Button* sender, const views::Event& event);
61 58
62 // URLFetcher::Delegate
63 virtual void OnURLFetchComplete(const URLFetcher* source,
64 const GURL& url,
65 const URLRequestStatus& status,
66 int response_code,
67 const ResponseCookies& cookies,
68 const std::string& data);
69
70 private: 59 private:
71 typedef std::vector<webkit_glue::WebApplicationInfo::IconInfo> IconInfoList;
72
73 // Adds a new check-box as a child to the view. 60 // Adds a new check-box as a child to the view.
74 views::Checkbox* AddCheckbox(const std::wstring& text, bool checked); 61 views::Checkbox* AddCheckbox(const std::wstring& text, bool checked);
75 62
76 // Set icons info from passed-in WebApplicationInfo.
77 void SetIconsInfo(const IconInfoList& icons);
78
79 // Fetch the largest unprocessed icon. 63 // Fetch the largest unprocessed icon.
80 // The first largest icon downloaded and decoded successfully will be used. 64 // The first largest icon downloaded and decoded successfully will be used.
81 void FetchIcon(); 65 void FetchIcon();
82 66
67 // Callback of icon download.
68 void OnIconDownloaded(bool errored, const SkBitmap& image);
69
83 // TabContents of the page that we want to create shortcut. 70 // TabContents of the page that we want to create shortcut.
84 TabContents* tab_contents_; 71 TabContents* tab_contents_;
85 72
86 // UI elements on the dialog. 73 // UI elements on the dialog.
87 views::View* app_info_; 74 views::View* app_info_;
88 views::Label* create_shortcuts_label_; 75 views::Label* create_shortcuts_label_;
89 views::Checkbox* desktop_check_box_; 76 views::Checkbox* desktop_check_box_;
90 views::Checkbox* menu_check_box_; 77 views::Checkbox* menu_check_box_;
91 views::Checkbox* quick_launch_check_box_; 78 views::Checkbox* quick_launch_check_box_;
92 79
93 // Target url of the app shortcut. 80 // Target shortcut info.
94 GURL url_; 81 ShellIntegration::ShortcutInfo shortcut_info_;
95
96 // Title of the app shortcut.
97 string16 title_;
98
99 // Description of the app shortcut.
100 string16 description_;
101
102 // Icon of the app shortcut.
103 SkBitmap icon_;
104 82
105 // Unprocessed icons from the WebApplicationInfo passed in. 83 // Unprocessed icons from the WebApplicationInfo passed in.
106 IconInfoList unprocessed_icons_; 84 web_app::IconInfoList unprocessed_icons_;
107 85
108 // Icon fetcher. 86 // Pending app icon download tracked by us.
109 scoped_ptr<URLFetcher> icon_fetcher_; 87 class IconDownloadCallbackFunctor;
88 IconDownloadCallbackFunctor* pending_download_;
110 89
111 DISALLOW_COPY_AND_ASSIGN(CreateApplicationShortcutView); 90 DISALLOW_COPY_AND_ASSIGN(CreateApplicationShortcutView);
112 }; 91 };
113 92
114 #endif // CHROME_BROWSER_VIEWS_CREATE_APPLICATION_SHORTCUT_VIEW_H_ 93 #endif // CHROME_BROWSER_VIEWS_CREATE_APPLICATION_SHORTCUT_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.cc ('k') | chrome/browser/views/create_application_shortcut_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698