關(guān)于對話框,主要實現(xiàn)了讓用戶查看當(dāng)前軟件的版本、軟件信息和檢查升級的功能。因此這個類主要繼續(xù) ChromeViews::View 類、 ChromeViews::DialogDelegate 和 GoogleUpdateStatusListener 。其中 ChromeViews::View 實現(xiàn)窗口的布局和顯示問題, ChromeViews::DialogDelegate 實現(xiàn)了事件響應(yīng),或者窗口某時是否可以顯示按鈕的問題, GoogleUpdateStatusListener 是用來實現(xiàn)接收更新程序狀態(tài)信息。
這個類的聲明如下:
class AboutChromeView : public ChromeViews::View,
??????????????????????? public ChromeViews::DialogDelegate,
??????????????????????? public GoogleUpdateStatusListener {
? public:
? explicit AboutChromeView(Profile* profile);
? virtual ~AboutChromeView();
? // Initialize the controls on the dialog.
? void Init();
? // Overridden from ChromeViews::View:
? virtual void GetPreferredSize(CSize *out);
? virtual void Layout();
? virtual void ViewHierarchyChanged(bool is_add,
????????????????????????????????? ?? ChromeViews::View* parent,
??????????????????????????????????? ChromeViews::View* child);
? // Overridden from ChromeViews::DialogDelegate:
? virtual int GetDialogButtons() const;
? virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
? ? virtual bool IsDialogButtonEnabled(DialogButton button) const;
? virtual bool IsDialogButtonVisible(DialogButton button) const;
? virtual bool CanResize() const;
? virtual bool CanMaximize() const;
? virtual bool IsAlwaysOnTop() const;
? virtual bool HasAlwaysOnTopMenu() const;
? virtual bool IsModal() const;
? virtual std::wstring GetWindowTitle() const;
? virtual bool Accept();
? virtual ChromeViews::View* GetContentsView();
? // Overridden from GoogleUpdateStatusListener:
? virtual void OnReportResults(GoogleUpdateUpgradeResult result,
?????????????????????????????? GoogleUpdateErrorCode error_code,
?????????????????????????????? const std::wstring& version);
? private:
? // The visible state of the Check For Updates button.
? enum CheckButtonStatus {
? ?? CHECKBUTTON_HIDDEN = 0,
??? CHECKBUTTON_DISABLED,
??? CHECKBUTTON_ENABLED,
? };
? // Update the UI to show the status of the upgrade.
? void UpdateStatus(GoogleUpdateUpgradeResult result,
??????????????????? GoogleUpdateErrorCode error_code);
? Profile* profile_;
? // UI elements on the dialog.
? ChromeViews::ImageView* about_dlg_background_;
? ChromeViews::Label* about_title_label_;
? ChromeViews::TextField* version_label_;
? ChromeViews::TextField* main_text_label_;
? // UI elements we add to the parent view.
? scoped_ptr<ChromeViews::Throbber> throbber_;
? ChromeViews::ImageView success_indicator_;
? ChromeViews::ImageView update_available_indicator_;
? ChromeViews::ImageView timeout_indicator_;
? ChromeViews::Label update_label_;
? // Keeps track of the visible state of the Check For Updates button.
? CheckButtonStatus check_button_status_;
? // The class that communicates with Google Update to find out if an update is
? // available and asks it to start an upgrade.
? GoogleUpdate* google_updater_;
? // Our current version.
? std::wstring current_version_;
? // The version Google Update reports is available to us.
? std::wstring new_version_available_;
? DISALLOW_EVIL_CONSTRUCTORS(AboutChromeView);
};
通過關(guān)于對話框的分析,可以理解到 chrome 瀏覽器窗口基本組成,以及窗口繼承關(guān)系,還有事件的響應(yīng)方式。前面三次分析,主要是入門的分析,也是了解這么一個大工程的一種手段。比如測試整個工程是否可以編譯,是否可以修改代碼等等。后面的分析會以瀏覽器輸入 HTTP 連接開始,直到打開網(wǎng)頁顯示為一個主線,做一個基本的分析。
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
