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

Unified Diff: chrome/browser/ui/views/app_list/app_list_controller_win.h

Issue 12207104: Refactor app_list_util.h into AppListService abstract base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix some obvious dumbs Created 7 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/app_list/app_list_controller_win.h
diff --git a/chrome/browser/ui/views/app_list/app_list_controller_win.h b/chrome/browser/ui/views/app_list/app_list_controller_win.h
new file mode 100644
index 0000000000000000000000000000000000000000..494bbf4940e96b5c79caa7043e9ffbd06286023e
--- /dev/null
+++ b/chrome/browser/ui/views/app_list/app_list_controller_win.h
@@ -0,0 +1,170 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_APP_LIST_APP_LIST_CONTROLLER_WIN_H_
+#define CHROME_BROWSER_UI_VIEWS_APP_LIST_APP_LIST_CONTROLLER_WIN_H_
+
+#include <string>
+
+#include "base/file_path.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_info_cache_observer.h"
+#include "chrome/browser/ui/app_list/app_list_controller.h"
+#include "ui/views/bubble/bubble_border.h"
+
+class Profile;
+
+namespace app_list {
+class AppListView;
+}
+
+namespace gfx {
+class Display;
+}
+
+template <typename T> struct DefaultSingletonTraits;
+
+// The AppListController class manages global resources needed for the app
+// list to operate, and controls when the app list is opened and closed.
+class AppListControllerWin : public AppListService,
+ public ProfileInfoCacheObserver {
+ public:
+ static AppListControllerWin* GetInstance();
tapted 2013/02/11 04:04:20 oops - forgot to implement this.
tapted 2013/02/18 07:05:39 Done.
+
+ void set_can_close(bool can_close) { can_close_app_list_ = can_close; }
+ bool can_close() { return can_close_app_list_; }
+ Profile* profile() const { return profile_; }
+ bool app_list_is_showing() const { return app_list_is_showing_; }
benwells 2013/02/11 04:12:32 I don't think this should all be in the .h. It doe
tapted 2013/02/11 05:35:11 the definition or the declaration? Leaving the de
benwells 2013/02/11 05:52:36 Sorry, I meant the whole interface. Unless I'm mis
tapted 2013/02/18 07:05:39 Done.
+
+ // Creates the app list view and populates it from |profile|, but doesn't
+ // show it. Does nothing if the view already exists.
+ void InitView(Profile* profile);
+
+ // Update the profile path stored in local prefs, load it (if not already
+ // loaded), and show the app list.
+ void SetProfilePath(const base::FilePath& profile_file_path);
+
+ void AppListClosing();
+ void AppListActivationChanged(bool active);
+ app_list::AppListView* GetView() { return current_view_; }
+
+ // TODO(koz): Split the responsibility for tracking profiles into a
+ // platform-independent class.
+ // Overidden from ProfileInfoCacheObserver.
+ void OnProfileAdded(const base::FilePath& profilePath) OVERRIDE {}
+ // We need to watch for profile removal to keep kAppListProfile updated.
+ void OnProfileWillBeRemoved(const base::FilePath& profile_path) OVERRIDE;
+ void OnProfileWasRemoved(const base::FilePath& profile_path,
+ const string16& profile_name) OVERRIDE {}
+ void OnProfileNameChanged(const base::FilePath& profile_path,
+ const string16& profile_name) OVERRIDE {}
+ void OnProfileAvatarChanged(const base::FilePath& profile_path) OVERRIDE {}
+
+ void OnBeginExtensionInstall(Profile* profile,
+ const std::string& extension_id,
+ const std::string& extension_name,
+ const gfx::ImageSkia& installing_icon);
+ void OnDownloadProgress(Profile* profile,
+ const std::string& extension_id,
+ int percent_downloaded);
+
+ // AppListService overrides:
+ virtual void Init(Profile* initial_profile) OVERRIDE;
+
+ // Activates the app list at the current mouse cursor location, creating the
+ // app list if necessary.
+ virtual void ShowAppList(Profile* profile) OVERRIDE;
+
+ virtual void SetAppListProfile(Profile* profile) OVERRIDE;
+ virtual void DismissAppList() OVERRIDE;
+ virtual Profile* GetCurrentAppListProfile() OVERRIDE;
+ virtual bool AppListControllerWin::IsAppListVisible() OVERRIDE;
+
+ virtual void NotifyAppListOfBeginExtensionInstall(
+ Profile* profile,
+ const std::string& extension_id,
+ const std::string& extension_name,
+ const gfx::ImageSkia& installing_icon) OVERRIDE;
+
+ virtual void AppListControllerWin::NotifyAppListOfDownloadProgress(
+ Profile* profile,
+ const std::string& extension_id,
+ int percent_downloaded) OVERRIDE;
+
+ private:
+ AppListControllerWin();
+
+ // Loads a profile asynchronously and calls OnProfileLoaded() when done.
+ void LoadProfileAsync(const base::FilePath& profile_file_path);
+
+ // Callback for asynchronous profile load.
+ void OnProfileLoaded(int profile_load_sequence_id,
+ Profile* profile,
+ Profile::CreateStatus status);
+
+ // We need to keep the browser alive while we are loading a profile as that
+ // shows intent to show the app list. These two functions track our pending
+ // profile loads and start or end browser keep alive accordingly.
+ void IncrementPendingProfileLoads();
+ void DecrementPendingProfileLoads();
+
+ // Create or recreate, and initialize |current_view_| from |profile|.
+ void PopulateViewFromProfile(Profile* profile);
+
+ // Utility methods for showing the app list.
+ void SnapArrowLocationToTaskbarEdge(
+ const gfx::Display& display,
+ views::BubbleBorder::ArrowLocation* arrow,
+ gfx::Point* anchor);
+ void UpdateAnchorLocationForCursor(
+ const gfx::Display& display,
+ views::BubbleBorder::ArrowLocation* arrow,
+ gfx::Point* anchor);
+ void UpdateArrowPositionAndAnchorPoint(const gfx::Point& cursor);
+ string16 GetAppListIconPath();
+
+ // Check if the app list or the taskbar has focus. The app list is kept
+ // visible whenever either of these have focus, which allows it to be
+ // pinned but will hide it if it otherwise loses focus. This is checked
+ // periodically whenever the app list does not have focus.
+ void CheckTaskbarOrViewHasFocus();
+
+ // Weak pointer. The view manages its own lifetime.
+ app_list::AppListView* current_view_;
+
+ // Weak pointer. The view owns the view delegate.
+ AppListViewDelegate* view_delegate_;
+
+ // Timer used to check if the taskbar or app list is active. Using a timer
+ // means we don't need to hook Windows, which is apparently not possible
+ // since Vista (and is not nice at any time).
+ base::RepeatingTimer<AppListController> timer_;
+
+ app_list::PaginationModel pagination_model_;
+
+ // The profile the AppList is currently displaying.
+ Profile* profile_;
+
+ // True if the controller can close the app list.
+ bool can_close_app_list_;
+
+ // True if the app list is showing. Used to ensure we only ever have 0 or 1
+ // browser process keep-alives active.
+ bool app_list_is_showing_;
+
+ // Incremented to indicate that pending profile loads are no longer valid.
+ int profile_load_sequence_id_;
+
+ // How many profile loads are pending.
+ int pending_profile_loads_;
benwells 2013/02/11 04:12:32 I think the profile loading stuff should move up t
tapted 2013/02/11 05:35:11 Yeah, OSX will need bits of it too. I've also toy
tapted 2013/02/18 07:05:39 (partly done)
tapted 2013/02/19 03:15:32 I might do the rest in a follow-up once it's clear
+
+ base::WeakPtrFactory<AppListController> weak_factory_;
+
+ friend struct DefaultSingletonTraits<AppListControllerWin>;
+
+ DISALLOW_COPY_AND_ASSIGN(AppListControllerWin);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_APP_LIST_APP_LIST_CONTROLLER_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698