| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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_DOM_UI_DOM_UI_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_DOM_UI_H_ |
| 6 #define CHROME_BROWSER_DOM_UI_DOM_UI_H_ | 6 #define CHROME_BROWSER_DOM_UI_DOM_UI_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 bool hide_favicon() const { | 54 bool hide_favicon() const { |
| 55 return hide_favicon_; | 55 return hide_favicon_; |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Returns true if the bookmark bar should be forced to being visible, | 58 // Returns true if the bookmark bar should be forced to being visible, |
| 59 // overriding the user's preference. | 59 // overriding the user's preference. |
| 60 bool force_bookmark_bar_visible() const { | 60 bool force_bookmark_bar_visible() const { |
| 61 return force_bookmark_bar_visible_; | 61 return force_bookmark_bar_visible_; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Returns true if the extension shelf should be forced to being visible |
| 65 // (if it contains any items), overriding the user's preference. |
| 66 bool force_extension_shelf_visible() const { |
| 67 return force_extension_shelf_visible_; |
| 68 } |
| 69 |
| 64 // Returns true if the location bar should be focused by default rather than | 70 // Returns true if the location bar should be focused by default rather than |
| 65 // the page contents. Some pages will want to use this to encourage the user | 71 // the page contents. Some pages will want to use this to encourage the user |
| 66 // to type in the URL bar. | 72 // to type in the URL bar. |
| 67 bool focus_location_bar_by_default() const { | 73 bool focus_location_bar_by_default() const { |
| 68 return focus_location_bar_by_default_; | 74 return focus_location_bar_by_default_; |
| 69 } | 75 } |
| 70 | 76 |
| 71 // Returns true if the page's URL should be hidden. Some DOM UI pages | 77 // Returns true if the page's URL should be hidden. Some DOM UI pages |
| 72 // like the new tab page will want to hide it. | 78 // like the new tab page will want to hide it. |
| 73 bool should_hide_url() const { | 79 bool should_hide_url() const { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 115 |
| 110 Profile* GetProfile(); | 116 Profile* GetProfile(); |
| 111 | 117 |
| 112 protected: | 118 protected: |
| 113 void AddMessageHandler(DOMMessageHandler* handler); | 119 void AddMessageHandler(DOMMessageHandler* handler); |
| 114 | 120 |
| 115 // Options that may be overridden by individual DOM UI implementations. The | 121 // Options that may be overridden by individual DOM UI implementations. The |
| 116 // bool options default to false. See the public getters for more information. | 122 // bool options default to false. See the public getters for more information. |
| 117 bool hide_favicon_; | 123 bool hide_favicon_; |
| 118 bool force_bookmark_bar_visible_; | 124 bool force_bookmark_bar_visible_; |
| 125 bool force_extension_shelf_visible_; |
| 119 bool focus_location_bar_by_default_; | 126 bool focus_location_bar_by_default_; |
| 120 bool should_hide_url_; | 127 bool should_hide_url_; |
| 121 string16 overridden_title_; // Defaults to empty string. | 128 string16 overridden_title_; // Defaults to empty string. |
| 122 PageTransition::Type link_transition_type_; // Defaults to LINK. | 129 PageTransition::Type link_transition_type_; // Defaults to LINK. |
| 123 int bindings_; // The bindings from BindingsPolicy that should be enabled for | 130 int bindings_; // The bindings from BindingsPolicy that should be enabled for |
| 124 // this page. | 131 // this page. |
| 125 | 132 |
| 126 private: | 133 private: |
| 127 // Execute a string of raw Javascript on the page. | 134 // Execute a string of raw Javascript on the page. |
| 128 void ExecuteJavascript(const std::wstring& javascript); | 135 void ExecuteJavascript(const std::wstring& javascript); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 139 | 146 |
| 140 DISALLOW_COPY_AND_ASSIGN(DOMUI); | 147 DISALLOW_COPY_AND_ASSIGN(DOMUI); |
| 141 }; | 148 }; |
| 142 | 149 |
| 143 // Messages sent from the DOM are forwarded via the DOMUI to handler | 150 // Messages sent from the DOM are forwarded via the DOMUI to handler |
| 144 // classes. These objects are owned by DOMUI and destroyed when the | 151 // classes. These objects are owned by DOMUI and destroyed when the |
| 145 // host is destroyed. | 152 // host is destroyed. |
| 146 class DOMMessageHandler { | 153 class DOMMessageHandler { |
| 147 public: | 154 public: |
| 148 DOMMessageHandler() : dom_ui_(NULL) {} | 155 DOMMessageHandler() : dom_ui_(NULL) {} |
| 149 virtual ~DOMMessageHandler() {}; | 156 virtual ~DOMMessageHandler() {} |
| 150 | 157 |
| 151 // Attaches |this| to |dom_ui| in order to handle messages from it. Declared | 158 // Attaches |this| to |dom_ui| in order to handle messages from it. Declared |
| 152 // virtual so that subclasses can do special init work as soon as the dom_ui | 159 // virtual so that subclasses can do special init work as soon as the dom_ui |
| 153 // is provided. Returns |this| for convenience. | 160 // is provided. Returns |this| for convenience. |
| 154 virtual DOMMessageHandler* Attach(DOMUI* dom_ui); | 161 virtual DOMMessageHandler* Attach(DOMUI* dom_ui); |
| 155 protected: | 162 protected: |
| 156 // Adds "url" and "title" keys on incoming dictionary, setting title | 163 // Adds "url" and "title" keys on incoming dictionary, setting title |
| 157 // as the url as a fallback on empty title. | 164 // as the url as a fallback on empty title. |
| 158 static void SetURLAndTitle(DictionaryValue* dictionary, | 165 static void SetURLAndTitle(DictionaryValue* dictionary, |
| 159 std::wstring title, | 166 std::wstring title, |
| 160 const GURL& gurl); | 167 const GURL& gurl); |
| 161 | 168 |
| 162 // This is where subclasses specify which messages they'd like to handle. | 169 // This is where subclasses specify which messages they'd like to handle. |
| 163 virtual void RegisterMessages() = 0; | 170 virtual void RegisterMessages() = 0; |
| 164 | 171 |
| 165 // Extract an integer value from a Value. | 172 // Extract an integer value from a Value. |
| 166 bool ExtractIntegerValue(const Value* value, int* out_int); | 173 bool ExtractIntegerValue(const Value* value, int* out_int); |
| 167 | 174 |
| 168 // Extract a string value from a Value. | 175 // Extract a string value from a Value. |
| 169 std::wstring ExtractStringValue(const Value* value); | 176 std::wstring ExtractStringValue(const Value* value); |
| 170 | 177 |
| 171 DOMUI* dom_ui_; | 178 DOMUI* dom_ui_; |
| 172 | 179 |
| 173 private: | 180 private: |
| 174 DISALLOW_COPY_AND_ASSIGN(DOMMessageHandler); | 181 DISALLOW_COPY_AND_ASSIGN(DOMMessageHandler); |
| 175 }; | 182 }; |
| 176 | 183 |
| 177 #endif // CHROME_BROWSER_DOM_UI_DOM_UI_H_ | 184 #endif // CHROME_BROWSER_DOM_UI_DOM_UI_H_ |
| OLD | NEW |